Skip to content

Commit af37191

Browse files
authored
Merge pull request #1 from codemodify/update-config-command
update config command + add the "sc branch pr" command
2 parents 76f48ec + d83fc3d commit af37191

36 files changed

Lines changed: 455 additions & 947 deletions

backend-cvs/backend.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ func notImplemented() error {
1616
return fmt.Errorf("CVS not implemented")
1717
}
1818

19-
func (thisRef *cvs) Config() (string, error) { return "", notImplemented() }
19+
func (thisRef *cvs) ConfigList() (string, error) { return "", notImplemented() }
20+
func (thisRef *cvs) ConfigSet(flags spec.ConfigSetFlags) error { return notImplemented() }
2021
func (thisRef *cvs) RepoInfo() (string, error) { return "", notImplemented() }
2122
func (thisRef *cvs) RepoInit(flags spec.RepoInitFlags) (string, error) { return "", notImplemented() }
2223
func (thisRef *cvs) RepoClone(flags spec.RepoCloneFlags) (string, error) {
@@ -31,6 +32,7 @@ func (thisRef *cvs) BranchCreate(flags spec.BranchCreateFlags) error { return no
3132
func (thisRef *cvs) BranchDelete(flags spec.BranchDeleteFlags) error { return notImplemented() }
3233
func (thisRef *cvs) BranchMerge(flags spec.BranchMergeFlags) error { return notImplemented() }
3334
func (thisRef *cvs) BranchRebase(flags spec.BranchRebaseFlags) error { return notImplemented() }
35+
func (thisRef *cvs) BranchPR() (string, error) { return "", notImplemented() }
3436
func (thisRef *cvs) ChangeList() (string, error) { return "", notImplemented() }
3537
func (thisRef *cvs) ChangeDiff(flags spec.ChangeDiffFlags) (string, error) {
3638
return "", notImplemented()

backend-empty/backend.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ func unsupported() error {
1616
return fmt.Errorf("unsupported SCS")
1717
}
1818

19-
func (thisRef *empty) Config() (string, error) { return "", unsupported() }
19+
func (thisRef *empty) ConfigList() (string, error) { return "", unsupported() }
20+
func (thisRef *empty) ConfigSet(flags spec.ConfigSetFlags) error { return unsupported() }
2021
func (thisRef *empty) RepoInfo() (string, error) { return "", unsupported() }
2122
func (thisRef *empty) RepoInit(flags spec.RepoInitFlags) (string, error) { return "", unsupported() }
2223
func (thisRef *empty) RepoClone(flags spec.RepoCloneFlags) (string, error) {
@@ -31,6 +32,7 @@ func (thisRef *empty) BranchCreate(flags spec.BranchCreateFlags) error { return
3132
func (thisRef *empty) BranchDelete(flags spec.BranchDeleteFlags) error { return unsupported() }
3233
func (thisRef *empty) BranchMerge(flags spec.BranchMergeFlags) error { return unsupported() }
3334
func (thisRef *empty) BranchRebase(flags spec.BranchRebaseFlags) error { return unsupported() }
35+
func (thisRef *empty) BranchPR() (string, error) { return "", unsupported() }
3436
func (thisRef *empty) ChangeList() (string, error) { return "", unsupported() }
3537
func (thisRef *empty) ChangeDiff(flags spec.ChangeDiffFlags) (string, error) {
3638
return "", unsupported()

backend-git/backend.go

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,56 @@ package git
33
import "github.com/codemodify/sc/spec"
44

55
var (
6-
git_cmdConfigList = []string{"git", "config", "--list"}
7-
git_cmdRepoInfoTopLevel = []string{"git", "rev-parse", "--show-toplevel"}
8-
git_cmdRepoInfoCurrentBranch = []string{"git", "rev-parse", "--abbrev-ref", "HEAD"}
9-
git_cmdRepoInfoIsBare = []string{"git", "rev-parse", "--is-bare-repository"}
10-
git_cmdRepoInfoOriginURL = []string{"git", "remote", "get-url", "origin"}
11-
git_cmdRepoInit = []string{"git", "init"}
12-
git_cmdRepoClone = []string{"git", "clone"}
13-
git_cmdFetchBranches = []string{"git", "fetch", "--no-tags"}
14-
git_cmdFetchTags = []string{"git", "fetch", "--tags"}
6+
git_cmdConfigListGlobal = []string{"git", "config", "--global", "--list"}
7+
git_cmdConfigListLocal = []string{"git", "config", "--local", "--list"}
8+
git_cmdConfigSet = []string{"git", "config"}
9+
10+
git_cmdRepoInfoTopLevel = []string{"git", "rev-parse", "--show-toplevel"}
11+
git_cmdRepoInfoCurrentBranch = []string{"git", "rev-parse", "--abbrev-ref", "HEAD"}
12+
git_cmdRepoInfoIsBare = []string{"git", "rev-parse", "--is-bare-repository"}
13+
git_cmdRepoInfoOriginURL = []string{"git", "remote", "get-url", "origin"}
14+
git_cmdRepoInit = []string{"git", "init"}
15+
git_cmdRepoClone = []string{"git", "clone"}
16+
1517
git_cmdBranchListLocal = []string{"git", "branch"}
1618
git_cmdBranchListRemote = []string{"git", "branch", "-r"}
17-
git_cmdBranchLocalToRemote = []string{"git", "for-each-ref", "--format=%(refname:short)->%(upstream:short)", "refs/heads"}
18-
git_cmdBranchSwitch = []string{"git", "switch"}
19+
git_cmdBranchListRemoteFetch = []string{"git", "fetch", "--no-tags"}
20+
git_cmdBranchListLocalToRemote = []string{"git", "for-each-ref", "--format=%(refname:short)->%(upstream:short)", "refs/heads"}
1921
git_cmdBranchCreate = []string{"git", "switch", "-c"} // create and switch
2022
git_cmdBranchCreateFromExisting = []string{"git", "switch", "-c"} // create and switch "new-branch" from "existing-branch"
2123
git_cmdBranchDeleteLocal = []string{"git", "branch", "-d"}
2224
git_cmdBranchDeleteLocalForce = []string{"git", "branch", "-D"} // if there are unmerged commits
2325
git_cmdBranchDeleteRemote = []string{"git", "push", "origin", "--delete"}
26+
git_cmdBranchSwitch = []string{"git", "switch"}
2427
git_cmdBranchMerge = []string{"git", "merge"}
2528
git_cmdBranchRebase = []string{"git", "rebase"}
26-
git_cmdChangeList = []string{"git", "status"}
27-
git_cmdChangeDiff = []string{"git", "diff"}
28-
git_cmdChangeDiffFile = []string{"git", "diff", "--"}
29-
git_cmdChangeAdd = []string{"git", "add"}
30-
git_cmdChangeRemove = []string{"git", "restore", "--staged", "--"}
31-
git_cmdChangeReset = []string{"git", "restore", "--source", "HEAD", "--staged", "--worktree", "--"}
32-
git_cmdCommitSave = []string{"git", "commit", "-m"}
33-
git_cmdCommitList = []string{"git", "log", "--oneline", "--decorate"}
34-
git_cmdCommitPull = []string{"git", "pull"}
35-
git_cmdCommitPush = []string{"git", "push"}
36-
git_cmdCommitUndo = []string{"git", "revert", "--no-edit"}
37-
git_cmdHeadVerify = []string{"git", "rev-parse", "--verify", "HEAD"}
38-
git_cmdStashList = []string{"git", "stash", "list", "--format=%gd\t%gs"}
39-
git_cmdStashPush = []string{"git", "stash", "push", "-m"}
40-
git_cmdStashDrop = []string{"git", "stash", "drop"}
41-
git_cmdRestoreFromSource = []string{"git", "restore", "--source"}
42-
git_cmdTagList = []string{"git", "tag", "--list"}
43-
git_cmdTagPull = []string{"git", "fetch", "--tags"}
44-
git_cmdTagCreate = []string{"git", "tag"}
45-
git_cmdTagDelete = []string{"git", "tag", "-d"}
46-
git_cmdTagPush = []string{"git", "push", "--tags"}
29+
git_cmdBranchPRBranch = []string{"git", "rev-parse", "--abbrev-ref", "HEAD"}
30+
git_cmdBranchPROriginHead = []string{"git", "symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"}
31+
32+
git_cmdCommitList = []string{"git", "log", "--oneline", "--decorate"}
33+
git_cmdCommitPull = []string{"git", "pull"}
34+
git_cmdCommitUndo = []string{"git", "reset", "--soft", "HEAD~1"} // []string{"git", "revert", "--no-edit"}
35+
git_cmdCommitSave = []string{"git", "commit", "-m"}
36+
git_cmdCommitPush = []string{"git", "push"}
37+
git_cmdCommitHeadVerify = []string{"git", "rev-parse", "--verify", "HEAD"}
38+
39+
git_cmdChangeList = []string{"git", "status"}
40+
git_cmdChangeAdd = []string{"git", "add"}
41+
git_cmdChangeRemove = []string{"git", "restore", "--staged", "--"}
42+
git_cmdChangeReset = []string{"git", "restore", "--source", "HEAD", "--staged", "--worktree", "--"}
43+
git_cmdChangeDiff = []string{"git", "diff"}
44+
git_cmdChangeDiffFile = []string{"git", "diff", "--"}
45+
46+
git_cmdStashList = []string{"git", "stash", "list", "--format=%gd\t%gs"}
47+
git_cmdStashAdd = []string{"git", "stash", "push", "-m"}
48+
git_cmdStashRemove = []string{"git", "restore", "--source"}
49+
git_cmdStashDelete = []string{"git", "stash", "drop"}
50+
51+
git_cmdTagList = []string{"git", "tag", "--list"}
52+
git_cmdTagPull = []string{"git", "fetch", "--tags"}
53+
git_cmdTagCreate = []string{"git", "tag"}
54+
git_cmdTagDelete = []string{"git", "tag", "-d"}
55+
git_cmdTagPush = []string{"git", "push", "--tags"}
4756
)
4857

4958
type git struct{}

0 commit comments

Comments
 (0)