summaryrefslogtreecommitdiff
path: root/branches.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-07-21 22:25:27 -0500
committerJeff Carr <[email protected]>2025-07-21 22:25:27 -0500
commit68af638f9ece1a67075d5022a1361821e0f03b9a (patch)
tree6c041d3507fd361290de9d89446db69e0f38e5aa /branches.go
parent1c439782941d21d8b26bf5590b4f3d4b69da70ad (diff)
something to make user branchesv0.0.106v0.0.105
Diffstat (limited to 'branches.go')
-rw-r--r--branches.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/branches.go b/branches.go
index 9159e92..3b642c1 100644
--- a/branches.go
+++ b/branches.go
@@ -82,3 +82,29 @@ func (repo *Repo) DeleteLocalDevelBranch() error {
return fmt.Errorf("local branch has patches not in remote")
}
}
+
+// makes a local branch based off of the master branch
+// (unless a remote devel branch exists. then it uses that)
+func (repo *Repo) MakeLocalDevelBranch() error {
+ branch := repo.GetDevelBranchName()
+ if branch == "" {
+ // hard coded default
+ branch = "devel"
+ }
+ if repo.Exists(filepath.Join(".git/refs/heads", branch)) {
+ // local devel branch already exists
+ return nil
+ }
+ if repo.Exists(filepath.Join(".git/refs/remotes/origin", branch)) {
+ // remote devel branch exists, but local does not
+ cmd := []string{"git", "checkout", branch}
+ repo.RunVerbose(cmd)
+ return nil
+ }
+ master := repo.GetMasterBranchName()
+ cmd := []string{"git", "branch", branch, master}
+ repo.RunVerbose(cmd)
+ cmd = []string{"git", "checkout", branch}
+ repo.RunVerbose(cmd)
+ return nil
+}