Skip to content

Commit

Permalink
Support tag name in revision attribute (stormcat24#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
stormcat24 authored Jan 6, 2020
1 parent 3cd3153 commit 19b2cce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import "github.com/stormcat24/protodep/cmd"
import (
"github.com/stormcat24/protodep/cmd"
)

func main() {
cmd.Execute()
Expand Down
10 changes: 10 additions & 0 deletions repository/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ func (r *GitHubRepository) Open() (*OpenedRepository, error) {
return nil, errors.Wrapf(err, "checkout to %s is failed", revision)
}

tag := plumbing.NewTagReferenceName(revision)
ref, err := rep.Reference(tag, false)
if err != nil && err != plumbing.ErrReferenceNotFound {
return nil, errors.Wrapf(err, "tag = %s", tag)
}

if ref != nil {
hash = ref.Hash()
}

head := plumbing.NewHashReference(plumbing.HEAD, hash)
if err := rep.Storer.SetReference(head); err != nil {
return nil, errors.Wrapf(err, "set head to %s is failed", revision)
Expand Down

0 comments on commit 19b2cce

Please sign in to comment.