From 6b8ef6fc60a6ce7540e2def69d118c8baf8cf0cb Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 29 Jan 2025 01:12:32 -0600 Subject: [PATCH] last commit for the day --- branches.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/branches.go b/branches.go index 7d68e40..085380c 100644 --- a/branches.go +++ b/branches.go @@ -6,9 +6,34 @@ import ( // returns true if 'git pull' will work func (repo *Repo) IsBranchRemote(branchname string) bool { + if branchname == "" { + return false + } if repo.Exists(filepath.Join(".git/refs/remotes/origin", branchname)) { // todo: actually use .git/config return true } return false } + +// returns true if 'git pull' will work +func (repo *Repo) ExistsUserBranchRemote() bool { + branchname := repo.GetUserBranchName() + if repo.IsBranchRemote(branchname) { + return true + } + return false +} + +// returns true if the user branch exists +func (repo *Repo) ExistsUserBranch() bool { + if repo.GetUserBranchName() == "" { + return false + } + branchname := repo.GetUserBranchName() + if repo.Exists(filepath.Join(".git/refs/heads", branchname)) { + // todo: actually use .git/config + return true + } + return false +}