aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-05-26 12:47:01 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-05-29 22:58:01 +0200
commit1c146a1b678d11ef86840955a9195685d18e4a52 (patch)
treea6a78a366b221b4cbfff343ea10bd62d9498a531
parent1022b9e5364c7f4bb8e38363b3760a3e48813047 (diff)
downloadgit-bug-1c146a1b678d11ef86840955a9195685d18e4a52.tar.gz
Change client default timeout value to 60 seconds
add named return values for easier validation for 2FA codes
-rw-r--r--bridge/github/config.go29
-rw-r--r--bridge/github/iterator.go12
2 files changed, 15 insertions, 26 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go
index 7868156e..dc1185b5 100644
--- a/bridge/github/config.go
+++ b/bridge/github/config.go
@@ -28,7 +28,7 @@ const (
keyProject = "project"
keyToken = "token"
- defaultTimeout = 5 * time.Second
+ defaultTimeout = 60 * time.Second
)
var (
@@ -243,8 +243,10 @@ func promptToken() (string, error) {
func loginAndRequestToken(owner, project string) (string, error) {
fmt.Println("git-bug will now generate an access token in your Github profile. Your credential are not stored and are only used to generate the token. The token is stored in the repository git config.")
fmt.Println()
- fmt.Println("Depending on your configuration the token will have one of the following scopes:")
+ fmt.Println("The access scope depend on the type of repository.")
+ fmt.Println("Public:")
fmt.Println(" - 'user:email': to be able to read public-only users email")
+ fmt.Println("Private:")
fmt.Println(" - 'repo' : to be able to read private repositories")
// fmt.Println("The token will have the \"repo\" permission, giving it read/write access to your repositories and issues. There is no narrower scope available, sorry :-|")
fmt.Println()
@@ -304,12 +306,7 @@ func loginAndRequestToken(owner, project string) (string, error) {
}
if resp.StatusCode == http.StatusCreated {
- token, err := decodeBody(resp.Body)
- if err != nil {
- return "", err
- }
-
- return token, nil
+ return decodeBody(resp.Body)
}
b, _ := ioutil.ReadAll(resp.Body)
@@ -403,7 +400,7 @@ func promptURL(remotes map[string]string) (string, string, error) {
}
}
-func splitURL(url string) (string, string, string, error) {
+func splitURL(url string) (shortURL string, owner string, project string, err error) {
res := rxGithubURL.FindStringSubmatch(url)
if res == nil {
return "", "", "", fmt.Errorf("bad github project url")
@@ -500,19 +497,11 @@ func prompt2FA() (string, error) {
return "", err
}
- if len(byte2fa) != 6 {
- fmt.Println("invalid 2FA code size")
- continue
- }
-
- str2fa := string(byte2fa)
- _, err = strconv.Atoi(str2fa)
- if err != nil {
- fmt.Println("2fa code must be digits only")
- continue
+ if len(byte2fa) > 0 {
+ return string(byte2fa), nil
}
- return str2fa, nil
+ fmt.Println("code is empty")
}
}
diff --git a/bridge/github/iterator.go b/bridge/github/iterator.go
index 2bb197de..fcf72b8f 100644
--- a/bridge/github/iterator.go
+++ b/bridge/github/iterator.go
@@ -70,22 +70,22 @@ func NewIterator(owner, project, token string, since time.Time) *iterator {
issueEdit: indexer{-1},
commentEdit: indexer{-1},
variables: map[string]interface{}{
- keyOwner: githubv4.String(owner),
- "name": githubv4.String(project),
+ "owner": githubv4.String(owner),
+ "name": githubv4.String(project),
},
},
commentEdit: commentEditIterator{
index: -1,
variables: map[string]interface{}{
- keyOwner: githubv4.String(owner),
- "name": githubv4.String(project),
+ "owner": githubv4.String(owner),
+ "name": githubv4.String(project),
},
},
issueEdit: issueEditIterator{
index: -1,
variables: map[string]interface{}{
- keyOwner: githubv4.String(owner),
- "name": githubv4.String(project),
+ "owner": githubv4.String(owner),
+ "name": githubv4.String(project),
},
},
}