Skip to content

Commit 706f883

Browse files
committed
close #72 token must contain machine id in name
1 parent 6e3a97c commit 706f883

File tree

7 files changed

+59
-10
lines changed

7 files changed

+59
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ maintainer: groenborg
66

77
| build | goreport |
88
| ------------- | ----------------- |
9-
| [build status](https://concourse.code.praqma.com/api/v1/teams/main/pipelines/git-phlow/jobs/integration/badge) | [![Go Report Card](https://goreportcard.com/badge/github.com/Praqma/git-phlow)](https://goreportcard.com/report/github.com/Praqma/git-phlow) |
9+
| ![build status](https://concourse.kubernetes.praqma.cloud/api/v1/teams/main/pipelines/git-phlow/jobs/integration-tests/badge) | [![Go Report Card](https://goreportcard.com/badge/github.com/Praqma/git-phlow)](https://goreportcard.com/report/github.com/Praqma/git-phlow) |
1010

1111

1212
git-phlow (pronounced _"git flow"_), is a CLI extension for git, which provides an extra set of commands to easily use our pragmatic workflow called **the phlow**. It has an automatic branching model, which compliant CI/CD services can use for full automation. It also provides automatic issue tracking using [github](https://github.com) issues with [waffle](https://waffle.io/).

ci/notes/CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
The release brings much needed features to the phlow. Requests for opening GitHub issues in your browser have been heard, and here it is.
2-
We have also tried to address the issues with the workon command, where in some cases it was unable to locate the issues on github.
3-
As always we strive for perfection and try to make the code pretty as a butterfly.
4-
git-phlow can still not keep the coffey hot, but we are working hard on it.
1+
Last release brought some unexpected problems with our authentication og permissions to github, whoops.
2+
We have made a fix for theses problems, so just go ahead and get the update and these problems should be a part of the past.
3+
To re-authenticate you need to delete the old 'git phlow' token on github.com and delete your phlow settings in your global .gitconfig file.
4+
55

66
#### Features
77
- web command #63 (Browser can be started from phlow) @groenborg

cmd/issues.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ List all the open issues on GitHub with it's ID. Helps you locate what needs to
1616
`,
1717
PreRun: func(cmd *cobra.Command, args []string) {
1818
checks.IsRepository()
19+
checks.IsAuthenticated()
1920
},
2021
Run: func(cmd *cobra.Command, args []string) {
2122
phlow.IssueList()

cmd/web.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if that fails it will simply open GitHubs issue list in your default browser
2323
`,
2424
PreRun: func(cmd *cobra.Command, args []string) {
2525
checks.IsRepository()
26+
checks.IsAuthenticated()
2627
},
2728
Run: func(cmd *cobra.Command, args []string) {
2829
if len(args) > 0 {

main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package main
22

3-
import (
4-
"github.com/praqma/git-phlow/cmd"
5-
)
3+
import "github.com/praqma/git-phlow/cmd"
64

75
func main() {
86
cmd.Execute()
7+
98
}

plugins/github.go

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/praqma/git-phlow/githandler"
1212
"github.com/praqma/git-phlow/options"
13+
"os"
1314
)
1415

1516
//GitHub ...
@@ -122,16 +123,50 @@ func (i *IssueRequest) Get() ([]Issues, error) {
122123
return nil, err
123124
}
124125

126+
//Permissions ...
127+
//data struct for permissions
128+
type Permissions struct {
129+
Scopes []string `json:"scopes"`
130+
Note string `json:"note"`
131+
}
132+
133+
//createPermissions ...
134+
func createPermissions() (string, error) {
135+
hostname, err := os.Hostname()
136+
if err != nil {
137+
return "", err
138+
}
139+
140+
note := "git phlow " + hostname
141+
if options.GlobalFlagVerbose {
142+
fmt.Println("github plugin: " + note)
143+
}
144+
145+
perm := Permissions{
146+
Scopes: []string{"public_repo", "repo", "repo_deployment"},
147+
Note: note,
148+
}
149+
b2b, err := json.Marshal(&perm)
150+
if err != nil {
151+
return "", err
152+
}
153+
return string(b2b), nil
154+
}
155+
125156
//Auth ...
126157
//Auth request to github
127158
func (a *AuthRequest) Auth(user, pass string) (string, error) {
128159
var auth Auth
129-
var authBody = `{"scopes": ["public_repo"],"note": "git phlow"}`
160+
161+
perm, err := createPermissions()
162+
if err != nil {
163+
return "", err
164+
}
130165

131166
if options.GlobalFlagVerbose {
132167
fmt.Println(a.URL)
133168
}
134-
req, err := http.NewRequest("POST", a.URL, bytes.NewBuffer([]byte(authBody)))
169+
req, err := http.NewRequest("POST", a.URL, bytes.NewBuffer([]byte(perm)))
135170
if err != nil {
136171
return "", err
137172
}

plugins/github_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ func TestAuthorize(t *testing.T) {
3434
})
3535
}
3636

37+
func TestCreatePermissions(t *testing.T) {
38+
Convey("Running tests on 'createPermissions' function", t, func() {
39+
Convey("should return json permissions as string", func() {
40+
str, err := createPermissions()
41+
42+
t.Log(str)
43+
So(str, ShouldContainSubstring, "repo")
44+
So(err, ShouldBeNil)
45+
46+
})
47+
})
48+
}
49+
3750
func TestGetDefaultBranch(t *testing.T) {
3851
Convey("Runnign tests on 'GetDefaultBranch' request", t, func() {
3952
Convey("GetDefaultBranch should return master", func() {

0 commit comments

Comments
 (0)