Skip to content

Commit

Permalink
fixed some minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
anilchauhanmogiio committed Oct 15, 2022
1 parent 69969e2 commit d9ecb77
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
14 changes: 13 additions & 1 deletion cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package cmd

import (
"fmt"
"github.com/meanii/sync.ssh/database"
"github.com/meanii/sync.ssh/validator"
"github.com/spf13/cobra"
"log"
)

/* authCmd represents the auth command */
Expand All @@ -32,6 +34,14 @@ var authCmd = &cobra.Command{
username, _ := cmd.Flags().GetString("username")
token, _ := cmd.Flags().GetString("token")

if len(username) <= 0 {
log.Fatalf("please provide github username!")
}

if len(token) <= 0 {
log.Fatalf("please provide your github access token!")
}

user := database.User{}
_ = user.Load() /* loading all the pre config */

Expand All @@ -43,11 +53,13 @@ var authCmd = &cobra.Command{
/* validating, if toke is valid or not */
user.Name, user.EmailAddress = validator.CheckToken(token, username)
_ = user.Save(user)

fmt.Println("you have been logged in now!, please prefer to init --repo=<repo_name>")
},
}

func init() {
rootCmd.AddCommand(authCmd)
authCmd.Flags().StringP("username", "u", "", "your github username!")
authCmd.Flags().StringP("token", "t", "", "your github token!")
}
}
1 change: 1 addition & 0 deletions github/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (g *GitService) githubClient() {
}

func (g *GitService) getRef() (ref *github.Reference, err error) {

if ref, _, err = g.Client.Git.GetRef(g.Ctx, *g.SourceOwner, *g.SourceRepo, "refs/heads/"+*g.BaseBranch); err == nil {
return ref, nil
}
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/meanii/sync.ssh

go 1.19
go 1.18

require (
github.com/alexeyco/simpletable v1.0.0
Expand All @@ -11,7 +11,6 @@ require (
)

require (
github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/alexeyco/simpletable v1.0.0 h1:ZQ+LvJ4bmoeHb+dclF64d0LX+7QAi7awsfCrptZrpHk=
github.com/alexeyco/simpletable v1.0.0/go.mod h1:VJWVTtGUnW7EKbMRH8cE13SigKGx/1fO2SeeOiGeBkk=
github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d h1:ZX0t+GA3MWiP7LWt5xWOphWRQd5JwL4VW5uLW83KM8g=
github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d/go.mod h1:EcJ034SpbWy4heOSDiBZJRn3b5wKJM1b4sFfYeVAkI4=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
Expand Down

0 comments on commit d9ecb77

Please sign in to comment.