diff options
author | Alexey 〒erentyev <axifnx@gmail.com> | 2021-09-26 00:29:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 00:29:25 +0300 |
commit | 7e9bd206fd13a34ccdd59dfa8bf5474e5e7f000d (patch) | |
tree | 2bf772fb852175065a003ad664f16bbc23f49687 /modules/git | |
parent | 58d81835e2e78cc218d238c580a58cdd54535b44 (diff) | |
download | gitea-7e9bd206fd13a34ccdd59dfa8bf5474e5e7f000d.tar.gz gitea-7e9bd206fd13a34ccdd59dfa8bf5474e5e7f000d.zip |
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>
Diffstat (limited to 'modules/git')
-rw-r--r-- | modules/git/repo.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/modules/git/repo.go b/modules/git/repo.go index e7d42dacb1..89af7aa9e1 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -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 } |