aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--git-checkout-history/main.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/git-checkout-history/main.go b/git-checkout-history/main.go
index e69de29..fa9747c 100644
--- a/git-checkout-history/main.go
+++ b/git-checkout-history/main.go
@@ -0,0 +1,43 @@
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os/user"
+
+ "gopkg.in/yaml.v2"
+)
+
+// TODO: move to package
+type BranchList struct {
+ Branches []string
+}
+
+// TODO: move to package
+func getHomeDir() string {
+ usr, err := user.Current()
+ if err != nil {
+ log.Fatal(err)
+ }
+ return usr.HomeDir
+}
+
+func main() {
+ branchList := BranchList{}
+
+ file_path := getHomeDir() + "/.git-checkout-history"
+ data, err := ioutil.ReadFile(file_path)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ err = yaml.Unmarshal(data, &branchList)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ for i := 1; i < len(branchList.Branches); i++ {
+ fmt.Printf("[%d] %s\n", i, branchList.Branches[i])
+ }
+}