mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 06:21:11 +00:00 
			
		
		
		
	Backport #23372
Fix #23357 .
Now the `/repos/{owner}/{repo}/git/notes/{sha}` API supports getting
notes by a ref or sha
(https://try.gitea.io/api/swagger#/repository/repoGetNote). But the
`GetNote` func can only accept commit ID.
a12f575737/modules/git/notes_nogogit.go (L18)
So we need to convert the query parameter to commit ID before calling
`GetNote`.
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
	
	
This commit is contained in:
		
					parent
					
						
							
								2ba58fab22
							
						
					
				
			
			
				commit
				
					
						54c674c936
					
				
			
		
					 1 changed files with 11 additions and 1 deletions
				
			
		|  | @ -58,8 +58,18 @@ func getNote(ctx *context.APIContext, identifier string) { | |||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	commitSHA, err := ctx.Repo.GitRepo.ConvertToSHA1(identifier) | ||||
| 	if err != nil { | ||||
| 		if git.IsErrNotExist(err) { | ||||
| 			ctx.NotFound(err) | ||||
| 		} else { | ||||
| 			ctx.Error(http.StatusInternalServerError, "ConvertToSHA1", err) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	var note git.Note | ||||
| 	if err := git.GetNote(ctx, ctx.Repo.GitRepo, identifier, ¬e); err != nil { | ||||
| 	if err := git.GetNote(ctx, ctx.Repo.GitRepo, commitSHA.String(), ¬e); err != nil { | ||||
| 		if git.IsErrNotExist(err) { | ||||
| 			ctx.NotFound(identifier) | ||||
| 			return | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue