Skip to content

Commit 1acfb54

Browse files
committed
include logic to show current branch on top of the branches list
1 parent 39f140a commit 1acfb54

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

git/git_branch_list.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ func GetBranchList(repo *git.Repository, branchChan chan Branch) {
6464
splitCurrentBranch := strings.Split(currentBranch, "/")
6565
currentBranch = splitCurrentBranch[len(splitCurrentBranch)-1]
6666

67+
allBranchList = append(allBranchList, &currentBranch)
68+
branches = append(branches, &currentBranch)
69+
6770
ref, _ := repo.References()
6871

6972
if ref != nil {
@@ -83,7 +86,10 @@ func GetBranchList(repo *git.Repository, branchChan chan Branch) {
8386
} else {
8487
refNamePtr = &refNameSplit[1]
8588
}
86-
allBranchList = append(allBranchList, refNamePtr)
89+
if *refNamePtr != currentBranch {
90+
allBranchList = append(allBranchList, refNamePtr)
91+
}
92+
8793
}
8894
}
8995
}
@@ -104,7 +110,9 @@ func GetBranchList(repo *git.Repository, branchChan chan Branch) {
104110
localBranch = splitBranch[len(splitBranch)-1]
105111

106112
logger.Log("Available Branch : "+localBranch, global.StatusInfo)
107-
branches = append(branches, &localBranch)
113+
if localBranch != currentBranch {
114+
branches = append(branches, &localBranch)
115+
}
108116
}
109117
return nil
110118
} else {

global/GlobalLogger.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ func (logger *Logger) Log(message string, status string) {
4444
}
4545

4646
func (logger *Logger) LogInfo() {
47-
log.Printf("%vINFO: %v%v\n", color.Cyan, color.Reset, logger.Message)
47+
log.Printf("%v[INFO]: %v%v\n", color.Cyan, color.Reset, logger.Message)
4848
}
4949

5050
func (logger *Logger) LogWarning() {
51-
log.Printf("%vWARNING: %v%v\n", color.Yellow, color.Reset, logger.Message)
51+
log.Printf("%v[WARNING]: %v%v\n", color.Yellow, color.Reset, logger.Message)
5252
}
5353

5454
func (logger *Logger) LogError() {
55-
log.Printf("%vERROR: %v%v\n", color.Red, color.Reset, logger.Message)
55+
log.Printf("%v[ERROR]: %v%v\n", color.Red, color.Reset, logger.Message)
5656
}

0 commit comments

Comments
 (0)