Skip to content

Commit 9a0c01f

Browse files
committed
fix(tagger): do not specify --branch when cloning default branch
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 3784f91 commit 9a0c01f

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

tagger/tag.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,6 @@
238238
die("Branch not found :(\n");
239239
}
240240

241-
function translateBranch(string $branch, string $repo): string {
242-
if ($branch !== 'master') {
243-
return $branch;
244-
}
245-
if (in_array($repo, [
246-
'nextcloud/text',
247-
'nextcloud/twofactor_nextcloud_notification',
248-
'nextcloud/app_api',
249-
])) {
250-
return 'main';
251-
}
252-
return $branch;
253-
}
254-
255241
// use proper temp location on dev machines, assuming it's memdisc, to not wear out physical storage
256242
$workDir = gethostname() === 'client-builder' ? __DIR__ : trim(shell_exec('mktemp -d'));
257243
fwrite(STDERR, '[Debug] Work dir is: ' . $workDir . PHP_EOL);
@@ -275,26 +261,26 @@ function translateBranch(string $branch, string $repo): string {
275261
$SSH_OPTIONS = "GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa.support-app -o IdentitiesOnly=yes'";
276262
}
277263

278-
$branch = translateBranch($originalBranch, $repo);
264+
$branchOpt = $originalBranch === 'master' || $originalBranch === 'main' ? '' : '--branch='.escapeshellarg($originalBranch);
279265

280266
// Clone the repository and checkout the required branch
281-
fwrite(STDERR, '[Debug] cd ' . $workDir . ' && ' . $SSH_OPTIONS . ' git clone ' . $depthMode . ' --branch="' . $branch . '" git@github.com:' . $repo . PHP_EOL);
282-
shell_exec('cd ' . $workDir . ' && ' . $SSH_OPTIONS . ' git clone ' . $depthMode . ' --branch="' . $branch . '" git@github.com:' . $repo);
267+
fwrite(STDERR, '[Debug] cd ' . $workDir . ' && ' . $SSH_OPTIONS . ' git clone ' . $depthMode . $branchOpt . ' git@github.com:' . $repo . PHP_EOL);
268+
shell_exec('cd ' . $workDir . ' && ' . $SSH_OPTIONS . ' git clone ' . $depthMode . $branchOpt . ' git@github.com:' . $repo);
283269

284270
// checkout historic commit if applicable
285271
if ($historic) {
286272
if (!is_dir($workDir . '/' . $name)) {
287273
// we end up here, with a failed clone, when there were no commits in our time range. We redo with depth=42.
288274
// 42 for good luck. 1 Might bring too new commits.
289-
shell_exec('cd ' . $workDir . ' && ' . $SSH_OPTIONS . ' git clone --depth=42 --branch="' . $branch . '" git@github.com:' . $repo);
275+
shell_exec('cd ' . $workDir . ' && ' . $SSH_OPTIONS . ' git clone --depth=42 ' . $branchOpt . ' git@github.com:' . $repo);
290276
}
291277

292278
$commitHash = trim(shell_exec('cd ' . $workDir . '/' . $name . ' && git log -n1 --format=%H --until="' . $historic . '"'));
293279
if ($commitHash === "") {
294280
shell_exec('cd ' . $workDir . ' && rm -rf ' . $name);
295281
// we end up here, when there were no old enough commits in our time range! We redo with depth=42.
296282
// 42 for good luck.
297-
shell_exec('cd ' . $workDir . ' && ' . $SSH_OPTIONS . ' git clone --depth=42 --branch="' . $branch . '" git@github.com:' . $repo);
283+
shell_exec('cd ' . $workDir . ' && ' . $SSH_OPTIONS . ' git clone --depth=42 ' . $branchOpt . ' git@github.com:' . $repo);
298284
$commitHash = trim(shell_exec('cd ' . $workDir . '/' . $name . ' && git log -n1 --format=%H --until="' . $historic . '"'));
299285
}
300286
if (strlen($commitHash) !== 40) {

0 commit comments

Comments
 (0)