@@ -24,9 +24,9 @@ func GetLocalBranchName(gitcmd GitInterface) string {
24
24
panic ("cannot determine local git branch name" )
25
25
}
26
26
27
- func BranchNameFromCommit (repoConfig * config.RepoConfig , gitcmd GitInterface , commit Commit ) string {
28
- if repoConfig .BranchNameIncludeTarget {
29
- remoteBranchName := GetRemoteBranchName ( repoConfig , gitcmd )
27
+ func BranchNameFromCommit (cfg * config.Config , gitcmd GitInterface , commit Commit ) string {
28
+ if cfg . Repo .BranchNameIncludeTarget {
29
+ remoteBranchName := cfg . Internal . GitHubBranch
30
30
return "spr/" + remoteBranchName + "/" + commit .CommitID
31
31
}
32
32
@@ -44,23 +44,11 @@ func BranchNameRegex(repoConfig *config.RepoConfig) *regexp.Regexp {
44
44
return _branchNameRegex
45
45
}
46
46
47
- // GetRemoteBranchName
48
- func GetRemoteBranchName (repoConfig * config.RepoConfig , gitcmd GitInterface ) string {
49
- localBranchName := GetLocalBranchName (gitcmd )
50
-
51
- for _ , remoteBranchName := range repoConfig .RemoteBranches {
52
- if localBranchName == remoteBranchName {
53
- return remoteBranchName
54
- }
55
- }
56
- return repoConfig .GitHubBranch
57
- }
58
-
59
47
// GetLocalTopCommit returns the top unmerged commit in the stack
60
48
//
61
49
// return nil if there are no unmerged commits in the stack
62
- func GetLocalTopCommit (repoConfig * config.RepoConfig , gitcmd GitInterface ) * Commit {
63
- commits := GetLocalCommitStack (repoConfig , gitcmd )
50
+ func GetLocalTopCommit (cfg * config.Config , gitcmd GitInterface ) * Commit {
51
+ commits := GetLocalCommitStack (cfg , gitcmd )
64
52
if len (commits ) == 0 {
65
53
return nil
66
54
}
@@ -70,19 +58,18 @@ func GetLocalTopCommit(repoConfig *config.RepoConfig, gitcmd GitInterface) *Comm
70
58
// GetLocalCommitStack returns a list of unmerged commits
71
59
//
72
60
// the list is ordered with the bottom commit in the stack first
73
- func GetLocalCommitStack (repoConfig * config.RepoConfig , gitcmd GitInterface ) []Commit {
61
+ func GetLocalCommitStack (cfg * config.Config , gitcmd GitInterface ) []Commit {
74
62
var commitLog string
75
- targetBranch := GetRemoteBranchName (repoConfig , gitcmd )
76
63
logCommand := fmt .Sprintf ("log --format=medium --no-color %s/%s..HEAD" ,
77
- repoConfig . GitHubRemote , targetBranch )
64
+ cfg . Internal . GitHubRemote , cfg . Internal . GitHubBranch )
78
65
gitcmd .MustGit (logCommand , & commitLog )
79
66
commits , valid := parseLocalCommitStack (commitLog )
80
67
if ! valid {
81
68
// if not valid - run rebase to add commit ids
82
69
rewordPath , err := exec .LookPath ("spr_reword_helper" )
83
70
check (err )
84
71
rebaseCommand := fmt .Sprintf ("rebase %s/%s -i --autosquash --autostash" ,
85
- repoConfig . GitHubRemote , targetBranch )
72
+ cfg . Internal . GitHubRemote , cfg . Internal . GitHubBranch )
86
73
gitcmd .GitWithEditor (rebaseCommand , nil , rewordPath )
87
74
88
75
gitcmd .MustGit (logCommand , & commitLog )
0 commit comments