Skip to content

Commit 85d85fc

Browse files
committed
close #188 wrapup for jira
1 parent 7fc70b9 commit 85d85fc

File tree

4 files changed

+101
-16
lines changed

4 files changed

+101
-16
lines changed

ci/CHANGELOG.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
## Changelog
2-
An apology to the users who was affected by the recent major release, that was not cool. We have fixed a few things that should make life easier.
3-
We also cleaned up the code a bit and made it look nicer.
42

5-
#### Improvements
6-
- bootstrap .phlow if it does not exist #203 @groenborg
7-
git phlow will now create a .phlow file if none exists. It will also see if it can find the default branch like it did before.
83

9-
- workon should not do a pull rebase #200 @groenborg
10-
workon will not do a pull rebase, when setting up a workspace.
4+
#### Features
5+
6+
- deliver is updated to support target configuration, and Jira #230 @groenborg
7+
you can now deliver work, with settings from the target configuration.. Hurray
8+
9+
- wrapup is now support on windows as well #188 @groenborg
10+
wrapup will now format messages based on GitHub and Jira branches
11+
12+
- workon is now updated to support target configuration, and Jira #224 @groenborg
13+
you can now work on issues located on GitHub and Jira, with settings from the target configuration
14+
15+
16+
#### Bug Fixes
17+
- fix configuration for windows #236 @groenborg
18+
Turns out the config before did not work on windows, however, it does now.
19+
20+
- auth errors are handled when commands using service API are called #240 @groenborg
21+
a successful bug-hunt resulted in one less error, where the tool basically would explode with errors if commands were executed without authorization
22+
23+
24+
#### improvements
25+
- We removed the beautiful spinner when running `workon` and `deliver` #241 @groenborg
26+
it might return in future versions, when it no longer messes with the formatting. Never mess with the formatting!

main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
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() {
8-
96
cmd.Execute()
10-
117
}

phlow/wrapup.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/praqma/git-phlow/githandler"
1010
"github.com/praqma/git-phlow/options"
1111
"github.com/praqma/git-phlow/executor"
12+
"strconv"
13+
"errors"
1214
)
1315

1416
//WrapUp ...
@@ -30,13 +32,25 @@ func WrapUp() {
3032

3133
//Retrieve branch info - current branch
3234
info := githandler.AsList(out)
33-
3435
var commitMessage string
3536

36-
if options.GlobalFlagForceMessage != "" {
37-
commitMessage = "close #" + strings.Split(info.Current, "-")[0] + " " + options.GlobalFlagForceMessage
37+
issue, err := GetJIRAIssue(info.Current)
38+
if err != nil {
39+
40+
if options.GlobalFlagForceMessage != "" {
41+
commitMessage = "close #" + strings.Split(info.Current, "-")[0] + " " + options.GlobalFlagForceMessage
42+
} else {
43+
commitMessage = "close #" + strings.Replace(info.Current, "-", " ", -1)
44+
}
3845
} else {
39-
commitMessage = "close #" + strings.Replace(info.Current, "-", " ", -1)
46+
msg := strings.TrimPrefix(info.Current, issue)
47+
48+
if options.GlobalFlagForceMessage != "" {
49+
commitMessage = "close #" + issue + " " + options.GlobalFlagForceMessage
50+
} else {
51+
commitMessage = "close #" + issue + strings.Replace(msg, "-", " ", -1)
52+
}
53+
4054
}
4155

4256
_, err = git.Commit("-m", commitMessage)
@@ -47,3 +61,12 @@ func WrapUp() {
4761

4862
fmt.Fprintln(os.Stdout, commitMessage)
4963
}
64+
65+
func GetJIRAIssue(branch string) (string, error) {
66+
67+
parts := strings.Split(branch, "-")
68+
if _, err := strconv.Atoi(parts[0]); err != nil && len(parts) > 1 {
69+
return parts[0] + "-" + parts[1], nil
70+
}
71+
return "", errors.New("not a jira branch")
72+
}

phlow/wrapup_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package phlow_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
"github.com/praqma/git-phlow/phlow"
6+
. "github.com/onsi/gomega"
7+
)
8+
9+
var _ = Describe("Wrapup", func() {
10+
11+
Describe("Testing getting name and issue", func() {
12+
13+
Context("for github branches", func() {
14+
15+
It("for github should return error", func() {
16+
_, err := phlow.GetJIRAIssue("1-hello-issue")
17+
Ω(err).ShouldNot(BeNil())
18+
})
19+
20+
It("for master should return error", func() {
21+
_, err := phlow.GetJIRAIssue("master")
22+
Ω(err).ShouldNot(BeNil())
23+
})
24+
25+
})
26+
27+
Context("for jira branches", func() {
28+
29+
It("should return TIS-46", func() {
30+
issue, err := phlow.GetJIRAIssue("TIS-46-update-localtransportcontroller-to-handle-multiple-travel-providers-in-one-reservation")
31+
Ω(err).Should(BeNil())
32+
Ω(issue).Should(Equal("TIS-46"))
33+
})
34+
35+
It("should return TIS-45", func() {
36+
issue, err := phlow.GetJIRAIssue("TIS-45-email-non-registered-users-to-sign-up-with-teams-in-space")
37+
Ω(err).Should(BeNil())
38+
Ω(issue).Should(Equal("TIS-45"))
39+
})
40+
41+
It("should return ADO-70", func() {
42+
issue, err := phlow.GetJIRAIssue("ADO-70-booking-button-randomly-dissapears")
43+
Ω(err).Should(BeNil())
44+
Ω(issue).Should(Equal("ADO-70"))
45+
})
46+
47+
})
48+
49+
})
50+
})

0 commit comments

Comments
 (0)