Parcourir la source

Clarify the caching + do not panic if the cache exists

Vadim Markovtsev il y a 7 ans
Parent
commit
733728cae1
2 fichiers modifiés avec 18 ajouts et 0 suppressions
  1. 13 0
      README.md
  2. 5 0
      cmd/hercules/main.go

+ 13 - 0
README.md

@@ -59,6 +59,19 @@ git rev-list HEAD | tac | hercules -commits - https://github.com/git/git | tee c
 
 `labours.py -i /path/to/yaml` allows to read the output from `hercules` which was saved on disk.
 
+#### Caching
+
+It is possible to store the cloned repository on disk. The subsequent analysis can run on the
+corresponding directory instead of cloning from scratch:
+
+```
+# First time - cache
+hercules https://github.com/git/git /tmp/repo-cache
+
+# Second time - use the cache
+hercules /tmp/repo-cache
+```
+
 ### Extensions
 
 #### Files

+ 5 - 0
cmd/hercules/main.go

@@ -132,6 +132,11 @@ func main() {
 			if err != nil {
 				panic(err)
 			}
+			_, err = os.Stat(flag.Arg(1))
+			if !os.IsNotExist(err) {
+				fmt.Fprintf(os.Stderr, "warning: deleted %s\n", flag.Arg(1))
+				os.RemoveAll(flag.Arg(1))
+			}
 		} else {
 			backend = memory.NewStorage()
 		}