GitPull() detects local only branches
This commit is contained in:
parent
2a62d23482
commit
ddd95e9afc
22
git.go
22
git.go
|
@ -40,9 +40,29 @@ func (rs *RepoStatus) Age() time.Duration {
|
|||
}
|
||||
|
||||
func (rs *RepoStatus) GitPull() error {
|
||||
currentName := rs.GetCurrentBranchName()
|
||||
if rs.IsOnlyLocalTag(currentName) {
|
||||
log.Log(REPOWARN, rs.Path(), "can not git pull on local only branch", currentName)
|
||||
return nil
|
||||
}
|
||||
var found bool = false
|
||||
// okay, it's not local. Is it mapped in .git/config ?
|
||||
for name, branch := range rs.gitConfig.branches {
|
||||
log.Log(WARN, name, "remote:", branch.remote, "merge", branch.merge)
|
||||
if name == currentName {
|
||||
log.Log(WARN, "Found:", name, "remote:", branch.remote, "merge", branch.merge)
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if ! found {
|
||||
return errors.New("git config error")
|
||||
}
|
||||
var cmd []string
|
||||
cmd = append(cmd, "git", "pull")
|
||||
err, _, output := RunCmd(rs.realPath.String(), cmd)
|
||||
err, output := rs.RunCmd(cmd)
|
||||
if err != nil {
|
||||
output = "git error_,,,_a_,,,_b_,,,c"
|
||||
}
|
||||
if err == nil {
|
||||
log.Log(REPOWARN, "git pull ran", rs.Path())
|
||||
log.Log(REPOWARN, "git pull output", output)
|
||||
|
|
8
merge.go
8
merge.go
|
@ -8,6 +8,14 @@ import (
|
|||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
// used to block commits on non-user branches
|
||||
func (rs *RepoStatus) IsUserBranch() bool {
|
||||
if rs.GetCurrentBranchName() == rs.GetUserBranchName() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) MergeUserToDevel() bool {
|
||||
startbranch := rs.GetCurrentBranchName()
|
||||
devel := rs.GetDevelBranchName()
|
||||
|
|
29
tagWindow.go
29
tagWindow.go
|
@ -318,6 +318,29 @@ func (rs *RepoStatus) LocalTagExists(findname string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// returns true if 'taggy' is _ONLY_ a local tag
|
||||
// this means you can not do a git pull or git push on it
|
||||
func (rs *RepoStatus) IsOnlyLocalTag(taggy string) bool {
|
||||
// first make sure the tag is actually even local
|
||||
if !rs.LocalTagExists(taggy) {
|
||||
// this means it's not even local now.
|
||||
return false
|
||||
}
|
||||
// okay, taggy exists, does it exist in a remote repo?
|
||||
for _, t := range rs.Tags.ListAll() {
|
||||
tagname := t.TagString()
|
||||
if strings.HasPrefix(tagname, "refs/remotes") {
|
||||
path, filename := filepath.Split(tagname)
|
||||
if filename == taggy {
|
||||
log.Log(REPOWARN, "found tag:", path, filename, "from", rs.Path())
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
// we couldn't find the local tag anywhere remote, so it's probably only local
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *Tag) Age() time.Duration {
|
||||
const gitLayout = "Mon Jan 2 15:04:05 2006 -0700"
|
||||
tagTime, _ := time.Parse(gitLayout, t.date.String())
|
||||
|
@ -373,3 +396,9 @@ func (rs *RepoStatus) NewestTag() *Tag {
|
|||
}
|
||||
return newest
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) DumpTags() {
|
||||
for _, t := range rs.Tags.ListAll() {
|
||||
log.Log(REPOWARN, "tag", t.ref.String(), t.date.String(), t.tag.String())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue