mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Handle more pathological branch and tag names (#11843)
* Handle more pathological branch and tag names Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix failing test Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
		@@ -66,7 +66,7 @@ func NewPullRequest(repo *models.Repository, pull *models.Issue, labelIDs []int6
 | 
			
		||||
	defer baseGitRepo.Close()
 | 
			
		||||
 | 
			
		||||
	compareInfo, err := baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(),
 | 
			
		||||
		pr.BaseBranch, pr.GetGitRefName())
 | 
			
		||||
		git.BranchPrefix+pr.BaseBranch, pr.GetGitRefName())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -100,7 +100,7 @@ func createTemporaryRepo(pr *models.PullRequest) (string, error) {
 | 
			
		||||
	outbuf.Reset()
 | 
			
		||||
	errbuf.Reset()
 | 
			
		||||
 | 
			
		||||
	if err := git.NewCommand("fetch", "origin", "--no-tags", pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
 | 
			
		||||
	if err := git.NewCommand("fetch", "origin", "--no-tags", "--", pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
 | 
			
		||||
		log.Error("Unable to fetch origin base branch [%s:%s -> base, original_base in %s]: %v:\n%s\n%s", pr.BaseRepo.FullName(), pr.BaseBranch, tmpBasePath, err, outbuf.String(), errbuf.String())
 | 
			
		||||
		if err := models.RemoveTemporaryPath(tmpBasePath); err != nil {
 | 
			
		||||
			log.Error("CreateTempRepo: RemoveTemporaryPath: %s", err)
 | 
			
		||||
@@ -140,7 +140,7 @@ func createTemporaryRepo(pr *models.PullRequest) (string, error) {
 | 
			
		||||
 | 
			
		||||
	trackingBranch := "tracking"
 | 
			
		||||
	// Fetch head branch
 | 
			
		||||
	if err := git.NewCommand("fetch", "--no-tags", remoteRepoName, pr.HeadBranch+":"+trackingBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
 | 
			
		||||
	if err := git.NewCommand("fetch", "--no-tags", remoteRepoName, git.BranchPrefix+pr.HeadBranch+":"+trackingBranch).RunInDirPipeline(tmpBasePath, &outbuf, &errbuf); err != nil {
 | 
			
		||||
		log.Error("Unable to fetch head_repo head branch [%s:%s -> tracking in %s]: %v:\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, tmpBasePath, err, outbuf.String(), errbuf.String())
 | 
			
		||||
		if err := models.RemoveTemporaryPath(tmpBasePath); err != nil {
 | 
			
		||||
			log.Error("CreateTempRepo: RemoveTemporaryPath: %s", err)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user