Skip to content

Commit

Permalink
close #185 auth for jira
Browse files Browse the repository at this point in the history
  • Loading branch information
groenborg committed Aug 18, 2017
1 parent 0eafe5b commit 467fa8d
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 174 deletions.
23 changes: 11 additions & 12 deletions ci/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
## Changelog
The new release of git-phlow adds support for windows in _beta_. Overall improvements have been made to increase stability and remove
various bugs and odd behaviours.
git phlow have had a _huge_ makeover in this release. Configuration have been introduced, and git phlow now works by reading
configuration from a .phlow file, instead of guessing your remote and integration branch. This also brings support for new services like Jira and bitbucket.
The underlying git implementation have been stabilized and is now up and running on windows, so do not feel cheated anymore.

#### Features
- Windows is now support in a pre-release version
- Add Less and More browsing #150 @groenborg
- Add no-color option for windows #148 @kryptag
- Auth for jira #185 @groenborg
git phlow can now authorize against Jira using the right configuration. See [docs](docs/README.md)

- phlow as configuration #192 @groenborg
git phlow now works based on a .phlow config file

#### Improvements
- Use Scanner in stead of buffered Reader #149 @groenborg
- Add windows binary to GitHub release #151 @groenborg
- Added windows worker to concourse ci #144
- git for windows is stabilized

#### Bug fixes
- Colors are buggy when terminal width is changed #131 @groenborg
- username and password are no longer printed #158 @groenborg
- version was stuck at 1.0.0 #167 @groenborg
- Windows release is now zip and not tar.gz #169 @groenborg
- pull when setting up workspace #193 @lakruzz

2 changes: 1 addition & 1 deletion ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
- get: tollgate
trigger: true
- get: gp-version
params: {bump: patch}
params: {bump: major}
- put: gp-version
params: {file: gp-version/version}
- task: integration
Expand Down
2 changes: 1 addition & 1 deletion ci/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go install github.com/onsi/ginkgo/ginkgo


# run tests
go test -v ./...
ginkgo -v -r -trace -cover



3 changes: 1 addition & 2 deletions ci/windows/go-test-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ cd $env:GOPATH/src/github.com/praqma/git-phlow
go get -d -t -v ./...

#RUN TESTS
cd executor
go test -p 1 -v
go test -v ./...

# USES THE LATEST EXITCODE, WHICH IS FROM GO TEST, AND EXITS WITH THAT. THIS FIXIS
# ISSUE #152
Expand Down
4 changes: 3 additions & 1 deletion githandler/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (os *Git) Config(argv ...string) (string, error) {
return strings.Replace(stdOut, "\n", "", -1), nil
}

