Skip to content

Commit 7e9bd20

Browse files
axifive6543gwymor
authored
Fix bundle creation (#17079)
Signed-off-by: Alexey Terentyev <axifnx@gmail.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Gwyneth Morgan <87623694+gwymor@users.noreply.github.com> Co-authored-by: Gwyneth Morgan <gwymor@tilde.club>
1 parent 58d8183 commit 7e9bd20

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

modules/git/repo.go

+17-7
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,24 @@ func (repo *Repository) CreateBundle(ctx context.Context, commit string, out io.
425425
}
426426
defer os.RemoveAll(tmp)
427427

428-
tmpFile := filepath.Join(tmp, "bundle")
429-
args := []string{
430-
"bundle",
431-
"create",
432-
tmpFile,
433-
commit,
428+
env := append(os.Environ(), "GIT_OBJECT_DIRECTORY="+filepath.Join(repo.Path, "objects"))
429+
_, err = NewCommandContext(ctx, "init", "--bare").RunInDirWithEnv(tmp, env)
430+
if err != nil {
431+
return err
432+
}
433+
434+
_, err = NewCommandContext(ctx, "reset", "--soft", commit).RunInDirWithEnv(tmp, env)
435+
if err != nil {
436+
return err
434437
}
435-
_, err = NewCommandContext(ctx, args...).RunInDir(repo.Path)
438+
439+
_, err = NewCommandContext(ctx, "branch", "-m", "bundle").RunInDirWithEnv(tmp, env)
440+
if err != nil {
441+
return err
442+
}
443+
444+
tmpFile := filepath.Join(tmp, "bundle")
445+
_, err = NewCommandContext(ctx, "bundle", "create", tmpFile, "bundle", "HEAD").RunInDirWithEnv(tmp, env)
436446
if err != nil {
437447
return err
438448
}

services/archiver/archiver.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
136136
if err == nil {
137137
if archiver.Status == models.RepoArchiverGenerating {
138138
archiver.Status = models.RepoArchiverReady
139-
return archiver, models.UpdateRepoArchiverStatus(ctx, archiver)
139+
if err = models.UpdateRepoArchiverStatus(ctx, archiver); err != nil {
140+
return nil, err
141+
}
140142
}
141-
return archiver, nil
143+
return archiver, committer.Commit()
142144
}
143145

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

0 commit comments

Comments
 (0)