Skip to content

Commit e7afd37

Browse files
committed
close #258 clean deprecated code and fix cmd docs
1 parent 0479204 commit e7afd37

File tree

18 files changed

+75
-672
lines changed

18 files changed

+75
-672
lines changed

cmd/cleanup.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import (
44
"fmt"
55

66
"github.com/praqma/git-phlow/cmd/cmdperm"
7-
"github.com/praqma/git-phlow/githandler"
87
"github.com/praqma/git-phlow/options"
98
"github.com/praqma/git-phlow/phlow"
10-
"github.com/praqma/git-phlow/plugins"
119
"github.com/praqma/git-phlow/ui"
1210
"github.com/spf13/cobra"
1311
)
@@ -24,10 +22,7 @@ It deletes safely by running 'git branch -d'. By default, both local and remote
2422
cmdperm.RequiredCurDirRepository()
2523
},
2624
Run: func(cmd *cobra.Command, args []string) {
27-
defaultBranch, _ := plugins.GitHub.Default()
28-
remote := githandler.ConfigBranchRemote(defaultBranch)
29-
30-
phlow.Clean(remote)
25+
phlow.CleanCaller(options.GlobalFlagTarget)
3126
},
3227
}
3328

@@ -40,4 +35,6 @@ func init() {
4035
//Run clean forcefully
4136
cleanCmd.Flags().BoolVarP(&options.GlobalFlagForce, "force", "f", false, "force remove delivered branches")
4237

38+
cleanCmd.Flags().StringVarP(&options.GlobalFlagTarget, "target", "t", "", "the name of the INI block in .gitconfig")
39+
4340
}

