Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce long output of "git status" #2650

Merged
merged 15 commits into from
Nov 7, 2023
2 changes: 1 addition & 1 deletion features/append/features/verbose.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: display all executed Git commands
| existing | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| existing | frontend | git checkout main |
| main | frontend | git rebase origin/main |
| | backend | git rev-list --left-right main...origin/main |
Expand Down
4 changes: 2 additions & 2 deletions features/hack/features/verbose.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: display all executed Git commands
| main | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| main | frontend | git rebase origin/main |
| | backend | git rev-list --left-right main...origin/main |
| | backend | git show-ref --verify --quiet refs/heads/main |
Expand Down Expand Up @@ -52,7 +52,7 @@ Feature: display all executed Git commands
| | backend | git stash list |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git config --unset git-town-branch.new.parent |
| new | frontend | git checkout main |
| | backend | git rev-parse --short HEAD |
Expand Down
4 changes: 2 additions & 2 deletions features/kill/current_branch/features/verbose.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Feature: display all executed Git commands
| | backend | git rev-parse --show-toplevel |
| | backend | git stash list |
| | backend | git remote |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git rev-parse --abbrev-ref HEAD |
| current | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| current | frontend | git push origin :current |
| | frontend | git checkout main |
| | backend | git log main..current |
Expand Down
2 changes: 1 addition & 1 deletion features/new_pull_request/features/verbose.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: display all executed Git commands
| feature | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| feature | frontend | git checkout main |
| main | frontend | git rebase origin/main |
| | backend | git rev-list --left-right main...origin/main |
Expand Down
4 changes: 2 additions & 2 deletions features/prepend/features/verbose.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: display all executed Git commands
| old | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| old | frontend | git checkout main |
| main | frontend | git rebase origin/main |
| | backend | git rev-list --left-right main...origin/main |
Expand Down Expand Up @@ -60,7 +60,7 @@ Feature: display all executed Git commands
| | backend | git stash list |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git config --unset git-town-branch.parent.parent |
| | backend | git config git-town-branch.old.parent main |
| parent | frontend | git checkout old |
Expand Down
2 changes: 1 addition & 1 deletion features/rename_branch/features/verbose.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Feature: display all executed Git commands
| | backend | git stash list |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git config --unset git-town-branch.new.parent |
| | backend | git config git-town-branch.old.parent main |
| new | frontend | git branch old {{ sha 'old commit' }} |
Expand Down
8 changes: 4 additions & 4 deletions features/ship/current_branch/features/verbose.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Feature: display all executed Git commands
| | backend | git rev-parse --show-toplevel |
| | backend | git stash list |
| | backend | git branch -vva |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git remote |
| feature | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git remote get-url origin |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| feature | frontend | git checkout main |
| main | frontend | git rebase origin/main |
| | backend | git rev-list --left-right main...origin/main |
Expand Down Expand Up @@ -70,7 +70,7 @@ Feature: display all executed Git commands
| | backend | git stash list |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git config git-town-branch.feature.parent main |
| | backend | git log --pretty=format:%h -10 |
| main | frontend | git revert {{ sha 'done' }} |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: display all executed Git commands
| old | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| old | frontend | git checkout main |
| main | frontend | git rebase origin/main |
| | backend | git rev-list --left-right main...origin/main |
Expand Down Expand Up @@ -67,7 +67,7 @@ Feature: display all executed Git commands
| | backend | git stash list |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git config git-town-branch.old.parent main |
| main | frontend | git branch old {{ sha 'Initial commit' }} |
| | frontend | git checkout old |
Expand Down
2 changes: 1 addition & 1 deletion features/sync/features/verbose.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Feature: display all executed Git commands
| feature | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| feature | frontend | git checkout main |
| main | frontend | git rebase origin/main |
| | backend | git rev-list --left-right main...origin/main |
Expand Down
2 changes: 1 addition & 1 deletion src/git/backend_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func (self *BackendCommands) RemoveOutdatedConfiguration(allBranches domain.Bran

// HasConflicts returns whether the local repository currently has unresolved merge conflicts.
func (self *BackendCommands) RepoStatus() (domain.RepoStatus, error) {
output, err := self.QueryTrim("git", "status", "--ignore-submodules")
output, err := self.QueryTrim("git", "status", "--long", "--ignore-submodules")
if err != nil {
return domain.RepoStatus{}, fmt.Errorf(messages.ConflictDetectionProblem, err)
}
Expand Down
46 changes: 46 additions & 0 deletions src/git/backend_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,52 @@ func TestBackendCommands(t *testing.T) {
must.NoError(t, err)
must.True(t, have.OpenChanges)
})

t.Run("status.short enabled", func(t *testing.T) {
t.Parallel()
t.Run("no open changes", func(t *testing.T) {
t.Parallel()
runtime := testruntime.Create(t)
err := runtime.Run("git", "config", "status.short", "true")
must.NoError(t, err)
have, err := runtime.Backend.RepoStatus()
must.NoError(t, err)
must.False(t, have.OpenChanges)
})
t.Run("open changes", func(t *testing.T) {
t.Parallel()
runtime := testruntime.Create(t)
runtime.CreateFile("file", "stashed content")
err := runtime.Run("git", "config", "status.short", "true")
must.NoError(t, err)
have, err := runtime.Backend.RepoStatus()
must.NoError(t, err)
must.True(t, have.OpenChanges)
})
})

t.Run("status.branch enabled", func(t *testing.T) {
t.Parallel()
t.Run("no open changes", func(t *testing.T) {
t.Parallel()
runtime := testruntime.Create(t)
err := runtime.Run("git", "config", "status.branch", "true")
must.NoError(t, err)
have, err := runtime.Backend.RepoStatus()
must.NoError(t, err)
must.False(t, have.OpenChanges)
})
t.Run("open changes", func(t *testing.T) {
t.Parallel()
runtime := testruntime.Create(t)
runtime.CreateFile("file", "stashed content")
err := runtime.Run("git", "config", "status.branch", "true")
must.NoError(t, err)
have, err := runtime.Backend.RepoStatus()
must.NoError(t, err)
must.True(t, have.OpenChanges)
})
})
})

t.Run("RebaseInProgress", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions test/datatable/data_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestDataTable(t *testing.T) {
table.AddRow("", "backend", "git remote")
table.AddRow("old", "frontend", "git fetch --prune --tags")
table.AddRow("", "backend", "git branch -vva")
table.AddRow("", "backend", "git status --ignore-submodules")
table.AddRow("", "backend", "git status --long --ignore-submodules")
table.AddRow("", "backend", "git rev-parse --verify --abbrev-ref @{-1}")
table.AddRow("old", "frontend", "git merge --no-edit main")
table.AddRow("", "backend", "git diff main..old")
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestDataTable(t *testing.T) {
| | backend | git remote |
| old | frontend | git fetch --prune --tags |
| | backend | git branch -vva |
| | backend | git status --ignore-submodules |
| | backend | git status --long --ignore-submodules |
| | backend | git rev-parse --verify --abbrev-ref @{-1} |
| old | frontend | git merge --no-edit main |
| | backend | git diff main..old |
Expand Down