agit flow hook refuses forced pushes #7689

Closed
opened 2025-11-02 07:33:41 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf on GitHub (Aug 12, 2021).

  • Gitea version (or commit ref): Gitea version 1.16.0+dev-96-gf1a810e09 built with GNU Make 4.3, go1.16.7 : netgo, osusergo, bindata, sqlite, sqlite_unlock_notify

  • Git version: 2.33.0.rc0.290.g2c90b51f76

  • Operating system: Arch Linux

  • Built from: source

  • Run with: systemd

  • Database:

    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:

    • I have not tried yet, I don't see why it wouldn't work in a fresh repo like I tried it with...
  • Log gist:

    • TBD

Description

First off, I appreciate this feature (implemented recently in #14295), it is really handy (I didn't know about agit flow before btw).

I have run into an issue when force pushing an update into a PR while doing this agit flow stuff (after initially opening the PR using this method).
The force push was then refused by Gitea (a git hook).
The command used was git push --force HEAD:refs/for/whatever-the-branch-was -o topic=topic-name if I recall correctly.
EDIT: this was a typo here, I meant to say I pushed the HEAD ref, not "HEADS".

Note that

  • branch protection has not been enabled in this particular instance,
  • repo hooks have been reinitialized as per the subject PR request (it was noted somewhere there).

I cannot tell whether that is intended behaviour or not, i.e. whether I even ought to try to force push in agit flow or not.

Originally created by @wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf on GitHub (Aug 12, 2021). - Gitea version (or commit ref): `Gitea version 1.16.0+dev-96-gf1a810e09 built with GNU Make 4.3, go1.16.7 : netgo, osusergo, bindata, sqlite, sqlite_unlock_notify` - Git version: `2.33.0.rc0.290.g2c90b51f76` - Operating system: `Arch Linux` - Built from: `source` - Run with: `systemd` - Database: - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] I have not tried yet, I don't see why it wouldn't work in a fresh repo like I tried it with... - Log gist: - [ ] TBD ## Description First off, I appreciate this feature (implemented recently in #14295), it is really handy (I didn't know about agit flow before btw). I have run into an issue when force pushing an update into a PR while doing this agit flow stuff (after initially opening the PR using this method). The force push was then refused by Gitea (a git hook). The command used was `git push --force HEAD:refs/for/whatever-the-branch-was -o topic=topic-name` if I recall correctly. EDIT: this was a typo here, I meant to say I pushed the `HEAD` ref, not "`HEADS`". Note that * branch protection has not been enabled in this particular instance, * repo hooks have been reinitialized as per the subject PR request (it was noted somewhere there). I cannot tell whether that is intended behaviour or not, i.e. whether I even ought to try to force push in agit flow or not.
GiteaMirror added the type/enhancement label 2025-11-02 07:33:41 -06:00
Author
Owner

@lunny commented on GitHub (Aug 13, 2021):

@a1012112796 Maybe you can take a look.

@lunny commented on GitHub (Aug 13, 2021): @a1012112796 Maybe you can take a look.
Author
Owner

@zeripath commented on GitHub (Aug 13, 2021):

I think this is similar to the problem seen here https://github.com/go-gitea/gitea/issues/15373#issuecomment-898729133

I'm suspicious that might be some weird regression or interaction with #15629.

@zeripath commented on GitHub (Aug 13, 2021): I think this is similar to the problem seen here https://github.com/go-gitea/gitea/issues/15373#issuecomment-898729133 I'm suspicious that might be some weird regression or interaction with #15629.
Author
Owner

@wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf commented on GitHub (Aug 13, 2021):

I think this is similar to the problem seen here #15373 (comment)

I'm suspicious that might be some weird regression or interaction with #15629.

oh bugger 🙈

@wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf commented on GitHub (Aug 13, 2021): > I think this is similar to the problem seen here [#15373 (comment)](https://github.com/go-gitea/gitea/issues/15373#issuecomment-898729133) > > I'm suspicious that might be some weird regression or interaction with #15629. oh bugger 🙈
Author
Owner

@a1012112796 commented on GitHub (Aug 14, 2021):

Sorry, because can't get --force option in git hook, I use a push option to check if user want to force push
example:

git push -o force-push=true ...

ref:
23a87a003e/services/agit/agit.go (L39)

@a1012112796 commented on GitHub (Aug 14, 2021): Sorry, because can't get ``--force`` option in git hook, I use a push option to check if user want to force push example: ```SHELL git push -o force-push=true ... ``` ref: https://github.com/go-gitea/gitea/blob/23a87a003eb2b592ad5295f73d8d52d3f24069c6/services/agit/agit.go#L39
Author
Owner

@lunny commented on GitHub (Aug 14, 2021):

@a1012112796 could you use https://github.com/go-gitea/gitea/blob/main/modules/repository/push.go#L101 to detect it?

@lunny commented on GitHub (Aug 14, 2021): @a1012112796 could you use https://github.com/go-gitea/gitea/blob/main/modules/repository/push.go#L101 to detect it?
Author
Owner

@a1012112796 commented on GitHub (Aug 14, 2021):

@a1012112796 could you use https://github.com/go-gitea/gitea/blob/main/modules/repository/push.go#L101 to detect it?

They are same, ref:
23a87a003e/services/agit/agit.go (L206-L223)

I means to check if user make sure they want to force push, like the usage of --force.

@a1012112796 commented on GitHub (Aug 14, 2021): > @a1012112796 could you use https://github.com/go-gitea/gitea/blob/main/modules/repository/push.go#L101 to detect it? They are same, ref: https://github.com/go-gitea/gitea/blob/23a87a003eb2b592ad5295f73d8d52d3f24069c6/services/agit/agit.go#L206-L223 I means to check if user make sure they want to force push, like the usage of ``--force``.
Author
Owner

@lunny commented on GitHub (Oct 11, 2024):

Fixed by https://gitea.com/gitea/docs/pulls/78

@lunny commented on GitHub (Oct 11, 2024): Fixed by https://gitea.com/gitea/docs/pulls/78
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7689