Skip to content

Commit efba4a1

Browse files
committed
close #209 user scenarios phlow
1 parent 998b67f commit efba4a1

File tree

11 files changed

+254
-273
lines changed

11 files changed

+254
-273
lines changed

.gitconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[phlow]
2+
remote = origin
3+
service = github
4+
integration-branch = master
5+
issue-url = https://api.github.com
6+
delivery-branch-prefix = ready
7+

.phlow

Lines changed: 0 additions & 15 deletions
This file was deleted.

cmd/bootstrap.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
"github.com/praqma/git-phlow/phlow"
6+
)
7+
8+
// bootstrapCmd represents the bootstrap command
9+
var bootstrapCmd = &cobra.Command{
10+
Use: "bootstrap",
11+
Short: "creates a .gitconfig file",
12+
Long: `
13+
Creates a new .gitconfig file in your local repository
14+
`,
15+
Run: func(cmd *cobra.Command, args []string) {
16+
phlow.Bootstrap()
17+
},
18+
}
19+
20+
func init() {
21+
configCmd.AddCommand(bootstrapCmd)
22+
23+
}

cmd/config.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
// configCmd represents the config command
8+
var configCmd = &cobra.Command{
9+
Use: "config",
10+
Short: "bootstrap or show configuration",
11+
Long: `
12+
git phlow uses gits own configuration, so all your configurations can be placed everywhere git config can get them.
13+
Best practice is to create a .gitconfig in your repository with your won configurations.
14+
15+
Git phlow comes with internal defaults configured to work natively with github. So you can use git phlow
16+
without any configuration at all. If you want to customize it the default setting create an INI-block
17+
in a local .gitconfig, and make sure all mandatory fields are set.
18+
19+
To use a local .gitconfig file remember to add it to the config path, with this command
20+
'git config --local include.path ../.gitconfig'
21+
22+
[phlow] is the default ini block
23+
24+
Default configuration:
25+
[phlow]
26+
integration_branch = master
27+
remote = origin
28+
service = jira
29+
issue_url = https://my.jira.instance.com
30+
delivery_branch_prefix = ready
31+
32+
33+
34+
35+
36+
`,
37+
Run: func(cmd *cobra.Command, args []string) {
38+
cmd.Help()
39+
},
40+
}
41+
42+
func init() {
43+
RootCmd.AddCommand(configCmd)
44+
45+
}

cmd/show.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
"github.com/praqma/git-phlow/phlow"
6+
)
7+
8+
// showCmd represents the show command
9+
var showCmd = &cobra.Command{
10+
Use: "show",
11+
Short: "shows configuration",
12+
Long: `
13+
Shows a specified configuration block on your configuration file.
14+
If no arguments are passed it will show the internal default configuration
15+
`,
16+
Run: func(cmd *cobra.Command, args []string) {
17+
phlow.Show(args)
18+
},
19+
}
20+
21+
func init() {
22+
configCmd.AddCommand(showCmd)
23+
24+
}

executor/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func RunGit(git string, sub string, argv ...string) (string, error) {
7272
argv = append([]string{sub}, argv...)
7373
exe := exec.Command(git, argv...)
7474

75-
if true {
75+
if options.GlobalFlagVerbose {
7676
verboseOutput(exe.Args...)
7777
}
7878

githandler/git.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ func (os *Git) LSRemote(argv ...string) (string, error) {
2222
return strings.TrimSpace(output), nil
2323
}
2424

25+
//RevParse ...
26+
//Executes local git rev-parse with params
27+
func (os *Git) RevParse(argv ...string) (string, error) {
28+
output, err := os.Run("git", "rev-parse", argv...)
29+
if err != nil {
30+
return "", err
31+
}
32+
return strings.TrimSpace(output), nil
33+
}
34+
2535
//Branch ...
2636
//Executes local git branch with params
2737
func (os *Git) Branch(argv ...string) (string, error) {

phlow/config.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package phlow
2+
3+
import (
4+
"github.com/praqma/git-phlow/githandler"
5+
"github.com/praqma/git-phlow/executor"
6+
"github.com/praqma/git-phlow/setting"
7+
"fmt"
8+
)
9+
10+
//Bootstrap ...
11+
//Creates a new .gitconfig file with a default configuration
12+
func Bootstrap() {
13+
14+
git := githandler.Git{Run: executor.RunGit}
15+
16+
local, err := git.RevParse("--show-toplevel")
17+
if err != nil {
18+
panic(err)
19+
}
20+
21+
setting.BootstrapPhlowConfig(local, "master")
22+
}
23+
24+
//Show ...
25+
//Shows the listed configuration
26+
func
27+
Show(args []string) {
28+
29+
if len(args) >= 1 {
30+
conf := setting.NewProjectStg(args[0])
31+
fmt.Println(conf.ToString())
32+
return
33+
}
34+
conf := setting.NewProjectStg("")
35+
fmt.Println(conf.ToString())
36+
}

phlow/deliver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func Deliver(conf *setting.ProjectSetting) {
4040

4141
_, err = git.Pull("--rebase")
4242
if err != nil {
43+
fmt.Println("Error in rebasing: ")
4344
fmt.Println(err)
4445
}
4546

@@ -58,6 +59,7 @@ func Deliver(conf *setting.ProjectSetting) {
5859
//git push origin name:ready/name
5960
_, err = git.Push(conf.Remote, fmt.Sprintf("%s:%s/%s", branchInfo.Current, conf.DeliveryBranchPrefix, branchInfo.Current))
6061
if err != nil {
62+
fmt.Println("error in push")
6163
fmt.Println(err)
6264
return
6365
}

0 commit comments

Comments
 (0)