//DEPRECATESD SECTION ---------------------------------------------------------------
//Deprecated
//FormatPatch ...
//dry runs patch to see if we can auto merge
func FormatPatch(buf *bytes.Buffer, remoteBranch string) (err error) {
Expand All @@ -95,6 +95,7 @@ func FormatPatch(buf *bytes.Buffer, remoteBranch string) (err error) {
return
}

//Deprecated
//StatusPorcelain ...
//generates behind and ahead status
func StatusPorcelain() (string, error) {
Expand All @@ -105,6 +106,7 @@ func StatusPorcelain() (string, error) {
return strings.TrimSpace(out), nil
}

//Deprecated
//PushRename ...
func PushRename(branch, defaultBranch string) (string, error) {
remote := ConfigBranchRemote(defaultBranch)
Expand Down
45 changes: 25 additions & 20 deletions phlow/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@ var _ = Describe("Issue", func() {
Describe("GetPager on windows", func() {
Context("with pager set", func() {
It("should return testpager", func() {
EXPECTED := "testpager"
if runtime.GOOS == "windows" {
EXPECTED := "testpager"

err := os.Setenv("PAGER", "testpager")
ACTUAL := phlow.GetPager()
err := os.Setenv("PAGER", "testpager")
ACTUAL := phlow.GetPager()

Ω(ACTUAL).Should(Equal(EXPECTED))
Ω(err).Should(BeNil())
Ω(ACTUAL).Should(Equal(EXPECTED))
Ω(err).Should(BeNil())
}
})
})

Context("with pager unset", func() {
It("should return more", func() {
err := os.Unsetenv("PAGER")
if runtime.GOOS == "windows" {
err := os.Unsetenv("PAGER")

ACTUAL := phlow.GetPager()
EXPECTED := "more"
ACTUAL := phlow.GetPager()
EXPECTED := "more"

if runtime.GOOS == "windows" {
Ω(ACTUAL).Should(Equal(EXPECTED))
Ω(err).Should(BeNil())
}
Expand All @@ -44,26 +46,29 @@ var _ = Describe("Issue", func() {
Describe("GetPager on Unix", func() {
Context("with pager set", func() {
It("Should return less", func() {
EXPECTED := "less"
if runtime.GOOS != "windows" {
EXPECTED := "less"

err := os.Setenv("PAGER", "less")
ACTUAL := phlow.GetPager()
err := os.Setenv("PAGER", "less")
ACTUAL := phlow.GetPager()

Ω(ACTUAL).Should(Equal(EXPECTED))
Ω(err).Should(BeNil())
Ω(ACTUAL).Should(Equal(EXPECTED))
Ω(err).Should(BeNil())
}
})
})

Context("with pager unset", func() {
It("Should return nothing", func() {
err := os.Unsetenv("PAGER")

ACTUAL := phlow.GetPager()
EXPECTED := ""
if runtime.GOOS != "windows" {
err := os.Unsetenv("PAGER")

Ω(ACTUAL).Should(Equal(EXPECTED))
Ω(err).Should(BeNil())
ACTUAL := phlow.GetPager()
EXPECTED := ""

Ω(ACTUAL).Should(Equal(EXPECTED))
Ω(err).Should(BeNil())
}
})
})

Expand Down
12 changes: 7 additions & 5 deletions phlow/mkalias.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package phlow
import (
"fmt"
"github.com/praqma/git-phlow/ui"
"github.com/praqma/git-phlow/setting"
"github.com/praqma/git-phlow/githandler"
"github.com/praqma/git-phlow/executor"
)

//MakeAliasCaller ...
func MakeAliasCaller() {
MakeAlias(setting.GitConfig{})
MakeAlias()
}

//MakeAlias ...
func MakeAlias(conf setting.Configurator) {
func MakeAlias() {
git := githandler.Git{Run: executor.RunGit}
aliases := make(map[string]string)
aliases["alias.wrapup"] = "phlow wrapup"
aliases["alias.workon"] = "phlow workon"
Expand All @@ -23,10 +25,10 @@ func MakeAlias(conf setting.Configurator) {

for group, value := range aliases {

str := conf.Get(group)
str, _ := git.Config("--global", "--get", group)
if str == "" {
fmt.Printf("Creating alias %s \n", ui.Format.Alias(group))
conf.Set(group, value)
git.Config("--global", group, value)
} else {
fmt.Printf("Alias %s already exists \n", ui.Format.Alias(group))
}
Expand Down
15 changes: 7 additions & 8 deletions plugins/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/praqma/git-phlow/githandler"
"github.com/praqma/git-phlow/options"
"github.com/praqma/git-phlow/setting"
"github.com/praqma/git-phlow/executor"
)

var GitHub *GitHubImpl
Expand All @@ -27,6 +27,7 @@ type GitHubImpl struct {
token string
}

//Deprecated - This need to be redone to fit configuration - refer to: AuthorizeGitHub and AuthenticateGitHub they are changed to work the new way
//init ...
//creates a new GitHub request object with all the gh api urls
func init() {
Expand All @@ -40,12 +41,12 @@ func init() {
userRepo: "/user/repos",
}

stg := setting.NewToolStg()

git := githandler.Git{Run: executor.RunGit}
t, _ := git.Config("--get", "phlow.token")
info, _ := githandler.Remote()
org := info.Organisation
repo := info.Repository
token := stg.Token
token := t

GitHub = &GitHubImpl{
urls,
Expand Down Expand Up @@ -110,9 +111,6 @@ func AuthenticateGitHub(githubBaseURL string, user, token string) (bool, error)
return true, nil
}


// ------------------------------------------ DEPRECATE SECTION

//GetIssues ...
func (g *GitHubImpl) GetIssues() (issues []Issue, err error) {
URL := fmt.Sprintf(g.URLNoEsc(urls.issueURL), g.org, g.repo)
Expand Down Expand Up @@ -156,7 +154,6 @@ func (g *GitHubImpl) SetLabel(label string, issue int) (labels []Label, err erro
return re, nil
}


//Default ...
//Get default branch of a GitHub issue
func (g *GitHubImpl) Default() (defaultBranch string, err error) {
Expand Down Expand Up @@ -228,6 +225,7 @@ func createGHPermissions() (string, error) {
return string(b2b), nil
}

//Deprecated
//Auth ...
//Auth request to gh
func (g *GitHubImpl) Auth(user, pass string) (token string, err error) {
Expand All @@ -253,6 +251,7 @@ func (g *GitHubImpl) Auth(user, pass string) (token string, err error) {
return re.Token, nil
}

//Deprecated
//CheckAuth ...
//Checks personal access token validity by requesting private repositories and checking status code
func (g *GitHubImpl) CheckAuth() (bool, error) {
Expand Down
57 changes: 0 additions & 57 deletions setting/config.go

This file was deleted.

66 changes: 0 additions & 66 deletions setting/config_test.go

This file was deleted.

Loading

0 comments on commit 467fa8d

Please sign in to comment.