Skip to content

Conversation

GiteaBot
Copy link
Collaborator

@GiteaBot GiteaBot commented Dec 7, 2023

Backport #28348 by @AdamMajer

nogogit GetBranchNames() lists branches sorted in reverse commit date order. On the other hand the gogit implementation doesn't apply any ordering resulting in unpredictable behaviour. In my case, the unit tests requiring particular order fail

repo_branch_test.go:24:
            Error Trace:
           ./gitea/modules/git/repo_branch_test.go:24
            Error:          elements differ

                            extra elements in list A:
                            ([]interface {}) (len=1) {
                             (string) (len=6) "master"
                            }

                            extra elements in list B:
                            ([]interface {}) (len=1) {
                             (string) (len=7) "branch1"
                            }

                            listA:
                            ([]string) (len=2) {
                             (string) (len=6) "master",
                             (string) (len=7) "branch2"
                            }

                            listB:
                            ([]string) (len=2) {
                             (string) (len=7) "branch1",
                             (string) (len=7) "branch2"
                            }
            Test:           TestRepository_GetBranches

To fix this, we sort branches based on their commit date in gogit implementation.

Fixes: #28318

@GiteaBot GiteaBot added type/bug lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 7, 2023
@GiteaBot GiteaBot added this to the 1.21.2 milestone Dec 7, 2023
@techknowlogick techknowlogick merged commit 272ae03 into go-gitea:release/v1.21 Dec 7, 2023
@techknowlogick techknowlogick deleted the backport-28348-v1.21 branch December 7, 2023 18:03
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Mar 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants