Skip to content

Commit

Permalink
🩹 Use hostname (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
stoe authored Mar 19, 2023
1 parent fbef249 commit 5f2f40a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
18 changes: 12 additions & 6 deletions cmd/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ func GetActionsReport(cmd *cobra.Command, args []string) (err error) {
fmt.Println(
utils.Red(
fmt.Sprintf(
"\nerror: parsing https://github.com/%s/blob/HEAD/%s",
"\nerror: parsing https://%s/%s/blob/HEAD/%s",
hostname,
r.NameWithOwner, e.Path,
),
),
Expand All @@ -248,20 +249,23 @@ func GetActionsReport(cmd *cobra.Command, args []string) (err error) {
if len(a) == 2 {
av = a[1]
url = fmt.Sprintf(
"https://github.com/%s/tree/%s",
"https://%s/%s/tree/%s",
hostname,
an,
av,
)
} else {
url = fmt.Sprintf(
"https://github.com/%s/tree/HEAD",
"https://%s/%s/tree/HEAD",
hostname,
an,
)
}

if strings.Contains(url, "./") {
url = fmt.Sprintf(
"https://github.com/%s/%s/tree/HEAD/%s",
"https://%s/%s/%s/tree/HEAD/%s",
hostname,
r.Owner.Login,
r.Name,
strings.ReplaceAll(an, "./", ""),
Expand All @@ -283,7 +287,8 @@ func GetActionsReport(cmd *cobra.Command, args []string) (err error) {
fmt.Println(
utils.Red(
fmt.Sprintf(
"\nerror: parsing https://github.com/%s/blob/HEAD/%s",
"\nerror: parsing https://%s/%s/blob/HEAD/%s",
hostname,
r.NameWithOwner, e.Path,
),
),
Expand All @@ -305,7 +310,8 @@ func GetActionsReport(cmd *cobra.Command, args []string) (err error) {
wfs = append(wfs, ActionWorkflow{
Path: e.Path,
URL: fmt.Sprintf(
"https://github.com/%s/%s/blob/HEAD/%s",
"https://%s/%s/%s/blob/HEAD/%s",
hostname,
r.Owner.Login,
r.Name,
e.Path,
Expand Down
8 changes: 2 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
repo string

token string
hostname = "github.com"
hostname string

csvPath string
jsonPath string
Expand Down Expand Up @@ -129,7 +129,7 @@ func init() {
)

RootCmd.PersistentFlags().StringVarP(&token, "token", "t", "", "GitHub Personal Access Token (default: gh auth token)")
RootCmd.PersistentFlags().StringVar(&hostname, "hostname", "", "GitHub Enterprise Server hostname")
RootCmd.PersistentFlags().StringVar(&hostname, "hostname", "github.com", "GitHub Enterprise Server hostname")

RootCmd.PersistentFlags().StringVar(&csvPath, "csv", "", "Path to CSV file")
RootCmd.PersistentFlags().StringVar(&jsonPath, "json", "", "Path to JSON file")
Expand Down Expand Up @@ -158,10 +158,6 @@ func initConfig() {
opts.AuthToken = t
}

if hostname != "" {
opts.Host = strings.ToLower(hostname)
}

restClient, _ = gh.RESTClient(&opts)
graphqlClient, _ = gh.GQLClient(&opts)
}
Expand Down

0 comments on commit 5f2f40a

Please sign in to comment.