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

fix: shallow fetch might fail without message if nothing to be fetched #7746

Merged
merged 1 commit into from
Jul 16, 2024
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
9 changes: 6 additions & 3 deletions backend/plugins/gitextractor/parser/clone_gitcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ func (g *GitcliCloner) CloneRepo(ctx plugin.SubTaskContext, localDir string) err
if since != nil {
// fixes error described on https://stackoverflow.com/questions/63878612/git-fatal-error-in-object-unshallow-sha-1
// It might be casued by the commit which being deepen has mulitple parent(e.g. a merge commit), not sure.
if err := g.execGitCommand(ctx, "-C", localDir, "repack", "-d"); err != nil {
if err := g.execGitCommandIn(ctx, localDir, "repack", "-d"); err != nil {
return errors.Default.Wrap(err, "failed to repack the repo")
}
// deepen would fail on a EMPTY repo, ignore the error
if err := g.execGitCommand(ctx, "-C", localDir, "fetch", "--deepen=1"); err != nil {
if err := g.execGitCommandIn(ctx, localDir, "fetch", "--deepen=1"); err != nil {
g.logger.Error(err, "failed to deepen the cloned repo")
}
}
Expand Down Expand Up @@ -141,7 +141,10 @@ func (g *GitcliCloner) execGitCloneCommand(ctx plugin.SubTaskContext, localDir s
}
// 3. fetch all new commits from all branches since the given time
args = append([]string{"fetch", "--progress", fmt.Sprintf("--shallow-since=%s", since.Format(time.RFC3339))}, args...)
return g.execGitCommandIn(ctx, localDir, args...)
if err := g.execGitCommandIn(ctx, localDir, args...); err != nil {
g.logger.Warn(err, "shallow fetch failed")
}
return nil
} else {
args = append([]string{"clone", taskData.Options.Url, localDir, "--progress", "--bare"}, args...)
return g.execGitCommand(ctx, args...)
Expand Down
Loading