From 8812d4a06b830e207ec7421d5e1767121f2cd8fa Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 30 Oct 2020 17:13:34 +0100 Subject: [PATCH] auth-helper: properly await replacement of the token value in the config After writing the `.extraheader` config, we manually replace the token with the actual value. This is done in an `async` function, but we were not `await`ing the result. In our tests, this commit fixes a flakiness we observed where `remote.origin.url` sometimes (very rarely, actually) is not set for submodules. Our interpretation is that the configs are in the process of being rewritten with the correct token value _while_ another `git config` that wants to set the `insteadOf` value is reading the config, which is currently empty. A more idiomatic way to fix this in Typescript would use `Promise.all()`, like this: await Promise.all( configPaths.map(async configPath => { core.debug(`Replacing token placeholder in '${configPath}'`) await this.replaceTokenPlaceholder(configPath) }) ) However, during review of https://github.com/actions/checkout/pull/379 it was decided to keep the `for` loop in the interest of simplicity. Reported by Ian Lynagh. Signed-off-by: Johannes Schindelin --- src/git-auth-helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts index fc1404c..291d83b 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -148,7 +148,7 @@ class GitAuthHelper { output.match(/(?<=(^|\n)file:)[^\t]+(?=\tremote\.origin\.url)/g) || [] for (const configPath of configPaths) { core.debug(`Replacing token placeholder in '${configPath}'`) - this.replaceTokenPlaceholder(configPath) + await this.replaceTokenPlaceholder(configPath) } if (this.settings.sshKey) {