mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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>
This commit is contained in:
		@@ -425,14 +425,24 @@ func (repo *Repository) CreateBundle(ctx context.Context, commit string, out io.
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	defer os.RemoveAll(tmp)
 | 
						defer os.RemoveAll(tmp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tmpFile := filepath.Join(tmp, "bundle")
 | 
						env := append(os.Environ(), "GIT_OBJECT_DIRECTORY="+filepath.Join(repo.Path, "objects"))
 | 
				
			||||||
	args := []string{
 | 
						_, err = NewCommandContext(ctx, "init", "--bare").RunInDirWithEnv(tmp, env)
 | 
				
			||||||
		"bundle",
 | 
						if err != nil {
 | 
				
			||||||
		"create",
 | 
							return err
 | 
				
			||||||
		tmpFile,
 | 
					 | 
				
			||||||
		commit,
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	_, err = NewCommandContext(ctx, args...).RunInDir(repo.Path)
 | 
					
 | 
				
			||||||
 | 
						_, err = NewCommandContext(ctx, "reset", "--soft", commit).RunInDirWithEnv(tmp, env)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, 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 {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -136,9 +136,11 @@ func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
 | 
				
			|||||||
	if err == nil {
 | 
						if err == nil {
 | 
				
			||||||
		if archiver.Status == models.RepoArchiverGenerating {
 | 
							if archiver.Status == models.RepoArchiverGenerating {
 | 
				
			||||||
			archiver.Status = models.RepoArchiverReady
 | 
								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) {
 | 
						if !errors.Is(err, os.ErrNotExist) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user