mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-30 22:11:07 +00:00 
			
		
		
		
	[BUG] Allow 4 charachter SHA in /src/commit
		
	- Adjust the `RepoRefByType` middleware to allow for commit SHAs that are as short as 4 characters (the minium that Git requires). - Integration test added. - Follow up to4d76bbeda7- Resolves #4781 (cherry picked from commitb967fce25d)
This commit is contained in:
		
					parent
					
						
							
								6df8b97344
							
						
					
				
			
			
				commit
				
					
						57cb5eaf41
					
				
			
		
					 2 changed files with 9 additions and 2 deletions
				
			
		|  | @ -897,7 +897,7 @@ func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string { | |||
| 	case RepoRefCommit: | ||||
| 		parts := strings.Split(path, "/") | ||||
| 
 | ||||
| 		if len(parts) > 0 && len(parts[0]) >= 7 && len(parts[0]) <= repo.GetObjectFormat().FullLength() { | ||||
| 		if len(parts) > 0 && len(parts[0]) >= 4 && len(parts[0]) <= repo.GetObjectFormat().FullLength() { | ||||
| 			repo.TreePath = strings.Join(parts[1:], "/") | ||||
| 			return parts[0] | ||||
| 		} | ||||
|  | @ -1021,7 +1021,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context | |||
| 					return cancel | ||||
| 				} | ||||
| 				ctx.Repo.CommitID = ctx.Repo.Commit.ID.String() | ||||
| 			} else if len(refName) >= 7 && len(refName) <= ctx.Repo.GetObjectFormat().FullLength() { | ||||
| 			} else if len(refName) >= 4 && len(refName) <= ctx.Repo.GetObjectFormat().FullLength() { | ||||
| 				ctx.Repo.IsViewCommit = true | ||||
| 				ctx.Repo.CommitID = refName | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue