summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-29 10:11:15 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-29 11:37:29 +1100
commita2790cfe8e6705ebd81c63df2154ec82cb645ae3 (patch)
treeba41523fe4726471a8dfab7c29c93a0365dcb67b /pkg/commands
parent624ae45ebb3f54499a25c4eba0844fa971277c34 (diff)
rename to filtered mode
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/commit_list_builder.go14
-rw-r--r--pkg/commands/git.go34
2 files changed, 24 insertions, 24 deletions
diff --git a/pkg/commands/commit_list_builder.go b/pkg/commands/commit_list_builder.go
index c216cec7b..6aa59e920 100644
--- a/pkg/commands/commit_list_builder.go
+++ b/pkg/commands/commit_list_builder.go
@@ -84,8 +84,8 @@ func (c *CommitListBuilder) extractCommitFromLine(line string) *Commit {
}
type GetCommitsOptions struct {
- Limit bool
- LogScope string
+ Limit bool
+ FilterPath string
}
// GetCommits obtains the commits of the current branch
@@ -96,7 +96,7 @@ func (c *CommitListBuilder) GetCommits(options GetCommitsOptions) ([]*Commit, er
if err != nil {
return nil, err
}
- if rebaseMode != "" && options.LogScope == "" {
+ if rebaseMode != "" && options.FilterPath == "" {
// here we want to also prepend the commits that we're in the process of rebasing
rebasingCommits, err = c.getRebasingCommits(rebaseMode)
if err != nil {
@@ -305,10 +305,10 @@ func (c *CommitListBuilder) getLogCmd(options GetCommitsOptions) *exec.Cmd {
limitFlag = "-300"
}
- scopeFlag := ""
- if options.LogScope != "" {
- scopeFlag = fmt.Sprintf(" -- %s", c.OSCommand.Quote(options.LogScope))
+ filterFlag := ""
+ if options.FilterPath != "" {
+ filterFlag = fmt.Sprintf(" --follow -- %s", c.OSCommand.Quote(options.FilterPath))
}
- return c.OSCommand.ExecutableFromString(fmt.Sprintf("git log --oneline --pretty=format:\"%%H%s%%at%s%%aN%s%%d%s%%s\" %s --abbrev=%d --date=unix %s", SEPARATION_CHAR, SEPARATION_CHAR, SEPARATION_CHAR, SEPARATION_CHAR, limitFlag, 20, scopeFlag))
+ return c.OSCommand.ExecutableFromString(fmt.Sprintf("git log --oneline --pretty=format:\"%%H%s%%at%s%%aN%s%%d%s%%s\" %s --abbrev=%d --date=unix %s", SEPARATION_CHAR, SEPARATION_CHAR, SEPARATION_CHAR, SEPARATION_CHAR, limitFlag, 20, filterFlag))
}
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 84e8d50a4..6bf74b864 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -156,7 +156,7 @@ func findDotGitDir(stat func(string) (os.FileInfo, error), readFile func(filenam
return strings.TrimSpace(strings.TrimPrefix(fileContent, "gitdir: ")), nil
}
-func (c *GitCommand) getStashEntriesWithoutScope() []*StashEntry {
+func (c *GitCommand) getUnfilteredStashEntries() []*StashEntry {
unescaped := "git stash list --pretty='%gs'"
rawString, _ := c.OSCommand.RunCommandWithOutput(unescaped)
stashEntries := []*StashEntry{}
@@ -167,15 +167,15 @@ func (c *GitCommand) getStashEntriesWithoutScope() []*StashEntry {
}
// GetStashEntries stash entries
-func (c *GitCommand) GetStashEntries(scope string) []*StashEntry {
- if scope == "" {
- return c.getStashEntriesWithoutScope()
+func (c *GitCommand) GetStashEntries(filterPath string) []*StashEntry {
+ if filterPath == "" {
+ return c.getUnfilteredStashEntries()
}
unescaped := fmt.Sprintf("git stash list --name-only")
rawString, err := c.OSCommand.RunCommandWithOutput(unescaped)
if err != nil {
- return c.getStashEntriesWithoutScope()
+ return c.getUnfilteredStashEntries()
}
stashEntries := []*StashEntry{}
var currentStashEntry *StashEntry
@@ -191,12 +191,12 @@ outer:
match := re.FindStringSubmatch(lines[i])
idx, err := strconv.Atoi(match[1])
if err != nil {
- return c.getStashEntriesWithoutScope()
+ return c.getUnfilteredStashEntries()
}
currentStashEntry = stashEntryFromLine(lines[i], idx)
for i+1 < len(lines) && !isAStash(lines[i+1]) {
i++
- if lines[i] == scope {
+ if lines[i] == filterPath {
stashEntries = append(stashEntries, currentStashEntry)
continue outer
}
@@ -605,12 +605,12 @@ func (c *GitCommand) Ignore(filename string) error {
return c.OSCommand.AppendLineToFile(".gitignore", filename)
}
-func (c *GitCommand) ShowCmdStr(sha string, scope string) string {
- scopeArg := ""
- if scope != "" {
- scopeArg = fmt.Sprintf(" -- %s", c.OSCommand.Quote(scope))
+func (c *GitCommand) ShowCmdStr(sha string, filterPath string) string {
+ filterPathArg := ""
+ if filterPath != "" {
+ filterPathArg = fmt.Sprintf(" -- %s", c.OSCommand.Quote(filterPath))
}
- return fmt.Sprintf("git show --color=%s --no-renames --stat -p %s %s", c.colorArg(), sha, scopeArg)
+ return fmt.Sprintf("git show --color=%s --no-renames --stat -p %s %s", c.colorArg(), sha, filterPathArg)
}
func (c *GitCommand) GetBranchGraphCmdStr(branchName string) string {
@@ -1163,16 +1163,16 @@ func (c *GitCommand) FetchRemote(remoteName string) error {
// GetReflogCommits only returns the new reflog commits since the given lastReflogCommit
// if none is passed (i.e. it's value is nil) then we get all the reflog commits
-func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit, scope string) ([]*Commit, bool, error) {
+func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit, filterPath string) ([]*Commit, bool, error) {
commits := make([]*Commit, 0)
re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`)
- scopeArg := ""
- if scope != "" {
- scopeArg = fmt.Sprintf(" -- %s", c.OSCommand.Quote(scope))
+ filterPathArg := ""
+ if filterPath != "" {
+ filterPathArg = fmt.Sprintf(" --follow -- %s", c.OSCommand.Quote(filterPath))
}
- cmd := c.OSCommand.ExecutableFromString(fmt.Sprintf("git reflog --abbrev=20 --date=unix %s", scopeArg))
+ cmd := c.OSCommand.ExecutableFromString(fmt.Sprintf("git reflog --abbrev=20 --date=unix %s", filterPathArg))
onlyObtainedNewReflogCommits := false
err := RunLineOutputCmd(cmd, func(line string) (bool, error) {
match := re.FindStringSubmatch(line)