feat: used -b for clone

pull/210/head
Michael Brewer 1 year ago
parent 002a8b5d37
commit b525c785b4
No known key found for this signature in database
GPG Key ID: D7A137BA1254AFC7

@ -111,10 +111,7 @@ describe("git-clone", async () => {
expect(output.exitCode).toBe(0);
expect(output.stdout).toEqual([
"Creating directory ~/repo-tests.log...",
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log...",
"Switch to branch feat/branch...",
"branch 'feat/branch' set up to track 'origin/feat/branch'.",
"/git",
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
]);
});
@ -127,10 +124,7 @@ describe("git-clone", async () => {
expect(output.exitCode).toBe(0);
expect(output.stdout).toEqual([
"Creating directory ~/repo-tests.log...",
"Cloning https://gitlab.com/mike.brew/repo-tests.log to ~/repo-tests.log...",
"Switch to branch feat/branch...",
"branch 'feat/branch' set up to track 'origin/feat/branch'.",
"/git",
"Cloning https://gitlab.com/mike.brew/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
]);
});
});

@ -34,21 +34,12 @@ fi
# Check if the directory is empty
# and if it is, clone the repo, otherwise skip cloning
if [ -z "$(ls -A "$CLONE_PATH")" ]; then
if [ -z "$BRANCH_NAME" ]; then
echo "Cloning $REPO_URL to $CLONE_PATH..."
git clone "$REPO_URL" "$CLONE_PATH"
# Return the exit code of the last command
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
# If BRANCH_NAME is set of a non-blank value, switch to that branch
if [ -n "$BRANCH_NAME" ]; then
echo "Switch to branch $BRANCH_NAME..."
cd "$CLONE_PATH" || exit 1
git switch "$BRANCH_NAME"
cd - || exit 1
else
echo "Cloning $REPO_URL to $CLONE_PATH on branch $BRANCH_NAME..."
git clone "$REPO_URL" -b "$BRANCH_NAME" "$CLONE_PATH"
fi
else
echo "$CLONE_PATH already exists and isn't empty, skipping clone!"

Loading…
Cancel
Save