Skip to content

Commit a0698c0

Browse files
committed
chores: add optional commitHash when cloning repository
1 parent 1de7fb3 commit a0698c0

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

packages/prettier-plugin-java/scripts/clone-samples.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const jhipster1 = [
4848
},
4949
{
5050
repoUrl: "https://github.com/jhipster/jhipster-sample-app-nocache",
51-
branch: "main"
51+
branch: "main",
52+
commitHash: "fda6dee77651042083780c812a1a54ff2de8da47"
5253
},
5354
{
5455
repoUrl: "https://github.com/jhipster/jhipster-sample-app-hazelcast",
@@ -97,10 +98,21 @@ fs.emptyDirSync(samplesDir);
9798

9899
sampleRepos.forEach(cloneRepo);
99100

100-
function cloneRepo({ repoUrl, branch }) {
101+
function cloneRepo({ repoUrl, branch, commitHash }) {
101102
console.log(`cloning ${repoUrl}`);
102-
cp.execSync(`git clone ${repoUrl} --branch ${branch} --depth 1`, {
103-
cwd: samplesDir,
104-
stdio: [0, 1, 2]
105-
});
103+
if (commitHash) {
104+
cp.execSync(`git clone ${repoUrl} --branch ${branch}`, {
105+
cwd: samplesDir,
106+
stdio: [0, 1, 2]
107+
});
108+
cp.execSync(`git checkout ${commitHash}`, {
109+
cwd: path.resolve(samplesDir, repoUrl.split("/").pop()),
110+
stdio: [0, 1, 2]
111+
});
112+
} else {
113+
cp.execSync(`git clone ${repoUrl} --branch ${branch} --depth 1`, {
114+
cwd: samplesDir,
115+
stdio: [0, 1, 2]
116+
});
117+
}
106118
}

0 commit comments

Comments
 (0)