Skip to content

Commit

Permalink
Add an option to fetch tags
Browse files Browse the repository at this point in the history
commit-id:9ca38713
  • Loading branch information
ejoffe committed Apr 22, 2023
1 parent 05c9868 commit 95547e5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type RepoConfig struct {
PRTemplateInsertEnd string `yaml:"prTemplateInsertEnd,omitempty"`

MergeCheck string `yaml:"mergeCheck,omitempty"`

ForceFetchTags bool `default:"false" yaml:"forceFetchTags"`
}

type UserConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion git/mockgit/mockgit.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type responder interface {
}

func (m *Mock) ExpectFetch() {
m.expect("git fetch --tags")
m.expect("git fetch")
m.expect("git branch --no-color").respond("* master")
m.expect("git rebase origin/master --autostash")
}
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ User specific configuration is saved to .spr.yml in the user home directory.
| prTemplatePath | str | | path to PR template (e.g. .github/PULL_REQUEST_TEMPLATE/pull_request_template.md) |
| prTemplateInsertStart | str | | text to search for in PR template that determines body insert start location |
| prTemplateInsertEnd | str | | text to search for in PR template that determines body insert end location |
| mergeCheck | str | | enforce a pre-merge check using 'git spr check' |
| forceFetchTags | bool | false | also fetch tags when running 'git spr update' |


| User Config | Type | Default | Description |
Expand Down
6 changes: 5 additions & 1 deletion spr/spr.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ func commitsReordered(localCommits []git.Commit, pullRequests []*github.PullRequ
}

func (sd *stackediff) fetchAndGetGitHubInfo(ctx context.Context) *github.GitHubInfo {
sd.gitcmd.MustGit("fetch --tags", nil)
if sd.config.Repo.ForceFetchTags {
sd.gitcmd.MustGit("fetch --tags --force", nil)
} else {
sd.gitcmd.MustGit("fetch", nil)
}
targetBranch := git.GetRemoteBranchName(sd.config.Repo, sd.gitcmd)
rebaseCommand := fmt.Sprintf("rebase %s/%s --autostash",
sd.config.Repo.GitHubRemote, targetBranch)
Expand Down

0 comments on commit 95547e5

Please sign in to comment.