-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Set PusherName and PusherID to owner on deploy key to fix pushing with deploy keys #5935
Set PusherName and PusherID to owner on deploy key to fix pushing with deploy keys #5935
Conversation
I've initially set the EnvPusherName and EnvPusherID to that of the owner. This is probably a reasonable first step towards mitigating the bug in #3795 however, probably we should probably consider deploy keys slightly differently. |
Codecov Report
@@ Coverage Diff @@
## master #5935 +/- ##
==========================================
+ Coverage 38.28% 38.53% +0.25%
==========================================
Files 330 330
Lines 48518 48518
==========================================
+ Hits 18576 18698 +122
+ Misses 27268 27113 -155
- Partials 2674 2707 +33
Continue to review full report at Codecov.
|
@@ -250,6 +250,9 @@ func runServ(c *cli.Context) error { | |||
if err = private.UpdateDeployKeyUpdated(key.ID, repo.ID); err != nil { | |||
fail("Internal error", "UpdateDeployKey: %v", err) | |||
} | |||
|
|||
os.Setenv(models.EnvPusherName, username) |
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.
What about using repo.Owner.NameToLower
(I think), just for consistency?
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.
username
is repo.Owner.NameToLower
- it's the lowercase'd repo username that's provided to gitea serv.
In the case of the user pushes we use user.Name for this so we probably shouldn't be lowercasing at all, and in fact we should probably change this so it's clear that the "user" pushing this is a deploy key not the owner of the repository at all. However, this is the minimal change that works when previously we didn't have a working system at all previously.
I have added a FIXME note to mark that further thought is needed here.
The gitea PushUpdate function requires that the PusherID and PusherName are real users. Signed-off-by: Andrew Thornton <[email protected]>
c9cfc76
to
bc2b6ad
Compare
OK I've added an integration test to show that this actually solves the problem in #3795 |
…ment variables (go-gitea#5935) The gitea prerecieve and postrecieve hooks and the gitea PushUpdate function require that the PusherID and PusherName are real users. Previously, these environment variables were not being set when using a deploy key - the main result being that pushing to empty repositories meant that is_empty status was not changed. I've also added an integration test to ensure that the is_empty status is updated on pushing with a deploy key. There is a slight issue in that the deploy key is now considered a proxy for the owner - we don't have a way of separating out the deploy key from the owner at present. This can be fixed in another PR. Fix go-gitea#3795 Signed-off-by: Andrew Thornton [email protected]
…ment variables (go-gitea#5935) The gitea prerecieve and postrecieve hooks and the gitea PushUpdate function require that the PusherID and PusherName are real users. Previously, these environment variables were not being set when using a deploy key - the main result being that pushing to empty repositories meant that is_empty status was not changed. I've also added an integration test to ensure that the is_empty status is updated on pushing with a deploy key. There is a slight issue in that the deploy key is now considered a proxy for the owner - we don't have a way of separating out the deploy key from the owner at present. This can be fixed in another PR. Fix go-gitea#3795 Signed-off-by: Andrew Thornton [email protected] Cherry-pick: 13c0f7d
…ment variables (#5935) (#5944) The gitea prerecieve and postrecieve hooks and the gitea PushUpdate function require that the PusherID and PusherName are real users. Previously, these environment variables were not being set when using a deploy key - the main result being that pushing to empty repositories meant that is_empty status was not changed. I've also added an integration test to ensure that the is_empty status is updated on pushing with a deploy key. There is a slight issue in that the deploy key is now considered a proxy for the owner - we don't have a way of separating out the deploy key from the owner at present. This can be fixed in another PR. Fix #3795 Signed-off-by: Andrew Thornton [email protected]
The gitea PushUpdate function requires that the PusherID and PusherName
are real users.
Fix #3795
Signed-off-by: Andrew Thornton [email protected]