mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 14:31:02 +00:00 
			
		
		
		
	Expand code diffs against the commits repo
When expanding code diffs, the expansion should search for more context in the commits repo, rather than in the repo in context, because the commit may not be available in the base repo. For example, when previewing a pull request, the commit is not in the target repo yet - it's in the fork. Fixes #3746. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
		
					parent
					
						
							
								2810b9ae0a
							
						
					
				
			
			
				commit
				
					
						220c3fe3b3
					
				
			
		
					 3 changed files with 49 additions and 6 deletions
				
			
		|  | @ -18,17 +18,17 @@ | |||
| 					<td class="lines-num lines-num-old"> | ||||
| 						<div class="tw-flex"> | ||||
| 						{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} | ||||
| 							<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 							<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.CommitRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold-down"}} | ||||
| 							</button> | ||||
| 						{{end}} | ||||
| 						{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} | ||||
| 							<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 							<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.CommitRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold-up"}} | ||||
| 							</button> | ||||
| 						{{end}} | ||||
| 						{{if eq $line.GetExpandDirection 2}} | ||||
| 							<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 							<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.CommitRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold"}} | ||||
| 							</button> | ||||
| 						{{end}} | ||||
|  |  | |||
|  | @ -14,17 +14,17 @@ | |||
| 					<td colspan="2" class="lines-num"> | ||||
| 						<div class="tw-flex"> | ||||
| 							{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} | ||||
| 								<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.CommitRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 									{{svg "octicon-fold-down"}} | ||||
| 								</button> | ||||
| 							{{end}} | ||||
| 							{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} | ||||
| 								<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.CommitRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 									{{svg "octicon-fold-up"}} | ||||
| 								</button> | ||||
| 							{{end}} | ||||
| 							{{if eq $line.GetExpandDirection 2}} | ||||
| 								<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.CommitRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 									{{svg "octicon-fold"}} | ||||
| 								</button> | ||||
| 							{{end}} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue