diff options
Diffstat (limited to '')
-rw-r--r-- | http_handle_repo_contrib_one.go | 10 | ||||
-rw-r--r-- | templates/repo_contrib_one.tmpl | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/http_handle_repo_contrib_one.go b/http_handle_repo_contrib_one.go index 9810d5d..7ed0d6f 100644 --- a/http_handle_repo_contrib_one.go +++ b/http_handle_repo_contrib_one.go @@ -68,7 +68,15 @@ func handle_repo_contrib_one(w http.ResponseWriter, r *http.Request, params map[ } params["destination_commit"] = destination_commit - patch, err := destination_commit.Patch(source_commit) + merge_bases, err := source_commit.MergeBase(destination_commit) + if err != nil { + http.Error(w, "Error getting merge base: "+err.Error(), http.StatusInternalServerError) + return + } + merge_base := merge_bases[0] + params["merge_base"] = merge_base + + patch, err := merge_base.Patch(source_commit) if err != nil { http.Error(w, "Error getting patch: "+err.Error(), http.StatusInternalServerError) return diff --git a/templates/repo_contrib_one.tmpl b/templates/repo_contrib_one.tmpl index dca8a8f..1083e8c 100644 --- a/templates/repo_contrib_one.tmpl +++ b/templates/repo_contrib_one.tmpl @@ -39,11 +39,15 @@ <th scope="row">Destination branch</th> <td>{{ .mr_destination_branch }}</td> </tr> + <tr> + <th scope="row">Merge base</th> + <td>{{ .merge_base.ID.String }}</td> + </tr> </tbody> </table> </div> <div class="padding-wrapper"> - {{ $destination_commit := .destination_commit }} + {{ $merge_base := .merge_base }} {{ $source_commit := .source_commit }} {{ range .file_patches }} <div class="file-patch toggle-on-wrapper"> @@ -53,7 +57,7 @@ {{ if eq .From.Path "" }} --- /dev/null {{ else }} - --- a/<a href="../../tree/{{ .From.Path }}?commit={{ $destination_commit.Hash }}">{{ .From.Path }}</a> {{ .From.Mode }} + --- a/<a href="../../tree/{{ .From.Path }}?commit={{ $merge_base.Hash }}">{{ .From.Path }}</a> {{ .From.Mode }} {{ end }} <br /> {{ if eq .To.Path "" }} |