diff --git a/cmd/auth.go b/cmd/auth.go
index 08de9f1..881c9e4 100644
--- a/cmd/auth.go
+++ b/cmd/auth.go
@@ -18,9 +18,11 @@ along with this program. If not, see .
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 */
@@ -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 */
@@ -43,6 +53,8 @@ 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=")
},
}
@@ -50,4 +62,4 @@ func init() {
rootCmd.AddCommand(authCmd)
authCmd.Flags().StringP("username", "u", "", "your github username!")
authCmd.Flags().StringP("token", "t", "", "your github token!")
-}
+}
\ No newline at end of file
diff --git a/github/service.go b/github/service.go
index afff9e0..6bcb594 100644
--- a/github/service.go
+++ b/github/service.go
@@ -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
}
diff --git a/go.mod b/go.mod
index bbc1d7c..54516de 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/meanii/sync.ssh
-go 1.19
+go 1.18
require (
github.com/alexeyco/simpletable v1.0.0
@@ -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
diff --git a/go.sum b/go.sum
index 0750796..cc31fcf 100644
--- a/go.sum
+++ b/go.sum
@@ -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=