Print the git hash for any rev

This commit is contained in:
Tim Hockin 2016-08-20 21:47:20 -07:00
parent 75998b9237
commit 7fcc902aa7
1 changed files with 10 additions and 0 deletions

10
main.go
View File

@ -200,6 +200,16 @@ func addWorktreeAndSwap(gitRoot, dest, branch, rev string) error {
}
log.Printf("fetched origin/%s", branch)
// find the real commit for the rev
output, err := runCommand(gitRoot, "git", "rev-list", "-n1", rev)
if err != nil {
return err
}
revhash := strings.Trim(string(output), "\n")
if revhash != rev {
log.Printf("rev %s resolves to %s", rev, revhash)
}
// add worktree in subdir
rand.Seed(time.Now().UnixNano())
worktreePath := path.Join(gitRoot, "rev-"+strconv.Itoa(rand.Int()))