-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
executable file
·48 lines (32 loc) · 838 Bytes
/
Copy pathmain.go
File metadata and controls
executable file
·48 lines (32 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
git2sqlite - converts git repositories to sqlite databases.
When ran against a git repository, will output an sqlite database
with the following tables:
refs :: <path, hash>
blobs :: <hash, content>
trees :: <hash, content>
commits :: <hash, content>
This project is a work in progress.
*/
package main
import (
"log"
"os"
"path/filepath"
)
func main() {
// check args
var location string
if len(os.Args) == 2 {
location, _ = filepath.Abs(os.Args[1])
} else {
location, _ = filepath.Abs(filepath.Dir(os.Args[0]))
}
REPOSITORY_NAME := filepath.Join(location, ".git")
DATABASE_NAME := filepath.Base(location)+".db"
repo := GitRepository{REPOSITORY_NAME}
db := SQLiteDatabase{DATABASE_NAME}
db.Create()
db.WriteRepository(repo)
log.Println("Finished.")
}