Skip to content

Commit

Permalink
use group from user input when using branch flow (#380)
Browse files Browse the repository at this point in the history
* use input.group when using branch flow

* added unit tests
  • Loading branch information
shubhbapna authored Feb 10, 2023
1 parent b9b152d commit 8306396
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/service/checkout/checkout-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class CheckoutService {
// target branch is guaranteed to exist since base always exist
mappedBranch: getMappedTarget(starterNode.project, starterNode.mapping, node.project, node.mapping, originalTarget.branch!),
name: node.project.split("/")[1],
group: node.project.split("/")[0],
group: this.config.getGroupName() ?? node.project.split("/")[0],
};

const originalSource = this.config.getSourceProject();
Expand Down
4 changes: 4 additions & 0 deletions src/service/config/configuration-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,8 @@ export class ConfigurationService {
getEventUrl(): string {
return this.getFlowType() === FlowType.BRANCH ? "" : this.configuration.gitEventData.html_url;
}

getGroupName(): string | undefined {
return this.getFlowType() === FlowType.BRANCH ? this.configuration.parsedInputs.group : undefined;
}
}
12 changes: 12 additions & 0 deletions test/unitary/service/config/configuration-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,16 @@ describe("methods", () => {
.mockImplementationOnce(() => ({ html_url: expected } as EventData));
expect(config.getEventUrl()).toBe(expected);
});

test.each([
["branch flow", FlowType.BRANCH, "group"],
["non branch flow", FlowType.CROSS_PULL_REQUEST, undefined],
])("getGroupName", (title: string, flowType: FlowType, group?: string) => {
currentInput = {
...defaultInputValues,
CLISubCommand: flowType,
group
};
expect(config.getGroupName()).toBe(group);
});
});

0 comments on commit 8306396

Please sign in to comment.