Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update to latest go-git #316

@smola

Description

@smola

Let's keep up with go-git bugfixes and update it.

commit 12b1bd549630fb6f3ad2c7f22bdba1e55937534f
Author: Santiago M. Mola <[email protected]>
Date:   Thu Aug 9 11:19:10 2018 +0200

    test: ensure HEAD exists on fixtures

    Newer git versions give an error when trying to fetch a refspec that
    not use wildcard and does not match anything (as git itself does).

    Borges always asks for HEAD explicitely, so we need to create it on
    our fixtures.

    Signed-off-by: Santiago M. Mola <[email protected]>

diff --git a/fixtures_test.go b/fixtures_test.go
index 119f6c1..a1e3cef 100644
--- a/fixtures_test.go
+++ b/fixtures_test.go
@@ -238,6 +238,17 @@ func (f *ChangesFixture) setReferences(r *git.Repository, refs []*model.Referenc
                }
        }

+       // If there is no explicit HEAD, set it to the first reference.
+       // This will avoid errors on missing HEAD, since borges expects HEAD to
+       // exist.
+       if _, err := r.Storer.Reference(plumbing.HEAD); err != nil {
+               err := r.Storer.SetReference(plumbing.NewSymbolicReference(
+                       plumbing.HEAD, plumbing.ReferenceName(refs[0].Name)))
+               if err != nil {
+                       return err
+               }
+       }
+
        return nil
 }

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions