Skip to content

Commit

Permalink
cmd/release: unshallow repositories
Browse files Browse the repository at this point in the history
If the repository is shallowed, we need to unshallow it in order to
generate the post release PR properly.

Signed-off-by: André Martins <[email protected]>
  • Loading branch information
aanm committed Sep 5, 2024
1 parent d7b7c63 commit 19fafa9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/release/post-release.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,21 @@ func (pc *PostRelease) Run(ctx context.Context, yesToPrompt, dryRun bool, ghClie
remoteBranch := fmt.Sprintf("%s/%s", remoteName, branch)

// Pull docker manifests from RUN URL
_, err = execCommand(pc.cfg.RepoDirectory, "git", "fetch", "-q", remoteName)
shallowRepo, err := isShallowRepo(pc.cfg.RepoDirectory)
if err != nil {
return err
io2.Fprintf(3, os.Stdout, "Unable to detect if repository is shallow, assuming it's not: %s\n", err)
}
if shallowRepo {
io2.Fprintf(3, os.Stdout, "Fetching and unshallowing repository to generate AUTHORS file properly\n")
_, err = execCommand(pc.cfg.RepoDirectory, "git", "fetch", "-q", "--unshallow", remoteName)
if err != nil {
return err
}
} else {
_, err = execCommand(pc.cfg.RepoDirectory, "git", "fetch", "-q", remoteName)
if err != nil {
return err
}
}

_, err = execCommand(pc.cfg.RepoDirectory, "git", "checkout", "-b", localBranch, remoteBranch)
Expand Down

0 comments on commit 19fafa9

Please sign in to comment.