Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

// Commit represents a git commit.
type Commit struct {
Branch string // Branch this commit belongs to
Tree
ID SHA1 // The ID of this commit object
Author *Signature
Expand Down
10 changes: 9 additions & 1 deletion repo_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strconv"
"strings"

"github.com/mcuadros/go-version"
version "github.com/mcuadros/go-version"
)

// GetRefCommitID returns the last commit ID string of given reference (branch or tag).
Expand Down Expand Up @@ -130,6 +130,14 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
commit.repo = repo
commit.ID = id

data, err = NewCommand("name-rev", id.String()).RunInDirBytes(repo.Path)
if err != nil {
return nil, err
}

// name-rev commitID ouput will be "COMMIT_ID master" or "COMMIT_ID master~12"
commit.Branch = strings.Split(strings.Split(string(data), " ")[1], "~")[0]

repo.commitCache.Set(id.String(), commit)
return commit, nil
}
Expand Down