diff --git a/cmd/reset.go b/cmd/reset.go index f42c8f32..8178c730 100644 --- a/cmd/reset.go +++ b/cmd/reset.go @@ -56,7 +56,7 @@ func Reset(c *git.Client, args []string) { // git reset [mode] commit // First, update the head reference for all modes branchName := c.GetHeadBranch() - err := c.GitDir.WriteFile(git.File("refs/heads/"+branchName), + err := c.GitDir.WriteFile(git.File(branchName.String()), []byte(fmt.Sprintf("%s", commitId)), 0644, ) diff --git a/git/refspec.go b/git/refspec.go index 89110f18..1c749819 100644 --- a/git/refspec.go +++ b/git/refspec.go @@ -34,6 +34,10 @@ func (r RefSpec) Value(c *Client) (string, error) { // Use GetBranch to get a valid branch from a branchname, don't cast from string type Branch RefSpec +// Implements Stringer on Branch +func (b Branch) String() string { + return RefSpec(b).String() +} // Returns a valid Branch object for an existing branch. func GetBranch(c *Client, branchname string) (Branch, error) { b := Branch("refs/heads/" + branchname)