Skip to content

Commit

Permalink
Handle dash in repository name
Browse files Browse the repository at this point in the history
commit-id:d55283ee
  • Loading branch information
ejoffe committed Jun 29, 2021
1 parent 16fc96a commit c63b6fb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .spr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ showPRLink: true
cleanupRemoteBranch: true
logGitCommands: false
logGitHubCalls: false
statusBitsHeader: true
statusBitsHeader: false
10 changes: 10 additions & 0 deletions cmd/spr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ func main() {
rake.YamlFileWriter(configfilepath),
)

if cfg.GitHubRepoOwner == "" {
fmt.Println("unable to auto configure repository owner - must be set manually in .spr.yml")
os.Exit(3)
}

if cfg.GitHubRepoName == "" {
fmt.Println("unable to auto configure repository name - must be set manually in .spr.yml")
os.Exit(4)
}

gitcmd = realgit.NewGitCmd(&cfg)

ctx := context.Background()
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func getRepoDetailsFromRemote(remote string) (string, string, bool) {
userFormat := `(git@)?`
// "/" is expected in "http://" or "ssh://" protocol, when no protocol given
// it should be ":"
repoFormat := `github.com(/|:)(?P<repoOwner>\w+)/(?P<repoName>\w+)`
repoFormat := `github.com(/|:)(?P<repoOwner>\w+)/(?P<repoName>[\w-]+)`
// This is neither required in https access nor in ssh one
suffixFormat := `(.git)?`
regexFormat := fmt.Sprintf(`^origin\s+%s%s%s%s \(push\)`,
Expand Down
3 changes: 3 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func TestGetRepoDetailsFromRemote(t *testing.T) {
{"origin git@github.com:r2/d2.git (push)", "r2", "d2", true},
{"origin git@github.com:r2/d2.git (fetch)", "", "", false},
{"origin git@github.com:r2/d2 (push)", "r2", "d2", true},

{"origin https://github.com/r2/d2-a.git (push)", "r2", "d2-a", true},
{"origin https://github.com/r2/d2_a.git (push)", "r2", "d2_a", true},
}
for i, testCase := range testCases {
t.Logf("Testing %v %q", i, testCase.remote)
Expand Down

0 comments on commit c63b6fb

Please sign in to comment.