Skip to content

Commit

Permalink
Merge pull request #463 from fluxcd/go-git-bc-tag
Browse files Browse the repository at this point in the history
go-git: transform revision for last observed tag
  • Loading branch information
hiddeco authored Feb 10, 2023
2 parents 0009fda + da9a7b7 commit c28ef00
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions git/gogit/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ func (g *Client) cloneTag(ctx context.Context, url, tag string, opts repository.

ref := plumbing.NewTagReferenceName(tag)
// check if previous revision has changed before attempting to clone
if opts.LastObservedCommit != "" {
if lastObserved := git.TransformRevision(opts.LastObservedCommit); lastObserved != "" {
head, err := getRemoteHEAD(ctx, url, ref, g.authOpts, authMethod)
if err != nil {
return nil, err
}

if head != "" && head == opts.LastObservedCommit {
if head != "" && head == lastObserved {
c := &git.Commit{
Hash: git.ExtractHashFromRevision(head),
Reference: ref.String(),
Expand Down Expand Up @@ -364,11 +363,11 @@ func recurseSubmodules(recurse bool) extgogit.SubmoduleRescursivity {

func getRemoteHEAD(ctx context.Context, url string, ref plumbing.ReferenceName,
authOpts *git.AuthOptions, authMethod transport.AuthMethod) (string, error) {
config := &config.RemoteConfig{
remoteCfg := &config.RemoteConfig{
Name: git.DefaultRemote,
URLs: []string{url},
}
remote := extgogit.NewRemote(memory.NewStorage(), config)
remote := extgogit.NewRemote(memory.NewStorage(), remoteCfg)
listOpts := &extgogit.ListOptions{
Auth: authMethod,
CABundle: authOpts.CAFile,
Expand Down

0 comments on commit c28ef00

Please sign in to comment.