Merge pull request #18 from ttran112/trunk

fix minor error and add branchName for addArgs, addCombine
This commit is contained in:
Thanh D Tran 2021-05-26 19:29:14 -07:00 committed by GitHub
commit 43a9709e4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,6 +114,11 @@ func openInBrowser(cmd *cobra.Command, opts *BrowseOptions) {
response, repoUrl = addCombined(opts, repoUrl, branchName)
}
if response != exitSuccess {
printExit(response, cmd, opts, repoUrl) // print success
return
}
response = getHttpResponse(opts, repoUrl)
if response == exitSuccess { // test the connection to see if the url is valid
opts.Browser.Browse(repoUrl) // otherwise open repo
@ -138,11 +143,6 @@ func addCombined(opts *BrowseOptions, url string, branchName string) (exitCode,
}
return exitError, ""
// if isNumber(opts.AdditionalArg) && opts.LineFlag { // if second arg is a number it should be a line number
// return "/" + opts.SelectorArg + "#L" + opts.AdditionalArg
// }
// return "/tree/" + opts.AdditionalArg + "/" + opts.SelectorArg
// }
}
func addFlags(opts *BrowseOptions, url string) (exitCode, string) {
@ -157,6 +157,12 @@ func addFlags(opts *BrowseOptions, url string) (exitCode, string) {
}
func addArgs(opts *BrowseOptions, url string, branchName string) (exitCode, string) {
if opts.AdditionalArg != "" {
// fmt.Println("test secodn argument")
return exitError, ""
}
if isNumber(opts.SelectorArg) {
return exitSuccess, url + "/issues/" + opts.SelectorArg
}