Skip to content

Commit

Permalink
fix(2952): Allow colon to be used in root directory (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
yk634 authored Nov 30, 2023
1 parent ee1f325 commit 7de3943
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ class ScmBase {
* @return {Promise}
*/
getSetupCommand(o) {
const [host, , branch, rootDir] = o.pipeline.scmUri.split(':');
const parts = o.pipeline.scmUri.split(':');
const [host, , branch, ...rootDirParts] = parts;
const rootDir = rootDirParts.join(':');

const [org, repo] = o.pipeline.scmRepo.name.split('/');
const prBranchRegex = /^~pr:(.*)$/;
const checkoutConfig = {
Expand Down
24 changes: 24 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,30 @@ describe('index test', () => {
});
});

it('returns a command when rootDir with a colon exists', () => {
config.pipeline.scmUri = 'github.com:12344567:branch:colon:colon';
instance._getCheckoutCommand = o => {
assert.deepEqual(o, {
branch: 'branch',
host: 'github.com',
org: 'screwdriver-cd',
repo: 'guide',
rootDir: 'colon:colon',
sha: '12345',
prSource: 'branch',
prBranchName: 'prBranchName',
prRef: 'prRef',
scmContext: 'github:github.com'
});

return Promise.resolve({ name: 'sd-checkout-code', command: 'stuff' });
};

return instance.getSetupCommand(config).then(command => {
assert.equal(command, 'stuff');
});
});

it('returns a command for pr', () => {
instance._getCheckoutCommand = o => {
assert.deepEqual(o, {
Expand Down

0 comments on commit 7de3943

Please sign in to comment.