mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-18 20:09:26 +00:00
Some fixes of the prompt of new branches (#26257)
Related to #26239 This PR makes some fixes: - do not show the prompt for mirror repos and repos with pull request units disabled - use `commit_time` instead of `updated_unix`, as `commit_time` is the real time when the branch was pushed
This commit is contained in:
parent
b9baed2c74
commit
9a65d011f6
|
@ -395,9 +395,9 @@ func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64, ex
|
||||||
Where("pusher_id=? AND is_deleted=?", userID, false).
|
Where("pusher_id=? AND is_deleted=?", userID, false).
|
||||||
And("name <> ?", excludeBranchName).
|
And("name <> ?", excludeBranchName).
|
||||||
And("repo_id = ?", repoID).
|
And("repo_id = ?", repoID).
|
||||||
And("updated_unix >= ?", time.Now().Add(-time.Hour*6).Unix()).
|
And("commit_time >= ?", time.Now().Add(-time.Hour*6).Unix()).
|
||||||
NotIn("name", subQuery).
|
NotIn("name", subQuery).
|
||||||
OrderBy("branch.updated_unix DESC").
|
OrderBy("branch.commit_time DESC").
|
||||||
Limit(2).
|
Limit(2).
|
||||||
Find(&branches)
|
Find(&branches)
|
||||||
return branches, err
|
return branches, err
|
||||||
|
|
|
@ -999,10 +999,18 @@ func renderCode(ctx *context.Context) {
|
||||||
ctx.ServerError("GetBaseRepo", err)
|
ctx.ServerError("GetBaseRepo", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID, ctx.Repo.Repository.DefaultBranch)
|
|
||||||
if err != nil {
|
showRecentlyPushedNewBranches := true
|
||||||
ctx.ServerError("GetRecentlyPushedBranches", err)
|
if ctx.Repo.Repository.IsMirror ||
|
||||||
return
|
!ctx.Repo.Repository.UnitEnabled(ctx, unit_model.TypePullRequests) {
|
||||||
|
showRecentlyPushedNewBranches = false
|
||||||
|
}
|
||||||
|
if showRecentlyPushedNewBranches {
|
||||||
|
ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID, ctx.Repo.Repository.DefaultBranch)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetRecentlyPushedBranches", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{range .RecentlyPushedNewBranches}}
|
{{range .RecentlyPushedNewBranches}}
|
||||||
<div class="ui positive message gt-df gt-ac">
|
<div class="ui positive message gt-df gt-ac">
|
||||||
<div class="gt-f1">
|
<div class="gt-f1">
|
||||||
{{$timeSince := TimeSince .UpdatedUnix.AsTime $.locale}}
|
{{$timeSince := TimeSince .CommitTime.AsTime $.locale}}
|
||||||
{{$.locale.Tr "repo.pulls.recently_pushed_new_branches" (PathEscapeSegments .Name) $timeSince | Safe}}
|
{{$.locale.Tr "repo.pulls.recently_pushed_new_branches" (PathEscapeSegments .Name) $timeSince | Safe}}
|
||||||
</div>
|
</div>
|
||||||
<a aria-role="button" class="ui compact positive button gt-m-0" href="{{$.Repository.ComposeBranchCompareURL $.Repository.BaseRepo (PathEscapeSegments .Name)}}">
|
<a aria-role="button" class="ui compact positive button gt-m-0" href="{{$.Repository.ComposeBranchCompareURL $.Repository.BaseRepo (PathEscapeSegments .Name)}}">
|
||||||
|
|
Loading…
Reference in a new issue