Skip to content

Commit

Permalink
Fix bundle creation (#17079)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Terentyev <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: Gwyneth Morgan <[email protected]>
Co-authored-by: Gwyneth Morgan <[email protected]>
  • Loading branch information
4 people authored Sep 25, 2021
1 parent 58d8183 commit 7e9bd20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
24 changes: 17 additions & 7 deletions modules/git/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,24 @@ func (repo *Repository) CreateBundle(ctx context.Context, commit string, out io.
}
defer os.RemoveAll(tmp)

tmpFile := filepath.Join(tmp, "bundle")
args := []string{
"bundle",
"create",
tmpFile,
commit,
env := append(os.Environ(), "GIT_OBJECT_DIRECTORY="+filepath.Join(repo.Path, "objects"))
_, err = NewCommandContext(ctx, "init", "--bare").RunInDirWithEnv(tmp, env)
if err != nil {
return err
}

_, err = NewCommandContext(ctx, "reset", "--soft", commit).RunInDirWithEnv(tmp, env)
if err != nil {
return err
}
_, err = NewCommandContext(ctx, args...).RunInDir(repo.Path)

_, err = NewCommandContext(ctx, "branch", "-m", "bundle").RunInDirWithEnv(tmp, env)
if err != nil {
return err
}

tmpFile := filepath.Join(tmp, "bundle")
_, err = NewCommandContext(ctx, "bundle", "create", tmpFile, "bundle", "HEAD").RunInDirWithEnv(tmp, env)
if err != nil {
return err
}
Expand Down
6 changes: 4 additions & 2 deletions services/archiver/archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
if err == nil {
if archiver.Status == models.RepoArchiverGenerating {
archiver.Status = models.RepoArchiverReady
return archiver, models.UpdateRepoArchiverStatus(ctx, archiver)
if err = models.UpdateRepoArchiverStatus(ctx, archiver); err != nil {
return nil, err
}
}
return archiver, nil
return archiver, committer.Commit()
}

if !errors.Is(err, os.ErrNotExist) {
Expand Down

0 comments on commit 7e9bd20

Please sign in to comment.