mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 00:02:59 -04:00 
			
		
		
		
	CreateBranch-hook has shasum. Use the full ref for fetching shasum
This commit is contained in:
		
							parent
							
								
									57dc9efaae
								
							
						
					
					
						commit
						dad806d3ea
					
				| @ -540,6 +540,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { | |||||||
| 
 | 
 | ||||||
| 	apiPusher := pusher.APIFormat() | 	apiPusher := pusher.APIFormat() | ||||||
| 	apiRepo := repo.APIFormat(nil) | 	apiRepo := repo.APIFormat(nil) | ||||||
|  | 
 | ||||||
|  | 	var shaSum string | ||||||
| 	switch opType { | 	switch opType { | ||||||
| 	case ActionCommitRepo: // Push | 	case ActionCommitRepo: // Push | ||||||
| 		if err = PrepareWebhooks(repo, HookEventPush, &api.PushPayload{ | 		if err = PrepareWebhooks(repo, HookEventPush, &api.PushPayload{ | ||||||
| @ -556,8 +558,17 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if isNewBranch { | 		if isNewBranch { | ||||||
|  | 			gitRepo, err := git.OpenRepository(repo.RepoPath()) | ||||||
|  | 			if err != nil { | ||||||
|  | 				log.Error(4, "OpenRepository[%s]: %v", repo.RepoPath(), err) | ||||||
|  | 			} | ||||||
|  | 			shaSum, err = gitRepo.GetBranchCommitID(opts.RefFullName) | ||||||
|  | 			if err != nil { | ||||||
|  | 				log.Error(4, "GetBranchCommitID[%s]: %v", opts.RefFullName, err) | ||||||
|  | 			} | ||||||
| 			return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{ | 			return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{ | ||||||
| 				Ref:     refName, | 				Ref:     refName, | ||||||
|  | 				Sha:     shaSum, | ||||||
| 				RefType: "branch", | 				RefType: "branch", | ||||||
| 				Repo:    apiRepo, | 				Repo:    apiRepo, | ||||||
| 				Sender:  apiPusher, | 				Sender:  apiPusher, | ||||||
| @ -565,7 +576,14 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 	case ActionPushTag: // Create | 	case ActionPushTag: // Create | ||||||
| 		shaSum := git.OpenRepository(repo.RepoPath()).GetTagCommitID(refName) | 		gitRepo, err := git.OpenRepository(repo.RepoPath()) | ||||||
|  | 		if err != nil { | ||||||
|  | 			log.Error(4, "OpenRepository[%s]: %v", repo.RepoPath(), err) | ||||||
|  | 		} | ||||||
|  | 		shaSum, err = gitRepo.GetTagCommitID(opts.RefFullName) | ||||||
|  | 		if err != nil { | ||||||
|  | 			log.Error(4, "GetTagCommitID[%s]: %v", opts.RefFullName, err) | ||||||
|  | 		} | ||||||
| 		return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{ | 		return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{ | ||||||
| 			Ref:     refName, | 			Ref:     refName, | ||||||
| 			Sha:     shaSum, | 			Sha:     shaSum, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user