Skip to content

Commit 3a4e6a6

Browse files
Fix go-git unit tests (#150)
* fix: update git unit tests to prepare for go-git update * chore: Bump go to 1.23.10
1 parent 16603e9 commit 3a4e6a6

10 files changed

Lines changed: 2055 additions & 67 deletions

File tree

.github/workflows/go.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
name: Set up Go
2424
uses: actions/setup-go@v3
2525
with:
26-
go-version: 1.22
26+
go-version: 1.23.10
2727

2828
-
2929
name: Check out code

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
name: Set up Go
2323
uses: actions/setup-go@v3
2424
with:
25-
go-version: 1.22
25+
go-version: 1.23.10
2626

2727
-
2828
name: Restore Go modules cache

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ COMMIT ?= $(shell git rev-parse HEAD | cut -c-7)
1616
BUILD_AT ?= $(shell date +"%Y.%m.%d %H:%M %Z")
1717

1818
install: bin/$(OS)/staticcheck bin/$(OS)/cel
19+
1920
bin/$(OS)/staticcheck:
20-
go install honnef.co/go/tools/cmd/staticcheck@2023.1.3
21+
go install honnef.co/go/tools/cmd/staticcheck@2025.1.1
2122

22-
cel:
23+
bin/$(OS)/cel:
2324
go install github.com/epam/hubctl/cmd/cel@latest
24-
.PHONY: cel
2525

2626
deps:
2727
go mod download

cmd/hub/git/git.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
goGit "github.com/go-git/go-git/v5"
1515
goGitConfig "github.com/go-git/go-git/v5/config"
1616
"github.com/go-git/go-git/v5/plumbing"
17+
"github.com/go-git/go-git/v5/plumbing/storer"
1718
"github.com/go-git/go-git/v5/storage/memory"
1819
)
1920

@@ -67,7 +68,11 @@ func Pull(targetRef, dir string) error {
6768
}
6869
defer refs.Close()
6970

70-
for ref, err := refs.Next(); err == nil; {
71+
refIter := storer.NewReferenceFilteredIter(func(r *plumbing.Reference) bool {
72+
return r.Hash() == reference.Hash() && r.Name() != plumbing.HEAD
73+
}, refs)
74+
75+
for ref, err := refIter.Next(); err == nil; {
7176
if ref.Hash() == reference.Hash() {
7277
reference = ref
7378
break

0 commit comments

Comments
 (0)