cmd/deliver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
// deliverCmd represents the deliver command
1313
var deliverCmd = &cobra.Command{
14-
Use: "deliver [test args]",
14+
Use: "deliver [args]",
1515
Short: "deliver changes to remote master",
1616
Long: fmt.Sprintf(`
1717
%s pushes your committed changes to the remote repository.

cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ var RootCmd = &cobra.Command{
1616
Long: fmt.Sprintf(`
1717
%s is a git extension that provides an extra set of commands, enabling you to:
1818
create, work on and deliver tasks.
19+
20+
USAGE: git phlow COMMAND
21+
1922
`, ui.Format.Bold("git-phlow")),
2023
Run: func(cmd *cobra.Command, args []string) {
2124
if options.GlobalFlagVersion != false {

cmd/upnext.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import (
55
"os"
66

77
"github.com/praqma/git-phlow/cmd/cmdperm"
8-
"github.com/praqma/git-phlow/githandler"
98
"github.com/praqma/git-phlow/options"
109
"github.com/praqma/git-phlow/phlow"
11-
"github.com/praqma/git-phlow/plugins"
1210
"github.com/praqma/git-phlow/ui"
1311
"github.com/spf13/cobra"
1412
)
@@ -27,10 +25,7 @@ When no --prefix flag is set, the default prefix is 'ready/'.
2725
},
2826
Run: func(cmd *cobra.Command, args []string) {
2927

30-
defaultBranch, _ := plugins.GitHub.Default()
31-
remote := githandler.ConfigBranchRemote(defaultBranch)
32-
33-
next := phlow.UpNext(remote, options.GlobalFlagPrefixForReady)
28+
next := phlow.UpNext(options.GlobalFlagPrefixForReady)
3429
fmt.Fprint(os.Stdout, next)
3530
},
3631
}

cmd/workon.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ import (
1212

1313
// workonCmd represents the workon command
1414
var workonCmd = &cobra.Command{
15-
Use: "workon [issue number]",
15+
Use: "workon [issue]",
1616
Short: "create or change to an issue branch",
1717
Long: fmt.Sprintf(`
18-
%s creates a new branch from an issue number fetched from GitHub.
18+
%s creates a new branch from an issue.
1919
A new branch will be created, based on your remote default branch and named after the issue title, e.g. "42-calculate-meaning-of-life".
20+
Workon can fetch issues from GitHub and Jira
2021
`, ui.Format.Bold("workon")),
2122
PreRun: func(cmd *cobra.Command, args []string) {
2223
cmdperm.RequiredCurDirRepository()

cmd/wrapup.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ var wrapupCmd = &cobra.Command{
1414
Use: "wrapup",
1515
Short: "Add changes to index and auto commit",
1616
Long: fmt.Sprintf(`
17-
%s adds the files in the workin directory to the index and makes a commit. The commit message is autogenerated and contains 'close issue', e.g. "close #42 fetch meaning of life". The issue number is fetched from the branch name, if the workon command have been used. When force is used on the message, the message will replace, the otherwice automatically generated commit message.
17+
%s adds the files in the workin directory to the index and makes a commit.
18+
The commit message generated from the branch name and prepends a smart commit function to close the issue.
19+
The smart commit work with GitHub and Jira.
1820
`, ui.Format.Bold("wrapup")),
1921
PreRun: func(cmd *cobra.Command, args []string) {
2022
cmdperm.RequiredCurDirRepository()

executor/executor.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,6 @@ func verboseOutput(argv ...string) {
1919
fmt.Println()
2020
}
2121

22-
//Commander ...
23-
//interface for os executions
24-
type Commander interface {
25-
Run() error
26-
}
27-
28-
//ExecuteCommander ...
29-
//Run a function with control over stdout and stdin
30-
func ExecuteCommander(c Commander) error {
31-
err := c.Run()
32-
if err != nil {
33-
return err
34-
}
35-
return nil
36-
}
37-
3822
//Runner ...
3923
//Runner type for git executions
4024
type Runner func(command string, argv ...string) (string, error)

githandler/branch.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,7 @@ func Ready(info *BranchInfo, remote string, prefix string) (remoteBranches []str
5757
return
5858
}
5959

60-
//DEPRECETED SECTION - USE GIT
61-
//BranchRename ...
62-
func BranchRename(name string) error {
63-
_, err := executor.RunCommand("git", "branch", "-m", name, "delivered/"+name)
64-
return err
65-
}
66-
60+
//Deprecated
6761
//BranchTime ...
6862
func BranchTime(name string) (int, error) {
6963
output, err := executor.RunCommand("git", "log", "-n 1", name, "--format=format:%ct")

githandler/remote.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package githandler
33
import (
44
"strings"
55
"regexp"
6-
"fmt"
7-
"github.com/praqma/git-phlow/executor"
86
)
97

108
//RemoteInfo ...
@@ -34,46 +32,3 @@ func OrgAndRepo(url string) *RemoteInfo {
3432
//Clone from local repo
3533
return &RemoteInfo{}
3634
}
37-
38-
39-
// -------------------------------- DEPRECATED SECTION ---------------------------------------------------
40-
//Remote
41-
//Deprecated
42-
func Remote() (*RemoteInfo, error) {
43-
var res string
44-
var err error
45-
if res, err = executor.RunCommand("git", "ls-remote", "--get-url", "origin"); err != nil {
46-
return nil, err
47-
}
48-
res = strings.Trim(res, "\n")
49-
return remoteURLExtractor(res), nil
50-
}
51-
52-
//Deprecated
53-
func remoteURLExtractor(url string) *RemoteInfo {
54-
re := regexp.MustCompile(`.+:(\S+)\/(\S+)\.git`)
55-
56-
//Extracts repo and org from ssh url format
57-
if strings.HasPrefix(url, "git@") {
58-
match := re.FindStringSubmatch(url)
59-
return &RemoteInfo{match[1], match[2]}
60-
}
61-
//Extracts repo and org from http url format
62-
if strings.HasPrefix(url, "http") {
63-
splitURL := strings.Split(strings.TrimSuffix(url, ".git"), "/")
64-
org := splitURL[len(splitURL)-2]
65-
repo := splitURL[len(splitURL)-1]
66-
return &RemoteInfo{org, repo}
67-
}
68-
69-
//Clone from local repo
70-
return &RemoteInfo{}
71-
}
72-
73-
//ConfigBranchRemote ... use setting.Project setting to get remote in stead
74-
//Deprecated
75-
func ConfigBranchRemote(branch string) string {
76-
configArg := fmt.Sprintf("branch.%s.remote", branch)
77-
output, _ := executor.RunCommand("git", "config", configArg)
78-
return strings.Replace(output, "\n", "", -1)
79-
}

phlow/cleanup.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ import (
1010
"github.com/praqma/git-phlow/setting"
1111
)
1212

13+
//CleanCaller ...
14+
func CleanCaller(ini string) {
15+
conf := setting.NewProjectStg(ini)
16+
Clean(conf)
17+
}
18+
1319
//Clean ...
14-
func Clean(remoteName string) {
20+
func Clean(conf *setting.ProjectSetting) {
1521
git := githandler.Git{Run: executor.RunGit}
16-
conf := setting.NewProjectStg("default")
1722

1823
out, err := git.Branch("-a")
1924
if err != nil {

0 commit comments

Comments
 (0)