Format code with Go fmt

This commit is contained in:
deepsource-autofix[bot] 2020-08-09 10:01:54 +00:00 committed by GitHub
parent 0c56135072
commit 557e209ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 148 additions and 150 deletions

View File

@ -11,4 +11,4 @@ func main() {
fmt.Println(err)
os.Exit(1)
}
}
}

View File

@ -27,7 +27,7 @@ func displayAllIssues(m []*gitlab.Issue) {
for _, issue := range m {
var labels string
for _, l := range issue.Labels {
labels+=" "+l+","
labels += " " + l + ","
}
labels = strings.Trim(labels, ", ")
duration := manip.TimeAgo(*issue.CreatedAt)
@ -58,7 +58,7 @@ var issueCmd = &cobra.Command{
Short: `Create, view and manage remote issues`,
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
if len(args)==0 || len(args) > 2 {
if len(args) == 0 || len(args) > 2 {
cmd.Help()
return
}

View File

@ -49,4 +49,4 @@ var issueCloseCmd = &cobra.Command{
func init() {
issueCmd.AddCommand(issueCloseCmd)
}
}

View File

@ -11,9 +11,9 @@ import (
)
var issueCreateCmd = &cobra.Command{
Use: "create [flags]",
Short: `Create an issue`,
Long: ``,
Use: "create [flags]",
Short: `Create an issue`,
Long: ``,
Aliases: []string{"new"},
Run: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
@ -28,7 +28,7 @@ var issueCreateCmd = &cobra.Command{
if title, _ := cmd.Flags().GetString("title"); title != "" {
issueTitle = strings.Trim(title, " ")
} else {
issueTitle = manip.AskQuestionWithInput("Title","", true)
issueTitle = manip.AskQuestionWithInput("Title", "", true)
}
if label, _ := cmd.Flags().GetString("label"); label != "" {
issueLabel = strings.Trim(label, "[] ")
@ -86,4 +86,4 @@ func init() {
issueCreateCmd.Flags().BoolP("allow-collaboration", "", false, "Allow collaboration")
issueCreateCmd.Flags().BoolP("remove-source-branch", "", false, "Remove Source Branch after merge")
issueCmd.AddCommand(issueCreateCmd)
}
}

View File

@ -42,4 +42,4 @@ var issueDeleteCmd = &cobra.Command{
func init() {
issueCmd.AddCommand(issueDeleteCmd)
}
}

View File

@ -15,9 +15,9 @@ var issueListCmd = &cobra.Command{
Args: cobra.MaximumNArgs(3),
Run: func(cmd *cobra.Command, args []string) {
var state string
if lb, _ := cmd.Flags().GetBool("all"); lb {
if lb, _ := cmd.Flags().GetBool("all"); lb {
state = "all"
} else if lb, _ := cmd.Flags().GetBool("closed"); lb {
} else if lb, _ := cmd.Flags().GetBool("closed"); lb {
state = "closed"
} else {
state = "opened"
@ -26,16 +26,16 @@ var issueListCmd = &cobra.Command{
l := &gitlab.ListProjectIssuesOptions{
State: gitlab.String(state),
}
if lb, _ := cmd.Flags().GetString("label"); lb != "" {
if lb, _ := cmd.Flags().GetString("label"); lb != "" {
label := gitlab.Labels{
lb,
}
l.Labels = label
}
if lb, _ := cmd.Flags().GetString("milestone"); lb != "" {
if lb, _ := cmd.Flags().GetString("milestone"); lb != "" {
l.Milestone = gitlab.String(lb)
}
if lb, _ := cmd.Flags().GetBool("confidential"); lb {
if lb, _ := cmd.Flags().GetBool("confidential"); lb {
l.Confidential = gitlab.Bool(lb)
}

View File

@ -49,4 +49,4 @@ var issueReopenCmd = &cobra.Command{
func init() {
issueCmd.AddCommand(issueReopenCmd)
}
}

View File

@ -32,7 +32,7 @@ var issueSubscribeCmd = &cobra.Command{
} else if resp.StatusCode == 404 {
er("Issue does not exist")
} else {
er("Could not complete request; "+ resp.Status)
er("Could not complete request; " + resp.Status)
}
}
} else {
@ -43,4 +43,4 @@ var issueSubscribeCmd = &cobra.Command{
func init() {
issueCmd.AddCommand(issueSubscribeCmd)
}
}

View File

@ -43,4 +43,4 @@ var issueUnsubscribeCmd = &cobra.Command{
func init() {
issueCmd.AddCommand(issueUnsubscribeCmd)
}
}

View File

@ -17,4 +17,4 @@ var labelCmd = &cobra.Command{
func init() {
RootCmd.AddCommand(labelCmd)
}
}

View File

@ -7,17 +7,16 @@ import (
"glab/internal/git"
)
var labelCreateCmd = &cobra.Command{
Use: "create <id> [flags]",
Short: `Create labels for repository/project`,
Long: ``,
Use: "create <id> [flags]",
Short: `Create labels for repository/project`,
Long: ``,
Aliases: []string{"new"},
Args: cobra.MaximumNArgs(1),
Run: createLabel,
Run: createLabel,
}
func createLabel (cmd *cobra.Command, args []string) {
func createLabel(cmd *cobra.Command, args []string) {
gitlabClient, repo := git.InitGitlabClient()
l := &gitlab.CreateLabelOptions{}
@ -51,4 +50,4 @@ func init() {
labelCreateCmd.Flags().StringP("color", "c", "#428BCA", "Color of label in plain or HEX code. (Default: #428BCA)")
labelCreateCmd.Flags().StringP("description", "d", "", "Label description")
labelCmd.AddCommand(labelCreateCmd)
}
}

View File

@ -9,12 +9,12 @@ import (
)
var labelListCmd = &cobra.Command{
Use: "list <id> [flags]",
Short: `List labels in repository`,
Long: ``,
Use: "list <id> [flags]",
Short: `List labels in repository`,
Long: ``,
Aliases: []string{"ls"},
Args: cobra.MaximumNArgs(1),
Run: listLabels,
Run: listLabels,
}
func listLabels(cmd *cobra.Command, args []string) {
@ -27,10 +27,10 @@ func listLabels(cmd *cobra.Command, args []string) {
fmt.Printf("Showing label %d of %d on %s", len(labels), len(labels), repo)
fmt.Println()
for _, label := range labels {
color.HEX(strings.Trim(label.Color, "#")).Printf("#%d %s\n",label.ID, label.Name)
color.HEX(strings.Trim(label.Color, "#")).Printf("#%d %s\n", label.ID, label.Name)
}
}
func init() {
labelCmd.AddCommand(labelListCmd)
}
}

View File

@ -61,4 +61,4 @@ var mrCmd = &cobra.Command{
func init() {
RootCmd.AddCommand(mrCmd)
}
}

View File

@ -12,12 +12,12 @@ import (
)
var mrApproveCmd = &cobra.Command{
Use: "approve <id> [flags]",
Short: `Approve merge requests`,
Long: ``,
Use: "approve <id> [flags]",
Short: `Approve merge requests`,
Long: ``,
Aliases: []string{"ls"},
Args: cobra.MaximumNArgs(1),
Run: approveMergeRequest,
Run: approveMergeRequest,
}
func approveMergeRequest(cmd *cobra.Command, args []string) {
@ -56,4 +56,4 @@ func init() {
mrApproveCmd.Flags().StringP("sha", "s", "", "The HEAD of the merge request")
//mrApproveCmd.Flags().StringP("password", "p", "", "Current users password. Required if 'Require user password to approve' is enabled in the project settings.")
mrCmd.AddCommand(mrApproveCmd)
}
}

View File

@ -16,4 +16,4 @@ var mrBrowseCmd = &cobra.Command{
func init() {
mrCmd.AddCommand(mrBrowseCmd)
}
}

View File

@ -11,12 +11,12 @@ import (
)
var mrCloseCmd = &cobra.Command{
Use: "close <id>",
Short: `Close merge requests`,
Long: ``,
Use: "close <id>",
Short: `Close merge requests`,
Long: ``,
Aliases: []string{"ls"},
Args: cobra.MaximumNArgs(1),
Run: closeMergeRequestState,
Run: closeMergeRequestState,
}
func closeMergeRequestState(cmd *cobra.Command, args []string) {
@ -45,4 +45,4 @@ func closeMergeRequestState(cmd *cobra.Command, args []string) {
func init() {
mrCmd.AddCommand(mrCloseCmd)
}
}

View File

@ -11,9 +11,9 @@ import (
)
var mrCreateCmd = &cobra.Command{
Use: "create",
Short: `Create new merge request`,
Long: ``,
Use: "create",
Short: `Create new merge request`,
Long: ``,
Aliases: []string{"new"},
Run: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
@ -119,4 +119,4 @@ func init() {
mrCreateCmd.Flags().BoolP("allow-collaboration", "", false, "Allow commits from other members")
mrCreateCmd.Flags().BoolP("remove-source-branch", "", false, "Remove Source Branch on merge")
mrCmd.AddCommand(mrCreateCmd)
}
}

View File

@ -11,13 +11,13 @@ import (
)
var mrDeleteCmd = &cobra.Command{
Use: "delete <id>",
Short: `Delete merge requests`,
Long: ``,
Use: "delete <id>",
Short: `Delete merge requests`,
Long: ``,
Aliases: []string{"del"},
Args: cobra.MaximumNArgs(1),
Example: "$ glab delete 123",
RunE: deleteMergeRequest,
RunE: deleteMergeRequest,
}
func deleteMergeRequest(cmd *cobra.Command, args []string) error {

View File

@ -10,13 +10,13 @@ import (
)
var mrIssuesCmd = &cobra.Command{
Use: "issues <id>",
Short: `Get issues related to a particular merge request.`,
Long: ``,
Use: "issues <id>",
Short: `Get issues related to a particular merge request.`,
Long: ``,
Aliases: []string{"issue"},
Args: cobra.MaximumNArgs(1),
Example: "$ glab mr issues 46",
Run: issuesRelatedMergeRequest,
Run: issuesRelatedMergeRequest,
}
func issuesRelatedMergeRequest(cmd *cobra.Command, args []string) {
@ -36,4 +36,4 @@ func issuesRelatedMergeRequest(cmd *cobra.Command, args []string) {
func init() {
mrCmd.AddCommand(mrIssuesCmd)
}
}

View File

@ -7,21 +7,21 @@ import (
)
var mrListCmd = &cobra.Command{
Use: "list [flags]",
Short: `List merge requests`,
Long: ``,
Use: "list [flags]",
Short: `List merge requests`,
Long: ``,
Aliases: []string{"ls"},
Args: cobra.MaximumNArgs(3),
RunE: listMergeRequest,
RunE: listMergeRequest,
}
func listMergeRequest(cmd *cobra.Command, args []string) error {
var state string
if lb, _ := cmd.Flags().GetBool("all"); lb {
if lb, _ := cmd.Flags().GetBool("all"); lb {
state = "all"
} else if lb, _ := cmd.Flags().GetBool("closed"); lb {
} else if lb, _ := cmd.Flags().GetBool("closed"); lb {
state = "closed"
} else if lb, _ := cmd.Flags().GetBool("merged"); lb {
} else if lb, _ := cmd.Flags().GetBool("merged"); lb {
state = "merged"
} else {
state = "opened"
@ -36,7 +36,7 @@ func listMergeRequest(cmd *cobra.Command, args []string) error {
}
l.Labels = &label
}
if lb, _ := cmd.Flags().GetString("milestone"); lb != "" {
if lb, _ := cmd.Flags().GetString("milestone"); lb != "" {
l.Milestone = gitlab.String(lb)
}

View File

@ -13,11 +13,11 @@ import (
)
var mrMergeCmd = &cobra.Command{
Use: "merge <id> [flags]",
Short: `Merge/Accept merge requests`,
Long: ``,
Use: "merge <id> [flags]",
Short: `Merge/Accept merge requests`,
Long: ``,
Aliases: []string{"accept"},
Run: acceptMergeRequest,
Run: acceptMergeRequest,
}
func acceptMergeRequest(cmd *cobra.Command, args []string) {
@ -68,4 +68,4 @@ func init() {
mrMergeCmd.Flags().StringP("squash-message", "", "", "Squash commit message")
mrMergeCmd.Flags().BoolP("squash", "s", false, "Squash commits on merge")
mrCmd.AddCommand(mrMergeCmd)
}
}

View File

@ -11,12 +11,12 @@ import (
)
var mrReopenCmd = &cobra.Command{
Use: "reopen <id>",
Short: `Reopen merge requests`,
Long: ``,
Use: "reopen <id>",
Short: `Reopen merge requests`,
Long: ``,
Aliases: []string{"open"},
Args: cobra.MaximumNArgs(1),
Run: reopenMergeRequestState,
Run: reopenMergeRequestState,
}
func reopenMergeRequestState(cmd *cobra.Command, args []string) {
@ -35,7 +35,7 @@ func reopenMergeRequestState(cmd *cobra.Command, args []string) {
} else if resp.StatusCode == 404 {
er("MergeRequest does not exist")
} else {
er("Could not complete request: "+resp.Status)
er("Could not complete request: " + resp.Status)
}
}
} else {
@ -45,4 +45,4 @@ func reopenMergeRequestState(cmd *cobra.Command, args []string) {
func init() {
mrCmd.AddCommand(mrReopenCmd)
}
}

View File

@ -12,11 +12,11 @@ import (
)
var mrRevokeCmd = &cobra.Command{
Use: "revoke <id>",
Short: `Revoke approval on a merge request <id>`,
Long: ``,
Use: "revoke <id>",
Short: `Revoke approval on a merge request <id>`,
Long: ``,
Aliases: []string{"unapprove"},
Run: revokeMergeRequest,
Run: revokeMergeRequest,
}
func revokeMergeRequest(cmd *cobra.Command, args []string) {

View File

@ -12,11 +12,11 @@ import (
)
var mrSubscribeCmd = &cobra.Command{
Use: "subscribe <id>",
Short: `Subscribe to merge requests`,
Long: ``,
Use: "subscribe <id>",
Short: `Subscribe to merge requests`,
Long: ``,
Aliases: []string{"sub"},
Run: subscribeSubscribeRequest,
Run: subscribeSubscribeRequest,
}
func subscribeSubscribeRequest(cmd *cobra.Command, args []string) {
@ -36,7 +36,7 @@ func subscribeSubscribeRequest(cmd *cobra.Command, args []string) {
} else if resp.StatusCode == 404 {
er("Merge Request does not exist")
} else {
er("Could not complete request."+resp.Status)
er("Could not complete request." + resp.Status)
}
}
} else {
@ -46,4 +46,4 @@ func subscribeSubscribeRequest(cmd *cobra.Command, args []string) {
func init() {
mrCmd.AddCommand(mrSubscribeCmd)
}
}

View File

@ -12,11 +12,11 @@ import (
)
var mrUnsubscribeCmd = &cobra.Command{
Use: "unsubscribe <id>",
Short: `Unsubscribe to merge requests`,
Long: ``,
Use: "unsubscribe <id>",
Short: `Unsubscribe to merge requests`,
Long: ``,
Aliases: []string{"unsub"},
Run: unsubscribeMergeRequest,
Run: unsubscribeMergeRequest,
}
func unsubscribeMergeRequest(cmd *cobra.Command, args []string) {
@ -46,4 +46,4 @@ func unsubscribeMergeRequest(cmd *cobra.Command, args []string) {
func init() {
mrCmd.AddCommand(mrUnsubscribeCmd)
}
}

View File

@ -12,13 +12,13 @@ var mrUpdateCmd = &cobra.Command{
Use: "update <id>",
Short: `Update merge requests`,
Long: ``,
Run: updateMergeRequest,
Run: updateMergeRequest,
}
func updateMergeRequest(cmd *cobra.Command, args []string) {
mergeID := strings.Trim(args[0], " ")
l := &gitlab.UpdateMergeRequestOptions{}
if m, _ := cmd.Flags().GetString("title"); m != ""{
if m, _ := cmd.Flags().GetString("title"); m != "" {
l.Title = gitlab.String(m)
}
if m, _ := cmd.Flags().GetBool("lock-discussion"); m {
@ -35,9 +35,9 @@ func updateMergeRequest(cmd *cobra.Command, args []string) {
displayMergeRequest(mr)
}
func init() {
func init() {
mrUpdateCmd.Flags().StringP("title", "t", "", "Title of merge request")
mrUpdateCmd.Flags().BoolP("lock-discussion", "", false, "Lock discussion on merge request")
mrUpdateCmd.Flags().StringP("description", "d", "", "merge request description")
mrCmd.AddCommand(mrUpdateCmd)
}
}

View File

@ -42,9 +42,9 @@ func displayMultiplePipelines(m []*gitlab.PipelineInfo) {
// pipelineCmd is merge request command
var pipelineCmd = &cobra.Command{
Use: "pipeline <command> [flags]",
Short: `Manage pipelines`,
Long: ``,
Use: "pipeline <command> [flags]",
Short: `Manage pipelines`,
Long: ``,
Aliases: []string{"pipe"},
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 || len(args) > 2 {

View File

@ -17,8 +17,8 @@ var pipelineDeleteCmd = &cobra.Command{
$ glab pipeline delete 34
$ glab pipeline delete 12,34,2
`),
Long: ``,
Run: deletePipeline,
Long: ``,
Run: deletePipeline,
}
func deletePipeline(cmd *cobra.Command, args []string) {
@ -34,7 +34,7 @@ func deletePipeline(cmd *cobra.Command, args []string) {
} else if pipeline.StatusCode == 404 {
er("Pipeline does not exist")
} else {
er("Could not complete request." +pipeline.Status)
er("Could not complete request." + pipeline.Status)
}
}
fmt.Println()
@ -43,6 +43,6 @@ func deletePipeline(cmd *cobra.Command, args []string) {
}
}
func init() {
func init() {
pipelineCmd.AddCommand(pipelineDeleteCmd)
}
}

View File

@ -14,9 +14,10 @@ var pipelineListCmd = &cobra.Command{
$ glab pipeline list
$ glab pipeline list --state=failed
`),
Long: ``,
Run: listPipelines,
Long: ``,
Run: listPipelines,
}
func listPipelines(cmd *cobra.Command, args []string) {
gitlabClient, repo := git.InitGitlabClient()
l := &gitlab.ListProjectPipelinesOptions{}
@ -42,4 +43,4 @@ func init() {
pipelineListCmd.Flags().StringP("orderBy", "o", "", "Order pipeline by <string>")
pipelineListCmd.Flags().StringP("sort", "", "desc", "Sort pipeline by {asc|desc}. (Defaults to desc)")
pipelineCmd.AddCommand(pipelineListCmd)
}
}

View File

@ -12,15 +12,16 @@ import (
"github.com/spf13/cobra"
"glab/internal/config"
)
// Version is set at build
var Version string
var build string
var commit string
var RootCmd = &cobra.Command{
Use: "glab <command> <subcommand> [flags]",
Short: "A GitLab CLI Tool",
Long: `GLab is an open source Gitlab Cli tool bringing GitLab to your command line`,
Use: "glab <command> <subcommand> [flags]",
Short: "A GitLab CLI Tool",
Long: `GLab is an open source Gitlab Cli tool bringing GitLab to your command line`,
SilenceErrors: true,
SilenceUsage: true,
Example: heredoc.Doc(`
@ -65,7 +66,6 @@ var RootCmd = &cobra.Command{
},
}
// Execute executes the root command.
func Execute() error {
return RootCmd.Execute()
@ -73,9 +73,9 @@ func Execute() error {
// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "show glab version information",
Long: ``,
Use: "version",
Short: "show glab version information",
Long: ``,
Aliases: []string{"v"},
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("glab version %s (%s)\n%s\n%s\n", Version, build, commit, changelogURL(Version))
@ -85,11 +85,11 @@ var versionCmd = &cobra.Command{
// versionCmd represents the version command
var updateCmd = &cobra.Command{
Use: "check-update",
Short: "Check for latest glab releases",
Long: ``,
Aliases: []string{"update",""},
Run: checkForUpdate,
Use: "check-update",
Short: "Check for latest glab releases",
Long: ``,
Aliases: []string{"update", ""},
Run: checkForUpdate,
}
var configCmd = &cobra.Command{
@ -97,7 +97,7 @@ var configCmd = &cobra.Command{
Short: `Configuration`,
Long: ``,
Aliases: []string{"conf"},
Args: cobra.MaximumNArgs(2),
Args: cobra.MaximumNArgs(2),
Run: config.Set,
}
@ -130,7 +130,7 @@ func initConfig() {
config.UseGlobalConfig = false
}
func initConfigCmd() {
func initConfigCmd() {
configCmd.Flags().BoolP("global", "g", false, "Set configuration globally")
configCmd.Flags().StringP("url", "u", "", "specify the url of the gitlab server if self hosted (eg: https://gitlab.example.com).")
configCmd.Flags().StringP("remote-var", "o", "", "delete merge request <id>")
@ -168,4 +168,4 @@ func checkForUpdate(*cobra.Command, []string) {
color.Printf("<yellow>A new version of glab has been released:</> <red>%s</> → <green>%s</>\n", Version, latestVersion)
fmt.Println(releaseInfo.HTMLUrl)
}
}
}

View File

@ -34,7 +34,6 @@ func SetGlobalPathDir() string {
return globalPathDir
}
// GetEnv : returns env variable value
func GetEnv(key string) string {
if key != "" {
@ -99,7 +98,6 @@ func SetEnv(key, value string) {
}
}
func GetRepo() string {
gitRemoteVar, err := gitconfig.Entire("remote." + GetEnv("GIT_REMOTE_URL_VAR") + ".url")
if err != nil {
@ -116,7 +114,7 @@ func GetRepo() string {
return strings.Trim(repo, "/")
}
func readAndSetEnv(question, env string) string {
func readAndSetEnv(question, env string) string {
envDefVal := GetEnv(env)
envVal := manip.AskQuestionWithInput(question, envDefVal, false)
SetEnv(env, envVal)
@ -125,22 +123,22 @@ func readAndSetEnv(question, env string) string {
func Set(cmd *cobra.Command, args []string) {
var isUpdated bool
if b, _ := cmd.Flags().GetBool("global"); b {
if b, _ := cmd.Flags().GetBool("global"); b {
UseGlobalConfig = true
}
if b, _ := cmd.Flags().GetString("token"); b != "" {
if b, _ := cmd.Flags().GetString("token"); b != "" {
SetEnv("GITLAB_TOKEN", b)
isUpdated = true
}
if b, _ := cmd.Flags().GetString("url"); b != "" {
if b, _ := cmd.Flags().GetString("url"); b != "" {
SetEnv("GITLAB_URI", b)
isUpdated = true
}
if b, _ := cmd.Flags().GetString("remote-var"); b != "" {
if b, _ := cmd.Flags().GetString("remote-var"); b != "" {
SetEnv("GIT_REMOTE_URL_VAR", b)
isUpdated = true
}
if b, _ := cmd.Flags().GetString("pid"); b != "" {
if b, _ := cmd.Flags().GetString("pid"); b != "" {
SetEnv("GITLAB_PROJECT_ID", b)
isUpdated = true
}
@ -153,4 +151,4 @@ func Set(cmd *cobra.Command, args []string) {
if isUpdated {
fmt.Println(aurora.Green("Environment variable(s) updated"))
}
}
}

View File

@ -31,7 +31,7 @@ func GetRepo() string {
}
// getRepoNameWithNamespace returns the the repo with its namespace (like profclems/glab). Respects group and subgroups names
func getRepoNameWithNamespace(remoteURL string) (string, error) {
func getRepoNameWithNamespace(remoteURL string) (string, error) {
parts := strings.Split(remoteURL, "//")
if len(parts) == 1 {
@ -43,11 +43,11 @@ func getRepoNameWithNamespace(remoteURL string) (string, error) {
part := parts[1]
parts = strings.SplitN(part, "/", 2)
} else {
return "", errors.New("cannot parse remote: " + config.GetEnv("GIT_REMOTE_URL_VAR") + " url: "+ remoteURL)
return "", errors.New("cannot parse remote: " + config.GetEnv("GIT_REMOTE_URL_VAR") + " url: " + remoteURL)
}
if len(parts) != 2 {
return "", errors.New("cannot parse remote: " + config.GetEnv("GIT_REMOTE_URL_VAR") + " url: "+ remoteURL)
return "", errors.New("cannot parse remote: " + config.GetEnv("GIT_REMOTE_URL_VAR") + " url: " + remoteURL)
}
repo := parts[1]
repo = strings.TrimSuffix(repo, ".git")
@ -345,7 +345,7 @@ func firstLine(output []byte) string {
return string(output)
}
func RunCmd(args...string) {
func RunCmd(args ...string) {
showRef := exec.Command("git", args...)
output, err := run.PrepareCmd(showRef).Output()
if err != nil {
@ -353,4 +353,4 @@ func RunCmd(args...string) {
return
}
fmt.Println(output)
}
}

View File

@ -41,4 +41,4 @@ func ParseURL(rawURL string) (u *url.URL, err error) {
}
return
}
}

View File

@ -18,9 +18,9 @@ import (
func VariableExists(key string, global bool) string {
return GetKeyValueInFile(config.ConfigFile, key)
}
*/
*/
func AskQuestionWithSelect(question, defaultVal string, isRequired bool) {
func AskQuestionWithSelect(question, defaultVal string, isRequired bool) {
color := ""
prompt := &survey.Select{
Message: "Choose a color:",
@ -29,13 +29,13 @@ func AskQuestionWithSelect(question, defaultVal string, isRequired bool) {
survey.AskOne(prompt, &color)
}
func AskQuestionWithInput(question, defaultVal string, isRequired bool) string {
func AskQuestionWithInput(question, defaultVal string, isRequired bool) string {
str := ""
prompt := &survey.Input{
Message: question,
}
if isRequired {
_ = survey.AskOne(prompt, &str, survey.WithValidator(survey.Required))
_ = survey.AskOne(prompt, &str, survey.WithValidator(survey.Required))
} else {
_ = survey.AskOne(prompt, &str)
}
@ -46,7 +46,7 @@ func AskQuestionWithInput(question, defaultVal string, isRequired bool) string
return str
}
func AskQuestionMultiline(question string, defaultVal string) string {
func AskQuestionMultiline(question string, defaultVal string) string {
str := ""
prompt := &survey.Multiline{
Message: question,
@ -80,7 +80,7 @@ func ReplaceNonAlphaNumericChars(words, replaceWith string) string {
if err != nil {
log.Fatal(err)
}
newStr := reg.ReplaceAllString(strings.Trim(words," "), replaceWith)
newStr := reg.ReplaceAllString(strings.Trim(words, " "), replaceWith)
return newStr
}
@ -137,7 +137,7 @@ func TruncateStrings(s string, n int) string {
for !utf8.ValidString(s[:n]) {
n--
}
return s[:n]+"..."
return s[:n] + "..."
}
// TimeAgo is ...

View File

@ -79,4 +79,4 @@ func (e CmdError) Error() string {
msg += "\n"
}
return fmt.Sprintf("%s%s: %s", msg, e.Args[0], e.Err)
}
}

View File

@ -7,20 +7,20 @@ import (
)
type ReleaseInfo struct {
Name string`json:"name"`
PreRelease bool `json:"prerelease"`
HTMLUrl string `json:"html_url"`
Name string `json:"name"`
PreRelease bool `json:"prerelease"`
HTMLUrl string `json:"html_url"`
PublishedAt time.Time `json:"published_at"`
}
// CheckForUpdate checks for latest release
func CheckForUpdate() (ReleaseInfo, error) {
releasesUrl := "https://api.github.com/repos/profclems/glab/releases/latest"
resp, err := request.MakeRequest("{}",releasesUrl, "GET")
resp, err := request.MakeRequest("{}", releasesUrl, "GET")
var releaseInfo ReleaseInfo
if err != nil {
return ReleaseInfo{}, err
}
json.Unmarshal([]byte(resp), &releaseInfo)
return releaseInfo, nil
}
}