mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	[API] Pull Requests (#248)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							d7ed78a919
						
					
				
				
					commit
					0f05470cb8
				
			@@ -8,6 +8,7 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/git"
 | 
			
		||||
	"code.gitea.io/gitea/models"
 | 
			
		||||
	"code.gitea.io/gitea/modules/base"
 | 
			
		||||
	"code.gitea.io/gitea/modules/log"
 | 
			
		||||
@@ -103,3 +104,24 @@ func ExtractOwnerAndRepo() macaron.Handler {
 | 
			
		||||
		ctx.Data["Repository"] = repo
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ReferencesGitRepo injects the GitRepo into the Context
 | 
			
		||||
func ReferencesGitRepo() macaron.Handler {
 | 
			
		||||
	return func(ctx *APIContext) {
 | 
			
		||||
		// Empty repository does not have reference information.
 | 
			
		||||
		if ctx.Repo.Repository.IsBare {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// For API calls.
 | 
			
		||||
		if ctx.Repo.GitRepo == nil {
 | 
			
		||||
			repoPath := models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
 | 
			
		||||
			gitRepo, err := git.OpenRepository(repoPath)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				ctx.Error(500, "RepoRef Invalid repo "+repoPath, err)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			ctx.Repo.GitRepo = gitRepo
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user