Skip to content

Commit

Permalink
siva: rooted ref iterator should not return HEAD
Browse files Browse the repository at this point in the history
Signed-off-by: Javi Fontan <jfontan@gmail.com>
  • Loading branch information
jfontan committed Jun 8, 2019
1 parent 983a4dc commit 1fbfe7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 5 additions & 0 deletions siva/rooted_storage.go
Expand Up @@ -294,6 +294,11 @@ func (r *refIter) Next() (*plumbing.Reference, error) {

name := string(ref.Name())
if strings.HasPrefix(name, r.prefix) {
// skip head
if strings.TrimPrefix(name, r.prefix) == plumbing.HEAD.String() {
continue
}

return r.sto.convertReferenceFromRemote(ref)
}
}
Expand Down
9 changes: 0 additions & 9 deletions siva/rooted_storage_test.go
Expand Up @@ -26,19 +26,13 @@ func TestRootedIterateReferences(t *testing.T) {
expected: []*plumbing.Reference{
hr("refs/heads/fix", "e09387d4fb5e8ac82494955d03733a63f1936cd9"),
hr("refs/heads/master", "4debba8a88e808bdef8364026db890c5cb2900de"),
// now symbolic references are converted to hash references
// sr("HEAD", "refs/heads/fix"),
hr("HEAD", "e09387d4fb5e8ac82494955d03733a63f1936cd9"),
},
},
{
name: "gitserver.com/b",
expected: []*plumbing.Reference{
hr("refs/heads/fix", "0c17762a2c24b2e9c01aea9ba3dc15e5176e68da"),
hr("refs/heads/master", "8c46128f7f8dca511321eb58940da6138a42ab42"),
// now symbolic references are converted to hash references
// sr("HEAD", "refs/heads/master"),
hr("HEAD", "8c46128f7f8dca511321eb58940da6138a42ab42"),

// remotes
hr("refs/remotes/origin/fix", "e09387d4fb5e8ac82494955d03733a63f1936cd9"),
Expand All @@ -51,9 +45,6 @@ func TestRootedIterateReferences(t *testing.T) {
expected: []*plumbing.Reference{
hr("refs/heads/css", "d47421c1ab4ab5d2e00ba5f0bbeccf9578dd3d5c"),
hr("refs/heads/master", "75129d3d3cc746b4cd335f9c01f1dad21d865403"),
// now symbolic references are converted to hash references
// sr("HEAD", "refs/heads/css"),
hr("HEAD", "d47421c1ab4ab5d2e00ba5f0bbeccf9578dd3d5c"),

// remotes
hr("refs/remotes/origin/fix", "0c17762a2c24b2e9c01aea9ba3dc15e5176e68da"),
Expand Down

0 comments on commit 1fbfe7a

Please sign in to comment.