mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 10:56:10 +01:00 
			
		
		
		
	fix #2002
This commit is contained in:
		| @@ -166,43 +166,49 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error | |||||||
|  |  | ||||||
| 	var stderr string | 	var stderr string | ||||||
| 	if _, stderr, err = process.ExecTimeout(5*time.Minute, | 	if _, stderr, err = process.ExecTimeout(5*time.Minute, | ||||||
| 		fmt.Sprintf("PullRequest.Merge(git clone): %s", tmpBasePath), | 		fmt.Sprintf("PullRequest.Merge (git clone): %s", tmpBasePath), | ||||||
| 		"git", "clone", baseGitRepo.Path, tmpBasePath); err != nil { | 		"git", "clone", baseGitRepo.Path, tmpBasePath); err != nil { | ||||||
| 		return fmt.Errorf("git clone: %s", stderr) | 		return fmt.Errorf("git clone: %s", stderr) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Check out base branch. | 	// Check out base branch. | ||||||
| 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | ||||||
| 		fmt.Sprintf("PullRequest.Merge(git checkout): %s", tmpBasePath), | 		fmt.Sprintf("PullRequest.Merge (git checkout): %s", tmpBasePath), | ||||||
| 		"git", "checkout", pr.BaseBranch); err != nil { | 		"git", "checkout", pr.BaseBranch); err != nil { | ||||||
| 		return fmt.Errorf("git checkout: %s", stderr) | 		return fmt.Errorf("git checkout: %s", stderr) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Add head repo remote. | 	// Add head repo remote. | ||||||
| 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | ||||||
| 		fmt.Sprintf("PullRequest.Merge(git remote add): %s", tmpBasePath), | 		fmt.Sprintf("PullRequest.Merge (git remote add): %s", tmpBasePath), | ||||||
| 		"git", "remote", "add", "head_repo", headRepoPath); err != nil { | 		"git", "remote", "add", "head_repo", headRepoPath); err != nil { | ||||||
| 		return fmt.Errorf("git remote add[%s -> %s]: %s", headRepoPath, tmpBasePath, stderr) | 		return fmt.Errorf("git remote add [%s -> %s]: %s", headRepoPath, tmpBasePath, stderr) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Merge commits. | 	// Merge commits. | ||||||
| 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | ||||||
| 		fmt.Sprintf("PullRequest.Merge(git fetch): %s", tmpBasePath), | 		fmt.Sprintf("PullRequest.Merge (git fetch): %s", tmpBasePath), | ||||||
| 		"git", "fetch", "head_repo"); err != nil { | 		"git", "fetch", "head_repo"); err != nil { | ||||||
| 		return fmt.Errorf("git fetch[%s -> %s]: %s", headRepoPath, tmpBasePath, stderr) | 		return fmt.Errorf("git fetch [%s -> %s]: %s", headRepoPath, tmpBasePath, stderr) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | ||||||
| 		fmt.Sprintf("PullRequest.Merge(git merge): %s", tmpBasePath), | 		fmt.Sprintf("PullRequest.Merge (git merge --no-commit): %s", tmpBasePath), | ||||||
| 		"git", "merge", "--no-ff", "-m", | 		"git", "merge", "--no-commit", "head_repo/"+pr.HeadBranch); err != nil { | ||||||
| 		fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch), | 		return fmt.Errorf("git merge --no-commit [%s]: %s", tmpBasePath, stderr) | ||||||
| 		"head_repo/"+pr.HeadBranch); err != nil { | 	} | ||||||
| 		return fmt.Errorf("git merge[%s]: %s", tmpBasePath, stderr) |  | ||||||
|  | 	sig := doer.NewGitSig() | ||||||
|  | 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | ||||||
|  | 		fmt.Sprintf("PullRequest.Merge (git merge): %s", tmpBasePath), | ||||||
|  | 		"git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email), | ||||||
|  | 		"-m", fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch)); err != nil { | ||||||
|  | 		return fmt.Errorf("git commit [%s]: %s", tmpBasePath, stderr) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Push back to upstream. | 	// Push back to upstream. | ||||||
| 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | 	if _, stderr, err = process.ExecDir(-1, tmpBasePath, | ||||||
| 		fmt.Sprintf("PullRequest.Merge(git push): %s", tmpBasePath), | 		fmt.Sprintf("PullRequest.Merge (git push): %s", tmpBasePath), | ||||||
| 		"git", "push", baseGitRepo.Path, pr.BaseBranch); err != nil { | 		"git", "push", baseGitRepo.Path, pr.BaseBranch); err != nil { | ||||||
| 		return fmt.Errorf("git push: %s", stderr) | 		return fmt.Errorf("git push: %s", stderr) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -180,7 +180,7 @@ func DeleteReleaseByID(id int64) error { | |||||||
| 		return fmt.Errorf("RepoPath: %v", err) | 		return fmt.Errorf("RepoPath: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	_, stderr, err := process.ExecDir(-1, repoPath, fmt.Sprintf("Delete release [%d]", rel.ID), | 	_, stderr, err := process.ExecDir(-1, repoPath, fmt.Sprintf("DeleteReleaseByID (git tag -d): %d", rel.ID), | ||||||
| 		"git", "tag", "-d", rel.TagName) | 		"git", "tag", "-d", rel.TagName) | ||||||
| 	if err != nil && !strings.Contains(stderr, "not found") { | 	if err != nil && !strings.Contains(stderr, "not found") { | ||||||
| 		return fmt.Errorf("git tag -d: %v - %s", err, stderr) | 		return fmt.Errorf("git tag -d: %v - %s", err, stderr) | ||||||
|   | |||||||
| @@ -576,20 +576,20 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) { | |||||||
| func initRepoCommit(tmpPath string, sig *git.Signature) (err error) { | func initRepoCommit(tmpPath string, sig *git.Signature) (err error) { | ||||||
| 	var stderr string | 	var stderr string | ||||||
| 	if _, stderr, err = process.ExecDir(-1, | 	if _, stderr, err = process.ExecDir(-1, | ||||||
| 		tmpPath, fmt.Sprintf("initRepoCommit(git add): %s", tmpPath), | 		tmpPath, fmt.Sprintf("initRepoCommit (git add): %s", tmpPath), | ||||||
| 		"git", "add", "--all"); err != nil { | 		"git", "add", "--all"); err != nil { | ||||||
| 		return fmt.Errorf("git add: %s", stderr) | 		return fmt.Errorf("git add: %s", stderr) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if _, stderr, err = process.ExecDir(-1, | 	if _, stderr, err = process.ExecDir(-1, | ||||||
| 		tmpPath, fmt.Sprintf("initRepoCommit(git commit): %s", tmpPath), | 		tmpPath, fmt.Sprintf("initRepoCommit (git commit): %s", tmpPath), | ||||||
| 		"git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email), | 		"git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email), | ||||||
| 		"-m", "initial commit"); err != nil { | 		"-m", "initial commit"); err != nil { | ||||||
| 		return fmt.Errorf("git commit: %s", stderr) | 		return fmt.Errorf("git commit: %s", stderr) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if _, stderr, err = process.ExecDir(-1, | 	if _, stderr, err = process.ExecDir(-1, | ||||||
| 		tmpPath, fmt.Sprintf("initRepoCommit(git push): %s", tmpPath), | 		tmpPath, fmt.Sprintf("initRepoCommit (git push): %s", tmpPath), | ||||||
| 		"git", "push", "origin", "master"); err != nil { | 		"git", "push", "origin", "master"); err != nil { | ||||||
| 		return fmt.Errorf("git push: %s", stderr) | 		return fmt.Errorf("git push: %s", stderr) | ||||||
| 	} | 	} | ||||||
| @@ -700,7 +700,7 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts C | |||||||
| 	// Init bare new repository. | 	// Init bare new repository. | ||||||
| 	os.MkdirAll(repoPath, os.ModePerm) | 	os.MkdirAll(repoPath, os.ModePerm) | ||||||
| 	_, stderr, err := process.ExecDir(-1, repoPath, | 	_, stderr, err := process.ExecDir(-1, repoPath, | ||||||
| 		fmt.Sprintf("initRepository(git init --bare): %s", repoPath), "git", "init", "--bare") | 		fmt.Sprintf("initRepository (git init --bare): %s", repoPath), "git", "init", "--bare") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return fmt.Errorf("git init --bare: %v - %s", err, stderr) | 		return fmt.Errorf("git init --bare: %v - %s", err, stderr) | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user