1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Chore: Default plugins: Refactor git checkout in default plugins build (#9812)

This commit is contained in:
Henry Heino 2024-02-02 14:55:28 -08:00 committed by GitHub
parent 0e45336140
commit 9a26e8aafd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 11 deletions

View File

@ -570,6 +570,7 @@ packages/default-plugins/build.js
packages/default-plugins/buildDefaultPlugins.js
packages/default-plugins/commands/buildAll.js
packages/default-plugins/commands/editPatch.js
packages/default-plugins/utils/getCurrentCommitHash.js
packages/default-plugins/utils/getPathToPatchFileFor.js
packages/default-plugins/utils/readRepositoryJson.js
packages/default-plugins/utils/waitForCliInput.js

1
.gitignore vendored
View File

@ -550,6 +550,7 @@ packages/default-plugins/build.js
packages/default-plugins/buildDefaultPlugins.js
packages/default-plugins/commands/buildAll.js
packages/default-plugins/commands/editPatch.js
packages/default-plugins/utils/getCurrentCommitHash.js
packages/default-plugins/utils/getPathToPatchFileFor.js
packages/default-plugins/utils/readRepositoryJson.js
packages/default-plugins/utils/waitForCliInput.js

View File

@ -10,6 +10,7 @@ import { glob } from 'glob';
import readRepositoryJson from './utils/readRepositoryJson';
import waitForCliInput from './utils/waitForCliInput';
import getPathToPatchFileFor from './utils/getPathToPatchFileFor';
import getCurrentCommitHash from './utils/getCurrentCommitHash';
type BeforeEachInstallCallback = (buildDir: string, pluginName: string)=> Promise<void>;
@ -41,10 +42,8 @@ const buildDefaultPlugins = async (outputParentDir: string|null, beforeInstall:
}
chdir(pluginDir);
const currentCommitHash = (await execCommand(['git', 'rev-parse', 'HEAD'])).trim();
const expectedCommitHash = repositoryData.commit;
if (currentCommitHash !== expectedCommitHash) {
logStatus(`Switching to commit ${expectedCommitHash}`);
await execCommand(['git', 'switch', repositoryData.branch]);
@ -55,6 +54,9 @@ const buildDefaultPlugins = async (outputParentDir: string|null, beforeInstall:
await execCommand(['git', 'fetch']);
await execCommand(['git', 'checkout', expectedCommitHash]);
}
if (await getCurrentCommitHash() !== expectedCommitHash) {
throw new Error(`Unable to checkout commit ${expectedCommitHash}`);
}
logStatus('Copying repository files...');

View File

@ -0,0 +1,7 @@
import { execCommand } from '@joplin/utils';
const getCurrentCommitHash = async () => {
return (await execCommand(['git', 'rev-parse', '--verify', 'HEAD^{commit}'])).trim();
};
export default getCurrentCommitHash;