diff options
author | Teddy Wing | 2014-12-14 13:15:11 -0500 |
---|---|---|
committer | Teddy Wing | 2014-12-14 13:15:11 -0500 |
commit | e02955d75b0f72147884de74ef6ff563828f1bc2 (patch) | |
tree | f04c05b47d2b4d5220c76edf7eea2ef09d176188 /utils | |
parent | 8c64b8afcf6d98cefe1076ee2ec048aa75e6b4c7 (diff) | |
download | git-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')
-rw-r--r-- | utils/utils.go | 17 |
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 +} |