Skip to content

Commit

Permalink
fix(2059): To use amp as branch name (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshwata authored Apr 13, 2020
1 parent 9f93b36 commit 20e0ea3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,23 +399,23 @@ class GitlabScm extends Scm {
command.push('export GIT_MERGE_AUTOEDIT=no');

// Git clone
command.push(`echo Cloning ${checkoutUrl}, on branch ${config.branch}`);
command.push(`echo 'Cloning ${checkoutUrl}, on branch ${config.branch}'`);
command.push('if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; '
+ `then git clone --recursive --quiet --progress --branch ${config.branch} `
+ `then git clone --recursive --quiet --progress --branch '${config.branch}' `
+ '$SCM_URL $SD_SOURCE_DIR; '
+ 'else git clone --depth=50 --no-single-branch --recursive --quiet --progress '
+ `--branch ${config.branch} $SCM_URL $SD_SOURCE_DIR; fi`);
+ `--branch '${config.branch}' $SCM_URL $SD_SOURCE_DIR; fi`);
// Reset to SHA
command.push(`echo Reset to SHA ${checkoutRef}`);
command.push(`git reset --hard ${checkoutRef}`);
command.push(`echo 'Reset to SHA ${checkoutRef}'`);
command.push(`git reset --hard '${checkoutRef}'`);
// Set config
command.push('echo Setting user name and user email');
command.push(`git config user.name ${this.config.username}`);
command.push(`git config user.email ${this.config.email}`);

// For pull requests
if (config.prRef) {
command.push(`echo Fetching PR and merging with ${config.branch}`);
command.push(`echo 'Fetching PR and merging with ${config.branch}'`);
command.push(`git fetch origin ${config.prRef}`);
command.push(`git merge ${config.sha}`);
}
Expand Down
2 changes: 1 addition & 1 deletion test/data/commands.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "sd-checkout-code",
"command": "echo Exporting environment variables && 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 && export GIT_URL=$SCM_URL.git && export GIT_MERGE_AUTOEDIT=no && echo Cloning hostName/orgName/repoName, on branch branchName && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then git clone --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR; else git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR; fi && echo Reset to SHA shaValue && git reset --hard shaValue && echo Setting user name and user email && git config user.name sd-buildbot && git config user.email [email protected]"
"command": "echo Exporting environment variables && 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 && export GIT_URL=$SCM_URL.git && export GIT_MERGE_AUTOEDIT=no && echo 'Cloning hostName/orgName/repoName, on branch branchName' && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then git clone --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR; else git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR; fi && echo 'Reset to SHA shaValue' && git reset --hard 'shaValue' && echo Setting user name and user email && git config user.name sd-buildbot && git config user.email [email protected]"
}
2 changes: 1 addition & 1 deletion test/data/customPrCommands.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "sd-checkout-code",
"command": "echo Exporting environment variables && 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 && export GIT_URL=$SCM_URL.git && export GIT_MERGE_AUTOEDIT=no && echo Cloning hostName/orgName/repoName, on branch branchName && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then git clone --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR; else git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR; fi && echo Reset to SHA branchName && git reset --hard branchName && echo Setting user name and user email && git config user.name abcd && git config user.email [email protected] && echo Fetching PR and merging with branchName && git fetch origin prBranch && git merge shaValue"
"command": "echo Exporting environment variables && 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 && export GIT_URL=$SCM_URL.git && export GIT_MERGE_AUTOEDIT=no && echo 'Cloning hostName/orgName/repoName, on branch branchName' && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then git clone --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR; else git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR; fi && echo 'Reset to SHA branchName' && git reset --hard 'branchName' && echo Setting user name and user email && git config user.name abcd && git config user.email [email protected] && echo 'Fetching PR and merging with branchName' && git fetch origin prBranch && git merge shaValue"
}
2 changes: 1 addition & 1 deletion test/data/prCommands.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "sd-checkout-code",
"command": "echo Exporting environment variables && 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 && export GIT_URL=$SCM_URL.git && export GIT_MERGE_AUTOEDIT=no && echo Cloning hostName/orgName/repoName, on branch branchName && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then git clone --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR; else git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR; fi && echo Reset to SHA branchName && git reset --hard branchName && echo Setting user name and user email && git config user.name sd-buildbot && git config user.email [email protected] && echo Fetching PR and merging with branchName && git fetch origin prBranch && git merge shaValue"
"command": "echo Exporting environment variables && 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 && export GIT_URL=$SCM_URL.git && export GIT_MERGE_AUTOEDIT=no && echo 'Cloning hostName/orgName/repoName, on branch branchName' && if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; then git clone --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR; else git clone --depth=50 --no-single-branch --recursive --quiet --progress --branch 'branchName' $SCM_URL $SD_SOURCE_DIR; fi && echo 'Reset to SHA branchName' && git reset --hard 'branchName' && echo Setting user name and user email && git config user.name sd-buildbot && git config user.email [email protected] && echo 'Fetching PR and merging with branchName' && git fetch origin prBranch && git merge shaValue"
}

0 comments on commit 20e0ea3

Please sign in to comment.