-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove GitHubBranch and GitHubOrigin from config - now fetched automa…
…tically using git status fixes #320 commit-id:3f943623
- Loading branch information
Showing
12 changed files
with
99 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,38 @@ | ||
package config_parser | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
|
||
"github.com/ejoffe/spr/config" | ||
"github.com/ejoffe/spr/git" | ||
) | ||
|
||
type remoteBranch struct { | ||
gitcmd git.GitInterface | ||
} | ||
|
||
func NewRemoteBranchSource(gitcmd git.GitInterface) *remoteBranch { | ||
return &remoteBranch{ | ||
gitcmd: gitcmd, | ||
} | ||
} | ||
|
||
var _remoteBranchRegex = regexp.MustCompile(`^## ([a-zA-Z0-9_\-/\.]+)\.\.\.([a-zA-Z0-9_\-/\.]+)/([a-zA-Z0-9_\-/\.]+)`) | ||
|
||
func (s *remoteBranch) Load(cfg interface{}) { | ||
var output string | ||
err := s.gitcmd.Git("status -b --porcelain -u no", &output) | ||
check(err) | ||
|
||
matches := _remoteBranchRegex.FindStringSubmatch(output) | ||
if matches == nil { | ||
fmt.Printf("error: unable to fetch remote branch info, using defaults") | ||
return | ||
} | ||
|
||
internalCfg := cfg.(*config.InternalConfig) | ||
|
||
internalCfg.GitHubRemote = matches[2] | ||
internalCfg.GitHubBranch = matches[3] | ||
} |
This file contains 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 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 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 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 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 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
Oops, something went wrong.