Skip to content

Commit 7b5ea3a

Browse files
authored
fix(2059): To use amp as branch name (#67)
1 parent 75e1573 commit 7b5ea3a

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -737,14 +737,14 @@ class BitbucketScm extends Scm {
737737
command.push(`export SD_CONFIG_DIR=${externalConfigDir}`);
738738

739739
// Git clone
740-
command.push(`echo Cloning external config repo ${parentCheckoutUrl}`);
740+
command.push(`echo 'Cloning external config repo ${parentCheckoutUrl}'`);
741741
command.push('if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; '
742742
+ `then ${gitWrapper} `
743-
+ `"git clone --recursive --quiet --progress --branch ${parentBranch} `
743+
+ `"git clone --recursive --quiet --progress --branch '${parentBranch}' `
744744
+ '$CONFIG_URL $SD_CONFIG_DIR"; '
745745
+ `else ${gitWrapper} `
746746
+ '"git clone --depth=50 --no-single-branch --recursive --quiet --progress '
747-
+ `--branch ${parentBranch} $CONFIG_URL $SD_CONFIG_DIR"; fi`);
747+
+ `--branch '${parentBranch}' $CONFIG_URL $SD_CONFIG_DIR"; fi`);
748748

749749
// Reset to SHA
750750
command.push(`${gitWrapper} "git -C $SD_CONFIG_DIR reset --hard `
@@ -753,7 +753,7 @@ class BitbucketScm extends Scm {
753753
}
754754

755755
// Git clone
756-
command.push(`echo Cloning ${checkoutUrl}, on branch ${branch}`);
756+
command.push(`echo 'Cloning ${checkoutUrl}, on branch ${branch}'`);
757757
command.push('if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; ' +
758758
`then export SCM_URL=${sshCheckoutUrl}; ` +
759759
'elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; ' +
@@ -762,14 +762,14 @@ class BitbucketScm extends Scm {
762762
);
763763
command.push('if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; '
764764
+ `then ${gitWrapper} `
765-
+ `"git clone --recursive --quiet --progress --branch ${branch} `
765+
+ `"git clone --recursive --quiet --progress --branch '${branch}' `
766766
+ '$SCM_URL $SD_SOURCE_DIR"; '
767767
+ `else ${gitWrapper} `
768768
+ '"git clone --depth=50 --no-single-branch --recursive --quiet --progress '
769-
+ `--branch ${branch} $SCM_URL $SD_SOURCE_DIR"; fi`);
769+
+ `--branch '${branch}' $SCM_URL $SD_SOURCE_DIR"; fi`);
770770
// Reset to Sha
771-
command.push(`echo Reset to SHA ${checkoutRef}`);
772-
command.push(`${gitWrapper} "git reset --hard ${checkoutRef}"`);
771+
command.push(`echo 'Reset to SHA ${checkoutRef}'`);
772+
command.push(`${gitWrapper} "git reset --hard '${checkoutRef}'"`);
773773

774774
// Set config
775775
command.push('echo Setting user name and user email');
@@ -779,7 +779,7 @@ class BitbucketScm extends Scm {
779779
if (config.prRef) {
780780
const prRef = config.prRef.replace('merge', 'head:pr');
781781

782-
command.push(`echo Fetching PR and merging with ${branch}`);
782+
command.push(`echo 'Fetching PR and merging with ${branch}'`);
783783
command.push(`${gitWrapper} "git fetch origin ${prRef}"`);
784784
command.push(`${gitWrapper} "git merge --no-edit ${config.sha}"`);
785785
// Init & Update submodule

test/data/childCommands.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "sd-checkout-code",
3-
"command": "if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export CONFIG_URL=git@github.com:screwdriver-cd/parent-repo; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export CONFIG_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@github.com/screwdriver-cd/parent-repo; else export CONFIG_URL=https://github.com/screwdriver-cd/parent-repo; fi && export SD_CONFIG_DIR=$SD_ROOT_DIR/config && echo Cloning external config repo github.com/screwdriver-cd/parent-repo && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch master $CONFIG_URL $SD_CONFIG_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch master $CONFIG_URL $SD_CONFIG_DIR\"; fi && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git -C $SD_CONFIG_DIR reset --hard 54321\" && echo Reset external config repo to 54321 && echo Cloning hostName/orgName/repoName, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR\"; fi && echo Reset to SHA shaValue && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git reset --hard shaValue\" && echo Setting user name and user email && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.name sd-buildbot\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.email dev-null@screwdriver.cd\""
3+
"command": "if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export CONFIG_URL=git@github.com:screwdriver-cd/parent-repo; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export CONFIG_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@github.com/screwdriver-cd/parent-repo; else export CONFIG_URL=https://github.com/screwdriver-cd/parent-repo; fi && export SD_CONFIG_DIR=$SD_ROOT_DIR/config && echo 'Cloning external config repo github.com/screwdriver-cd/parent-repo' && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch 'master' $CONFIG_URL $SD_CONFIG_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch 'master' $CONFIG_URL $SD_CONFIG_DIR\"; fi && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git -C $SD_CONFIG_DIR reset --hard 54321\" && echo Reset external config repo to 54321 && echo 'Cloning hostName/orgName/repoName, on branch branchName' && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR\"; fi && echo 'Reset to SHA shaValue' && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git reset --hard 'shaValue'\" && echo Setting user name and user email && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.name sd-buildbot\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.email dev-null@screwdriver.cd\""
44
}

test/data/commands.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "sd-checkout-code",
3-
"command": "echo Cloning hostName/orgName/repoName, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR\"; fi && echo Reset to SHA shaValue && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git reset --hard shaValue\" && echo Setting user name and user email && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.name sd-buildbot\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.email dev-null@screwdriver.cd\""
3+
"command": "echo 'Cloning hostName/orgName/repoName, on branch branchName' && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR\"; fi && echo 'Reset to SHA shaValue' && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git reset --hard 'shaValue'\" && echo Setting user name and user email && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.name sd-buildbot\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.email dev-null@screwdriver.cd\""
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "sd-checkout-code",
3-
"command": "echo Cloning hostName/orgName/repoName, on branch commitBranch && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch commitBranch $SCM_URL $SD_SOURCE_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch commitBranch $SCM_URL $SD_SOURCE_DIR\"; fi && echo Reset to SHA shaValue && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git reset --hard shaValue\" && echo Setting user name and user email && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.name sd-buildbot\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.email dev-null@screwdriver.cd\""
3+
"command": "echo 'Cloning hostName/orgName/repoName, on branch commitBranch' && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch 'commitBranch' $SCM_URL $SD_SOURCE_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch 'commitBranch' $SCM_URL $SD_SOURCE_DIR\"; fi && echo 'Reset to SHA shaValue' && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git reset --hard 'shaValue'\" && echo Setting user name and user email && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.name sd-buildbot\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.email dev-null@screwdriver.cd\""
44
}

test/data/customPrCommands.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "sd-checkout-code",
3-
"command": "echo Cloning hostName/orgName/repoName, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR\"; fi && echo Reset to SHA branchName && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git reset --hard branchName\" && echo Setting user name and user email && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.name abcd\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.email dev-null@my.email.com\" && echo Fetching PR and merging with branchName && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git fetch origin prBranch\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git merge --no-edit shaValue\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git submodule init\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git submodule update --recursive\""
3+
"command": "echo 'Cloning hostName/orgName/repoName, on branch branchName' && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR\"; else $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR\"; fi && echo 'Reset to SHA branchName' && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git reset --hard 'branchName'\" && echo Setting user name and user email && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.name abcd\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git config user.email dev-null@my.email.com\" && echo 'Fetching PR and merging with branchName' && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git fetch origin prBranch\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git merge --no-edit shaValue\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git submodule init\" && $(if git --version > /dev/null 2>&1; then echo 'eval'; else echo 'sd-step exec core/git'; fi) \"git submodule update --recursive\""
44
}

0 commit comments

Comments
 (0)