mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Backport #19010 Use DeployKeyID to replace the IsDeployKey, then CanWriteCode uses the DeployKeyID to check the write permission. Fix #19009 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		@@ -185,7 +185,7 @@ Gitea or set your environment appropriately.`, "")
 | 
			
		||||
	reponame := os.Getenv(models.EnvRepoName)
 | 
			
		||||
	userID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
 | 
			
		||||
	prID, _ := strconv.ParseInt(os.Getenv(models.EnvPRID), 10, 64)
 | 
			
		||||
	isDeployKey, _ := strconv.ParseBool(os.Getenv(models.EnvIsDeployKey))
 | 
			
		||||
	deployKeyID, _ := strconv.ParseInt(os.Getenv(models.EnvDeployKeyID), 10, 64)
 | 
			
		||||
 | 
			
		||||
	hookOptions := private.HookOptions{
 | 
			
		||||
		UserID:                          userID,
 | 
			
		||||
@@ -194,7 +194,7 @@ Gitea or set your environment appropriately.`, "")
 | 
			
		||||
		GitQuarantinePath:               os.Getenv(private.GitQuarantinePath),
 | 
			
		||||
		GitPushOptions:                  pushOptions(),
 | 
			
		||||
		PullRequestID:                   prID,
 | 
			
		||||
		IsDeployKey:                     isDeployKey,
 | 
			
		||||
		DeployKeyID:                     deployKeyID,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	scanner := bufio.NewScanner(os.Stdin)
 | 
			
		||||
 
 | 
			
		||||
@@ -243,7 +243,7 @@ func runServ(c *cli.Context) error {
 | 
			
		||||
	os.Setenv(models.EnvPusherID, strconv.FormatInt(results.UserID, 10))
 | 
			
		||||
	os.Setenv(models.EnvRepoID, strconv.FormatInt(results.RepoID, 10))
 | 
			
		||||
	os.Setenv(models.EnvPRID, fmt.Sprintf("%d", 0))
 | 
			
		||||
	os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey))
 | 
			
		||||
	os.Setenv(models.EnvDeployKeyID, fmt.Sprintf("%d", results.DeployKeyID))
 | 
			
		||||
	os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID))
 | 
			
		||||
	os.Setenv(models.EnvAppURL, setting.AppURL)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user