From e02955d75b0f72147884de74ef6ff563828f1bc2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 14 Dec 2014 13:15:11 -0500 Subject: 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. --- utils/utils.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'utils') 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 +} -- cgit v1.2.3