mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-18 05:43:42 +00:00
fix: give git-lfs the checkout token once (#1371)
`builtin:checkout` set the token both in its persisted credentials file and in the step's environment. git-lfs before 3.8.0 then sent `Authorization` twice on the LFS batch request, which nginx rejects with 400. Write the credentials file once the checkout succeeded, since it only serves later steps. A failed checkout no longer persists credentials. Users can also upgrade git-lfs to fix the root bug, but this fix is worth to keep regardless. Fixes: https://gitea.com/gitea/runner/issues/1370 Co-authored-by: bircni <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1371 Reviewed-by: bircni <[email protected]> Co-authored-by: silverwind <[email protected]>
This commit is contained in:
1 parent
b65fd0f8f8
commit
54b2cb944c
2 files changed
+15
-6
No files matched your search
@@ -174,9 +174,6 @@ func Main(ctx context.Context, c *action.Context) (err error) {
|
||||
env["GIT_SSH_COMMAND"] = shellquote.Join(ssh...)
|
||||
config += "[core]\n\tsshCommand = " + strconv.Quote(env["GIT_SSH_COMMAND"]) + "\n"
|
||||
}
|
||||
if !persist {
|
||||
config = ""
|
||||
}
|
||||
|
||||
if co.objectFormat == "" || co.sha == "" && !strings.HasPrefix(co.ref, "refs/") {
|
||||
advertised, err := lsRemote(ctx, c, env, co.url, co.ref)
|
||||
@@ -191,7 +188,7 @@ func Main(ctx context.Context, c *action.Context) (err error) {
|
||||
if ref != co.sha {
|
||||
co.outputRef = cmp.Or(ref, co.ref) // as given, like actions/checkout
|
||||
}
|
||||
if err := c.Container.Copy(runnerTemp, &container.FileEntry{Name: credentials, Mode: 0o600, Body: config})(ctx); err != nil {
|
||||
if err := c.Container.Copy(runnerTemp, &container.FileEntry{Name: credentials, Mode: 0o600})(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -215,7 +212,10 @@ func Main(ctx context.Context, c *action.Context) (err error) {
|
||||
}
|
||||
commands = commands[fetched:]
|
||||
}
|
||||
return clone(commands)
|
||||
if err := clone(commands); err != nil || !persist {
|
||||
return err
|
||||
}
|
||||
return c.Container.Copy(runnerTemp, &container.FileEntry{Name: credentials, Mode: 0o600, Body: config})(ctx) // for later steps, the step itself authenticates through env
|
||||
}
|
||||
|
||||
func gitEnv(c *action.Context, config []string) map[string]string {
|
||||
|
||||
Reference in new issue
Block a user