-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect broken git hooks #29494
Detect broken git hooks #29494
Changes from 7 commits
baf7515
ae44e3f
4a8bbde
0a02897
5068c8a
0f04a69
0a1eb84
e6652f4
a92d3b8
ac3f6d0
452afc2
797302c
749ce5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1006,6 +1006,8 @@ func renderHomeCode(ctx *context.Context) { | |
return | ||
} | ||
|
||
checkOutdatedBranch(ctx) | ||
|
||
checkCitationFile(ctx, entry) | ||
if ctx.Written() { | ||
return | ||
|
@@ -1072,6 +1074,27 @@ func renderHomeCode(ctx *context.Context) { | |
ctx.HTML(http.StatusOK, tplRepoHome) | ||
} | ||
|
||
func checkOutdatedBranch(ctx *context.Context) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, since it can only say "git hooks seem to be broken", it's also possible for other reasons to cause outdated branches.
wolfogre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// get the head commit of the branch since ctx.Repo.CommitID is not always the head commit of `ctx.Repo.BranchName` | ||
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.BranchName) | ||
if err != nil { | ||
log.Error("GetBranchCommitID: %v", err) | ||
// Don't return an error page, as it can be rechecked the next time the user opens the page. | ||
return | ||
} | ||
|
||
dbBranch, err := git_model.GetBranch(ctx, ctx.Repo.Repository.ID, ctx.Repo.BranchName) | ||
if err != nil { | ||
log.Error("GetBranch: %v", err) | ||
// Don't return an error page, as it can be rechecked the next time the user opens the page. | ||
return | ||
} | ||
|
||
if dbBranch.CommitID != commit.ID.String() { | ||
ctx.Flash.Warning(ctx.Tr("repo.error.broken_git_hook"), true) | ||
} | ||
} | ||
|
||
// RenderUserCards render a page show users according the input template | ||
func RenderUserCards(ctx *context.Context, total int, getter func(opts db.ListOptions) ([]*user_model.User, error), tpl base.TplName) { | ||
page := ctx.FormInt("page") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer including the link as translation parameter instead of hardcoded, i.e. to be able to easily change it when the link changes, and to prevent translation errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, there is a longstanding problem: non-English translation would (might) NEVER be updated ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> #29500
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can leave it to #29500, and follow the current way of other translations for now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about 452afc2.
Why "Please follow the
<a target="_blank" rel="noreferrer" href="%s">documentation</a>
to fix them" instead of:%s
to fix them": it has missed the word "documentation".%[1]sdocumentation%[2]s
to fix them": it could be very difficult for translators to understand what it is unless they have read the code.