Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: clone bare repositories without blobs #269

Merged
merged 2 commits into from
May 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions crawler/crawler/cloneRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,14 @@ func CloneRepository(domain Domain, hostname, name, gitURL, index string) error

// If folder already exists it will do a fetch instead of a clone.
if _, err := os.Stat(path); !os.IsNotExist(err) {
// Command is: git fetch --all
out, err := exec.Command("git", "-C", path, "fetch", "--all").CombinedOutput() // nolint: gas
tensor5 marked this conversation as resolved.
Show resolved Hide resolved
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
bfabio marked this conversation as resolved.
Show resolved Hide resolved
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
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