Skip to content

Commit 70e57e3

Browse files
committed
cleanup
1 parent bca42d1 commit 70e57e3

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

entrypoint.php

+20-22
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
// info
4545
$clonedRepository='https://' . $hostRepositoryOrganizationName;
4646
note(sprintf('Cloning "%s" repository to "%s" directory', $clonedRepository, $cloneDirectory));
47-
exec('git clone -- https://' . $publicAccessTokens . '@' . $hostRepositoryOrganizationName . ' ' . $cloneDirectory);
47+
48+
$commandLine = 'git clone -- https://' . $publicAccessTokens . '@' . $hostRepositoryOrganizationName . ' ' . $cloneDirectory;
49+
exec_with_note($commandLine);
4850

4951

5052
note('Cleaning destination repository of old files');
@@ -86,8 +88,7 @@
8688

8789

8890
// avoids doing the git commit failing if there are no changes to be commit, see https://stackoverflow.com/a/8123841/1348344
89-
exec('git status', $outputLines);
90-
print_output_lines($outputLines);
91+
exec_with_output_print('git status');
9192

9293
exec('git diff-index --quiet HEAD', $outputLines, $hasChangedFiles);
9394

@@ -97,8 +98,7 @@
9798

9899
if ($hasChangedFiles === 1) {
99100
note('Adding git commit');
100-
exec('git add .', $outputLines);
101-
print_output_lines($outputLines);
101+
exec_with_output_print('git add .');
102102

103103
$message = sprintf('Pushing git commit with "%s" message to "%s"', $commitMessage, $branch);
104104
note($message);
@@ -115,18 +115,10 @@
115115
$message = sprintf('Publishing "%s"', $tag);
116116
note($message);
117117

118-
// [debug] - show existing tags
119-
exec('git tag', $outputLines);
120-
note('Present tags:');
121-
print_output_lines($outputLines);
122-
123118
$commandLine = sprintf('git tag %s -m "%s"', $tag, $message);
124-
note('Running: ' . $commandLine);
125-
exec($commandLine);
119+
exec_with_note($commandLine);
126120

127-
$commandLine = 'git push --quiet origin ' . $tag;
128-
note('Running: ' . $commandLine);
129-
exec($commandLine);
121+
exec_with_note('git push --quiet origin ' . $tag);
130122
}
131123

132124

@@ -167,15 +159,21 @@ function resolve_public_access_token(): string
167159

168160

169161
function list_directory_files(string $directory) {
170-
exec('ls -la ' . $directory, $outputLines);
171-
print_output_lines($outputLines);
162+
exec_with_output_print('ls -la ' . $directory);
172163
}
173164

174-
/**
175-
* @param string[] $outputLines
176-
*/
177-
function print_output_lines(array $outputLines): void
165+
166+
/********************* helper functions *********************/
167+
168+
function exec_with_note(string $commandLine): void
178169
{
179-
echo implode(PHP_EOL, $outputLines);
170+
note('Running: ' . $commandLine);
171+
exec($commandLine);
180172
}
181173

174+
175+
function exec_with_output_print(string $commandLine): void
176+
{
177+
exec($commandLine, $outputLines);
178+
echo implode(PHP_EOL, $outputLines);
179+
}

0 commit comments

Comments
 (0)