fix(git): treat stale rejection as REPOSITORY_CHANGED (#14829)

This commit is contained in:
Rhys Arkins 2022-03-28 17:44:40 +02:00 committed by GitHub
parent 25d793f690
commit 00c74a9ca2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View file

@ -22,7 +22,6 @@ export function checkForPlatformFailure(err: Error): Error | null {
'early EOF', 'early EOF',
'fatal: bad config', // .gitmodules problem 'fatal: bad config', // .gitmodules problem
'expected flush after ref listing', 'expected flush after ref listing',
'[rejected] (stale info)',
]; ];
for (const errorStr of externalHostFailureStrings) { for (const errorStr of externalHostFailureStrings) {
if (err.message.includes(errorStr)) { if (err.message.includes(errorStr)) {

View file

@ -982,6 +982,7 @@ export async function fetchCommit({
export async function commitFiles( export async function commitFiles(
commitConfig: CommitFilesConfig commitConfig: CommitFilesConfig
): Promise<CommitSha | null> { ): Promise<CommitSha | null> {
try {
const commitResult = await prepareCommit(commitConfig); const commitResult = await prepareCommit(commitConfig);
if (commitResult) { if (commitResult) {
const pushResult = await pushCommit(commitConfig); const pushResult = await pushCommit(commitConfig);
@ -994,6 +995,12 @@ export async function commitFiles(
} }
} }
return null; return null;
} catch (err) /* istanbul ignore next */ {
if (err.message.includes('[rejected] (stale info)')) {
throw new Error(REPOSITORY_CHANGED);
}
throw err;
}
} }
export function getUrl({ export function getUrl({