summaryrefslogtreecommitdiff
path: root/deleteTags.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-05 20:04:38 -0500
committerJeff Carr <[email protected]>2025-10-05 20:04:38 -0500
commitd9ed0838c403e982f572d108542bcc16705049d9 (patch)
tree5d8229be3dbfcd068219417cf0039e7e37735eca /deleteTags.go
parent7360716b35b452595e93c554d5f342b9f0338ea2 (diff)
logic for branch testing
Diffstat (limited to 'deleteTags.go')
-rw-r--r--deleteTags.go68
1 files changed, 68 insertions, 0 deletions
diff --git a/deleteTags.go b/deleteTags.go
new file mode 100644
index 0000000..0b05238
--- /dev/null
+++ b/deleteTags.go
@@ -0,0 +1,68 @@
+package gitpb
+
+import (
+ "fmt"
+ "path/filepath"
+)
+
+/*
+func (repo *Repo) DeleteLocalTag(t *GitTag) bool {
+ b1, err := repo.CountDiffObjects(branch, remote) // should be zero
+ if err != nil {
+ return err
+ }
+ if b1 == 0 {
+ cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
+ _, err := repo.RunVerboseOnError(cmd)
+ return err
+ } else {
+ return fmt.Errorf("local branch has patches not in remote")
+ }
+}
+*/
+
+// deletes the devel local branch if it is a subset of the remote devel branch
+func (repo *Repo) DeleteLocalBranch(branch string) ([]string, error) {
+ remote := filepath.Join("origin", branch)
+
+ if !repo.IsBranchRemote(branch) {
+ return nil, fmt.Errorf("no remote branch")
+ }
+
+ b1, err := repo.CountDiffObjectsNew(branch, remote) // should be zero
+ if err != nil {
+ return nil, err
+ }
+ if len(b1) == 0 {
+ // log.Info("SAFE TO DELETE?")
+ /*
+ cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
+ _, err := repo.RunVerboseOnError(cmd)
+ */
+ return nil, nil
+ }
+ // log.Info("LOCAL NOT SAFE TO DELETE", repo.FullPath)
+ return b1, fmt.Errorf("local branch has patches not in remote")
+}
+
+// deletes the devel local branch if it is a subset of the remote devel branch
+func (repo *Repo) DeleteLocalDevelBranch() error {
+ branch := repo.GetDevelBranchName()
+ remote := filepath.Join("origin", branch)
+
+ if !repo.IsDevelRemote() {
+ return fmt.Errorf("no remote branch")
+ }
+
+ b1, err := repo.CountDiffObjects(branch, remote) // should be zero
+ if err != nil {
+ return err
+ }
+ if b1 == 0 {
+ cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
+ _, err := repo.RunVerboseOnError(cmd)
+ return err
+ } else {
+ return fmt.Errorf("local branch has patches not in remote")
+ }
+}