-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Auto-forward main branches after fetching #4493
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3577808
Remove double Refresh
stefanhaller 2174762
Inline fetchAux into call site
stefanhaller eaaa937
Add config for auto-forwarding branches after fetching
stefanhaller 7495854
Add a breaking changes hint for the new auto-forward behavior
stefanhaller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package sync | ||
|
|
||
| import ( | ||
| "github.com/jesseduffield/lazygit/pkg/config" | ||
| . "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
| ) | ||
|
|
||
| var FetchAndAutoForwardBranchesAllBranches = NewIntegrationTest(NewIntegrationTestArgs{ | ||
| Description: "Fetch from remote and auto-forward branches with config set to 'allBranches'", | ||
| ExtraCmdArgs: []string{}, | ||
| Skip: false, | ||
| SetupConfig: func(config *config.AppConfig) { | ||
| config.GetUserConfig().Git.AutoForwardBranches = "allBranches" | ||
| }, | ||
| SetupRepo: func(shell *Shell) { | ||
| shell.CreateNCommits(3) | ||
| shell.NewBranch("feature") | ||
| shell.NewBranch("diverged") | ||
| shell.CloneIntoRemote("origin") | ||
| shell.SetBranchUpstream("master", "origin/master") | ||
| shell.SetBranchUpstream("feature", "origin/feature") | ||
| shell.SetBranchUpstream("diverged", "origin/diverged") | ||
| shell.Checkout("master") | ||
| shell.HardReset("HEAD^") | ||
| shell.Checkout("feature") | ||
| shell.HardReset("HEAD~2") | ||
| shell.Checkout("diverged") | ||
| shell.HardReset("HEAD~2") | ||
| shell.EmptyCommit("local") | ||
| shell.NewBranch("checked-out") | ||
| }, | ||
| Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
| t.Views().Branches(). | ||
| Lines( | ||
| Contains("checked-out").IsSelected(), | ||
| Contains("diverged ↓2↑1"), | ||
| Contains("feature ↓2").DoesNotContain("↑"), | ||
| Contains("master ↓1").DoesNotContain("↑"), | ||
| ) | ||
|
|
||
| t.Views().Files(). | ||
| IsFocused(). | ||
| Press(keys.Files.Fetch) | ||
|
|
||
| // AutoForwardBranches is "allBranches": both master and feature get forwarded | ||
| t.Views().Branches(). | ||
| Lines( | ||
| Contains("checked-out").IsSelected(), | ||
| Contains("diverged ↓2↑1"), | ||
| Contains("feature ✓"), | ||
| Contains("master ✓"), | ||
| ) | ||
| }, | ||
| }) |
54 changes: 54 additions & 0 deletions
54
pkg/integration/tests/sync/fetch_and_auto_forward_branches_none.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package sync | ||
|
|
||
| import ( | ||
| "github.com/jesseduffield/lazygit/pkg/config" | ||
| . "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
| ) | ||
|
|
||
| var FetchAndAutoForwardBranchesNone = NewIntegrationTest(NewIntegrationTestArgs{ | ||
| Description: "Fetch from remote and auto-forward branches with config set to 'none'", | ||
| ExtraCmdArgs: []string{}, | ||
| Skip: false, | ||
| SetupConfig: func(config *config.AppConfig) { | ||
| config.GetUserConfig().Git.AutoForwardBranches = "none" | ||
| }, | ||
| SetupRepo: func(shell *Shell) { | ||
| shell.CreateNCommits(3) | ||
| shell.NewBranch("feature") | ||
| shell.NewBranch("diverged") | ||
| shell.CloneIntoRemote("origin") | ||
| shell.SetBranchUpstream("master", "origin/master") | ||
| shell.SetBranchUpstream("feature", "origin/feature") | ||
| shell.SetBranchUpstream("diverged", "origin/diverged") | ||
| shell.Checkout("master") | ||
| shell.HardReset("HEAD^") | ||
| shell.Checkout("feature") | ||
| shell.HardReset("HEAD~2") | ||
| shell.Checkout("diverged") | ||
| shell.HardReset("HEAD~2") | ||
| shell.EmptyCommit("local") | ||
| shell.NewBranch("checked-out") | ||
| }, | ||
| Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
| t.Views().Branches(). | ||
| Lines( | ||
| Contains("checked-out").IsSelected(), | ||
| Contains("diverged ↓2↑1"), | ||
| Contains("feature ↓2").DoesNotContain("↑"), | ||
| Contains("master ↓1").DoesNotContain("↑"), | ||
| ) | ||
|
|
||
| t.Views().Files(). | ||
| IsFocused(). | ||
| Press(keys.Files.Fetch) | ||
|
|
||
| // AutoForwardBranches is "none": nothing should happen | ||
| t.Views().Branches(). | ||
| Lines( | ||
| Contains("checked-out").IsSelected(), | ||
| Contains("diverged ↓2↑1"), | ||
| Contains("feature ↓2").DoesNotContain("↑"), | ||
| Contains("master ↓1").DoesNotContain("↑"), | ||
| ) | ||
| }, | ||
| }) |
54 changes: 54 additions & 0 deletions
54
pkg/integration/tests/sync/fetch_and_auto_forward_branches_only_main_branches.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package sync | ||
|
|
||
| import ( | ||
| "github.com/jesseduffield/lazygit/pkg/config" | ||
| . "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
| ) | ||
|
|
||
| var FetchAndAutoForwardBranchesOnlyMainBranches = NewIntegrationTest(NewIntegrationTestArgs{ | ||
| Description: "Fetch from remote and auto-forward branches with config set to 'onlyMainBranches'", | ||
| ExtraCmdArgs: []string{}, | ||
| Skip: false, | ||
| SetupConfig: func(config *config.AppConfig) { | ||
| config.GetUserConfig().Git.AutoForwardBranches = "onlyMainBranches" | ||
| }, | ||
| SetupRepo: func(shell *Shell) { | ||
| shell.CreateNCommits(3) | ||
| shell.NewBranch("feature") | ||
| shell.NewBranch("diverged") | ||
| shell.CloneIntoRemote("origin") | ||
| shell.SetBranchUpstream("master", "origin/master") | ||
| shell.SetBranchUpstream("feature", "origin/feature") | ||
| shell.SetBranchUpstream("diverged", "origin/diverged") | ||
| shell.Checkout("master") | ||
| shell.HardReset("HEAD^") | ||
| shell.Checkout("feature") | ||
| shell.HardReset("HEAD~2") | ||
| shell.Checkout("diverged") | ||
| shell.HardReset("HEAD~2") | ||
| shell.EmptyCommit("local") | ||
| shell.NewBranch("checked-out") | ||
| }, | ||
| Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
| t.Views().Branches(). | ||
| Lines( | ||
| Contains("checked-out").IsSelected(), | ||
| Contains("diverged ↓2↑1"), | ||
| Contains("feature ↓2").DoesNotContain("↑"), | ||
| Contains("master ↓1").DoesNotContain("↑"), | ||
| ) | ||
|
|
||
| t.Views().Files(). | ||
| IsFocused(). | ||
| Press(keys.Files.Fetch) | ||
|
|
||
| // AutoForwardBranches is "onlyMainBranches": master gets forwarded, but feature doesn't | ||
| t.Views().Branches(). | ||
| Lines( | ||
| Contains("checked-out").IsSelected(), | ||
| Contains("diverged ↓2↑1"), | ||
| Contains("feature ↓2").DoesNotContain("↑"), | ||
| Contains("master ✓"), | ||
| ) | ||
| }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a use case for auto-forwarding all branches: if you also don't have a use case for it I would just not support it to keep the code simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use case is that you collaborate on some branches with a coworker, they push some new commits, and you get them auto-forwarded so that you have those commits right available when you check out the branch again. Saves one pull after checkout. I find this useful and will probably turn it on myself. (The downside is that you don't see that new commits were pushed, so that you can inspect them using "View divergence from upstream").