Skip to content

Commit

Permalink
fix(artifacts/bitbucket): Allow updates to bitbucket default artifact…
Browse files Browse the repository at this point in the history
… text input

Allows updates to the artifact text input even when the regex pattern does not match the bitbucket cloud regex
Create regex pattern for bitbucket server to match input against
Fixes spinnaker/spinnaker#4958
  • Loading branch information
battlecow authored and christopherthielen committed Oct 1, 2019
1 parent 3377ee1 commit 5e25501
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,22 @@ export const BitbucketDefault: IArtifactKindConfig = {
}

private onReferenceChanged = (reference: string) => {
const pathRegex = new RegExp('/1.0/repositories/[^/]*/[^/]*/raw/[^/]*/(.*)$');
const results = pathRegex.exec(reference);
const bitbucketCloudRegex = new RegExp('/1.0/repositories/[^/]*/[^/]*/raw/[^/]*/(.*)$');
const bitbucketServerRegex = new RegExp('/projects/[^/]*/repos/[^/]*/raw/([^?]*)');

const clonedArtifact = cloneDeep(this.props.artifact);
clonedArtifact.reference = reference;

let results;
results = bitbucketCloudRegex.exec(reference);
if (results === null) {
results = bitbucketServerRegex.exec(reference);
}

if (results !== null) {
const clonedArtifact = cloneDeep(this.props.artifact);
clonedArtifact.name = decodeURIComponent(results[1]);
clonedArtifact.reference = reference;
this.props.onChange(clonedArtifact);
}
this.props.onChange(clonedArtifact);
};

public render() {
Expand Down

0 comments on commit 5e25501

Please sign in to comment.