Skip to content

Commit

Permalink
Fail if current repository is not a GitHub repo 馃懏
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokosi committed Mar 3, 2022
1 parent 2b2cdc4 commit d6f96de
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"os"
"strings"

"github.com/cli/go-gh"
Expand Down Expand Up @@ -36,7 +37,11 @@ type collaborator struct {

func main() {
config := parseFlags()
repoWithOrg := getRepo(config)
repoWithOrg, error := getRepo(config)
if error != nil {
fmt.Print(error)
os.Exit(1)
}

repoMessage, repo, validRepo := scanRepo(config, repoWithOrg)
if validRepo {
Expand All @@ -51,15 +56,18 @@ func main() {
}
}

func getRepo(config config) string {
func getRepo(config config) (string, error) {
if len(config.repo) > 1 {
return config.repo
return config.repo, nil
}
if config.verbose {
fmt.Printf("(current repo)\n")
}
currentRepo, _ := gh.CurrentRepository()
return currentRepo.Owner() + "/" + currentRepo.Name()
currentRepo, error := gh.CurrentRepository()
if error != nil {
return "", error
}
return currentRepo.Owner() + "/" + currentRepo.Name(), nil
}

func scanRepo(config config, repoWithOrg string) (message string, repository repo, validRepo bool) {
Expand Down

0 comments on commit d6f96de

Please sign in to comment.