aboutsummaryrefslogtreecommitdiffstats
path: root/utils/utils.go
diff options
context:
space:
mode:
authorTeddy Wing2014-12-14 13:15:11 -0500
committerTeddy Wing2014-12-14 13:15:11 -0500
commite02955d75b0f72147884de74ef6ff563828f1bc2 (patch)
treef04c05b47d2b4d5220c76edf7eea2ef09d176188 /utils/utils.go
parent8c64b8afcf6d98cefe1076ee2ec048aa75e6b4c7 (diff)
downloadgit-checkout-history-e02955d75b0f72147884de74ef6ff563828f1bc2.tar.bz2
git-checkout-history: Put duplicated code in utils.go
Extract code that was duplicated from checkout-history-store so that it now lives in a single place: the utils.go file. Add a new function to utils.go that returns the list of branches in history so that we can grab this for git-checkout-history.
Diffstat (limited to 'utils/utils.go')
-rw-r--r--utils/utils.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/utils.go b/utils/utils.go
index 8efe6d2..01e2556 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -63,3 +63,20 @@ func Store(branch string) {
log.Fatal(err)
}
}
+
+func Branches() []string {
+ branchList := BranchList{}
+
+ file_path := getHomeDir() + "/" + history_file
+ data, err := ioutil.ReadFile(file_path)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ err = yaml.Unmarshal(data, &branchList)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ return branchList.Branches
+}