Skip to content
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

Merged
merged 13 commits into from
Mar 6, 2024
Merged

Conversation

wolfogre
Copy link
Member

@wolfogre wolfogre commented Feb 29, 2024

Detect broken git hooks by checking if the commit id of branches in DB is the same with the git repo.

It can help #29338 #28277 and maybe more issues.

Users could complain about actions, webhooks, and activities not working, but they were not aware that it is caused by broken git hooks unless they could see a warning.

image

It should be merged after #29493. Otherwise, users could see a ephemeral warning after committing and opening the repo home page immediately.

And it also waits for #29495, since the doc link (the anchor part) will be updated.

@wolfogre wolfogre added the type/enhancement An improvement of existing functionality label Feb 29, 2024
@wolfogre wolfogre added this to the 1.22.0 milestone Feb 29, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 29, 2024
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 29, 2024
@wolfogre wolfogre marked this pull request as draft February 29, 2024 11:04
@wolfogre wolfogre marked this pull request as ready for review February 29, 2024 11:05
@@ -2591,6 +2591,7 @@ find_file.no_matching = No matching file found
error.csv.too_large = Can't render this file because it is too large.
error.csv.unexpected = Can't render this file because it contains an unexpected character in line %d and column %d.
error.csv.invalid_field_count = Can't render this file because it has a wrong number of fields in line %d.
error.broken_git_hook = Git hooks of this repository seem to be broken. Please follow the <a target="_blank" rel="noreferrer" href="https://docs.gitea.com/help/faq#push-hook--webhook-arent-running">documentation</a> to fix them, then push some commits to refresh the status.
Copy link
Member

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.

Copy link
Contributor

@wxiaoguang wxiaoguang Feb 29, 2024

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 ....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> #29500

Copy link
Member Author

@wolfogre wolfogre Mar 1, 2024

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.

Copy link
Member Author

@wolfogre wolfogre Mar 1, 2024

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:

  • "Please follow the %s to fix them": it has missed the word "documentation".
  • "Please follow the %[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.

@@ -1072,6 +1074,27 @@ func renderHomeCode(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplRepoHome)
}

func checkOutdatedBranch(ctx *context.Context) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkGitHooksAreWorking?

Copy link
Member Author

@wolfogre wolfogre Mar 1, 2024

Choose a reason for hiding this comment

The 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.

wxiaoguang
wxiaoguang previously approved these changes Mar 1, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 1, 2024
@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 1, 2024
@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 1, 2024
routers/web/repo/view.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 1, 2024
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 1, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 4, 2024
lunny
lunny previously requested changes Mar 5, 2024
Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depends on #29493

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Mar 5, 2024
wolfogre added a commit that referenced this pull request Mar 6, 2024
Unlike other async processing in the queue, we should sync branches to
the DB immediately when handling git hook calling. If it fails, users
can see the error message in the output of the git command.

It can avoid potential inconsistency issues, and help #29494.

---------

Co-authored-by: Lunny Xiao <[email protected]>
@wolfogre wolfogre dismissed lunny’s stale review March 6, 2024 08:49

#29493 has been merged now.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Mar 6, 2024
@wolfogre wolfogre added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 6, 2024
@silverwind silverwind enabled auto-merge (squash) March 6, 2024 09:14
@silverwind silverwind merged commit a4bcfb8 into go-gitea:main Mar 6, 2024
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 6, 2024
silverwind added a commit to silverwind/gitea that referenced this pull request Mar 6, 2024
* origin/main: (29 commits)
  Tweak actions color and borders (go-gitea#29640)
  Add download URL for executable files (go-gitea#28260)
  Move all login and account creation page labels to be above inputs (go-gitea#29432)
  Avoid issue info panic (go-gitea#29625)
  Cache repository default branch commit status to reduce query on commit status table (go-gitea#29444)
  Avoid unexpected panic in graceful manager (go-gitea#29629)
  Add a link for the recently pushed branch notification (go-gitea#29627)
  Fix wrong header of org project view page (go-gitea#29626)
  Detect broken git hooks (go-gitea#29494)
  Sync branches to DB immediately when handle git hook calling (go-gitea#29493)
  Fix wrong line number in code search result (go-gitea#29260)
  Make wiki default branch name changable (go-gitea#29603)
  A small refactor for agit implementation (go-gitea#29614)
  Update Twitter Logo (go-gitea#29621)
  Fix 500 error when adding PR comment (go-gitea#29622)
  Run editorconfig-checker on `locale_en-US.ini` (go-gitea#29608)
  bump protobuf module (go-gitea#29617)
  Add ac claim for old docker/build-push-action@v3 / current buildx gha cache (go-gitea#29584)
  Skip email domain check when admins edit user emails (go-gitea#29609)
  Improve natural sort (go-gitea#29611)
  ...
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 7, 2024
* giteaofficial/main:
  Use strict protocol check when redirect (go-gitea#29642)
  Update various logos and unify their filenames (go-gitea#29637)
  Tweak actions color and borders (go-gitea#29640)
  Add download URL for executable files (go-gitea#28260)
  Move all login and account creation page labels to be above inputs (go-gitea#29432)
  Avoid issue info panic (go-gitea#29625)
  Cache repository default branch commit status to reduce query on commit status table (go-gitea#29444)
  Avoid unexpected panic in graceful manager (go-gitea#29629)
  Add a link for the recently pushed branch notification (go-gitea#29627)
  Fix wrong header of org project view page (go-gitea#29626)
  Detect broken git hooks (go-gitea#29494)
  Sync branches to DB immediately when handle git hook calling (go-gitea#29493)
  Fix wrong line number in code search result (go-gitea#29260)
  Make wiki default branch name changable (go-gitea#29603)
  A small refactor for agit implementation (go-gitea#29614)
  Update Twitter Logo (go-gitea#29621)
  Fix 500 error when adding PR comment (go-gitea#29622)
@yp05327
Copy link
Contributor

yp05327 commented Mar 11, 2024

The warning message maybe not good enough.
Not only git hook broken but also DB data broken will see this error.
If DB data was broken, the provided doc doesn't do anything to help.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/translation size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants