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 5, 2022
1 parent e20520c commit 884e6fd
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, gitBranch, index str
if err != nil {
return errors.New(fmt.Sprintf("cannot git pull the repository: %s: %s", err.Error(), out))
}
// Command is: git reset --hard origin/<branch_name>
out, err = exec.Command("git", "-C", path, "reset", "--hard", "origin/"+gitBranch).CombinedOutput() // nolint: gas
if err != nil {
return errors.New(fmt.Sprintf("cannot git pull the repository: %s: %s", err.Error(), out))
}
return err
}

// Clone the repository using the external command "git".
// Command is: git clone -b <branch> <remote_repo>
out, err := exec.Command("git", "clone", "-b", gitBranch, 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", gitBranch, 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 884e6fd

Please sign in to comment.