start adding support for some more obscure git features

This commit is contained in:
maia tillie arson crimew 2021-10-26 20:44:43 +02:00
parent a6c6710b3c
commit 318039cb3c
4 changed files with 43 additions and 4 deletions

2
.gitignore vendored
View File

@ -20,3 +20,5 @@
.idea
*.iml
# local notes
notes.txt

View File

@ -61,7 +61,7 @@ func FindRefWorker(jt *jobtracker.JobTracker, path string, context jobtracker.Co
jt.AddJob(fmt.Sprintf(".git/logs/refs/remotes/origin/%s", branch[1]))
}
}
if path == ".git/config" {
if path == ".git/config" || path == ".git/config.worktree" {
cfg, err := ini.Load(content)
if err != nil {
log.Error().Str("file", targetFile).Err(err).Msg("failed to parse git config")
@ -126,7 +126,7 @@ func FindRefWorker(jt *jobtracker.JobTracker, path string, context jobtracker.Co
jt.AddJob(fmt.Sprintf(".git/logs/refs/remotes/origin/%s", branch[1]))
}
}
if path == ".git/config" {
if path == ".git/config" || path == ".git/config.worktree" {
cfg, err := ini.Load(body)
if err != nil {
log.Error().Str("file", targetFile).Err(err).Msg("failed to parse git config")

View File

@ -205,8 +205,11 @@ func FetchGit(baseUrl, baseDir string) error {
hashes := packRegex.FindAllSubmatch(infoPacks, -1)
jt = jobtracker.NewJobTracker(workers.DownloadWorker, maxConcurrency, jobtracker.DefaultNapper)
for _, sha1 := range hashes {
jt.AddJob(fmt.Sprintf(".git/objects/pack/pack-%s.idx", sha1[1]))
jt.AddJob(fmt.Sprintf(".git/objects/pack/pack-%s.pack", sha1[1]))
jt.AddJobs(
fmt.Sprintf(".git/objects/pack/pack-%s.idx", sha1[1]),
fmt.Sprintf(".git/objects/pack/pack-%s.pack", sha1[1]),
fmt.Sprintf(".git/objects/pack/pack-%s.rev", sha1[1]),
)
}
jt.StartAndWait(workers.DownloadContext{C: c, BaseUrl: baseUrl, BaseDir: baseDir}, false)
}

View File

@ -35,18 +35,40 @@ var (
".git/index",
".git/info/exclude",
".git/objects/info/packs",
".git/objects/info/alternates", // TODO: parse and process
".git/objects/info/http-alternates", // TODO: parse and process
".git/objects/info/commit-graph", // TODO: parse for object hashes
".git/objects/info/commit-graphs/commit-graph-chain", // TODO: read file and fetch mentioned graph files too, then parse those for object hashes
".git/info/grafts", // TODO: parse and process
".git/info/attributes", // TODO: can lfs filters be in here?
".git/info/sparse-checkout", // TODO: parse and process
".git/objects/loose-object-idx", // TODO: parse and process
".git/objects/pack/multi-pack-index", // TODO: parse and process
}
commonRefs = []string{
".git/FETCH_HEAD",
".git/HEAD",
".git/ORIG_HEAD",
".git/config",
".git/config.worktree",
".git/info/refs",
".git/logs/HEAD",
".git/logs/refs/heads/master",
".git/logs/refs/heads/main",
".git/logs/refs/heads/dev",
".git/logs/refs/heads/develop",
".git/logs/refs/tags/alpha",
".git/logs/refs/tags/beta",
".git/logs/refs/tags/stable",
".git/logs/refs/tags/release",
".git/logs/refs/tags/1.0",
".git/logs/refs/tags/1.0.0",
".git/logs/refs/tags/2.0",
".git/logs/refs/tags/2.0.0",
".git/logs/refs/tags/v1.0",
".git/logs/refs/tags/v1.0.0",
".git/logs/refs/tags/v2.0",
".git/logs/refs/tags/v2.0.0",
".git/logs/refs/remotes/origin/HEAD",
".git/logs/refs/remotes/origin/master",
".git/logs/refs/remotes/origin/main",
@ -58,6 +80,18 @@ var (
".git/refs/heads/main",
".git/refs/heads/dev",
".git/refs/heads/develop",
".git/refs/tags/alpha",
".git/refs/tags/beta",
".git/refs/tags/stable",
".git/refs/tags/release",
".git/refs/tags/1.0",
".git/refs/tags/1.0.0",
".git/refs/tags/2.0",
".git/refs/tags/2.0.0",
".git/refs/tags/v1.0",
".git/refs/tags/v1.0.0",
".git/refs/tags/v2.0",
".git/refs/tags/v2.0.0",
".git/refs/remotes/origin/HEAD",
".git/refs/remotes/origin/master",
".git/refs/remotes/origin/main",