summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-01-09 21:34:17 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-01-09 22:36:07 +1100
commit9b32e99eb80d3912ecfef3303418e6dce8219a75 (patch)
tree0d0b526703132dfcf64dd47bbc8598fdfdcd7525 /pkg/commands/git.go
parent79e696d8a747edc3bf1b9ddbd8dcd5038ec7d7ba (diff)
add reflog tab in commits panel
Diffstat (limited to 'pkg/commands/git.go')
-rw-r--r--pkg/commands/git.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 0975ba501..f72280d64 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -1113,3 +1113,28 @@ func (c *GitCommand) PushTag(remoteName string, tagName string) error {
func (c *GitCommand) FetchRemote(remoteName string) error {
return c.OSCommand.RunCommand("git fetch %s", remoteName)
}
+
+func (c *GitCommand) GetReflogCommits() ([]*Commit, error) {
+ output, err := c.OSCommand.RunCommandWithOutput("git reflog")
+ if err != nil {
+ return nil, err
+ }
+
+ lines := strings.Split(strings.TrimSpace(output), "\n")
+ commits := make([]*Commit, len(lines))
+ re := regexp.MustCompile(`(\w+).*HEAD@\{\d+\}: (.*)`)
+ for i, line := range lines {
+ match := re.FindStringSubmatch(line)
+ if len(match) == 1 {
+ continue
+ }
+
+ commits[i] = &Commit{
+ Sha: match[1],
+ Name: match[2],
+ Status: "reflog",
+ }
+ }
+
+ return commits, nil
+}