Skip to content

Commit

Permalink
feat: clone bare repositories without blobs
Browse files Browse the repository at this point in the history
In order to save disk space, make bare clones of repositories filtering
out blobs.
  • Loading branch information
tensor5 committed May 13, 2022
1 parent e216011 commit 00770d2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions crawler/crawler/cloneRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ func CloneRepository(domain Domain, hostname, name, gitURL, index string) error
if err != nil {
return errors.New(fmt.Sprintf("cannot git pull the repository: %s: %s", err.Error(), out))
}
out, err = exec.Command("git", "-C", path, "reset", "--hard", "origin/HEAD").CombinedOutput() // nolint: gas
if err != nil {
return errors.New(fmt.Sprintf("cannot git pull the repository: %s: %s", err.Error(), out))
}

return nil
}

// Clone the repository using the external command "git".
// Command is: git clone -b <branch> <remote_repo>
out, err := exec.Command("git", "clone", gitURL, path).CombinedOutput() // nolint: gas
// Command is: git clone --filter=blob:none --mirror -b <branch> <remote_repo>
out, err := exec.Command("git", "clone", "--filter=blob:none", "--mirror", "-b", gitURL, path).CombinedOutput() // nolint: gas
if err != nil {
return errors.New(fmt.Sprintf("cannot git clone the repository: %s: %s", err.Error(), out))
}
Expand Down

0 comments on commit 00770d2

Please sign in to comment.