Skip to content

Commit

Permalink
Using target_branch for jira labels when isDeployBeforeMerge flag is …
Browse files Browse the repository at this point in the history
…true (#924) (#960)

* using target branch for jira labels when deploy before merge flag is true (#924)

* updated changelog with jira labels changes (#924)

* Update CHANGELOG.md

* Update package.json

---------

Co-authored-by: Nicolas Vuillamy <[email protected]>
  • Loading branch information
0ptaq0 and nvuillam authored Jan 2, 2025
1 parent bcbffb2 commit 4b442ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image
- Fix init sfdx-hardis project commands and docs
- Display warning message in case package.xml has wrong format
- Allow to override package-no-overwrite from a branch .sfdx-hardis.yml config file
- Using target_branch for Jira labels when isDeployBeforeMerge flag is true

- Doc
- Update Microsoft Teams notifications integration User Guide
Expand Down
14 changes: 13 additions & 1 deletion src/common/ticketProvider/ticketProviderRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { SfError } from "@salesforce/core";
import c from "chalk";
import { Ticket } from "./index.js";
import { getCurrentGitBranch, uxLog } from "../utils/index.js";
import { GitProvider } from "../gitProvider/index.js";

export abstract class TicketProviderRoot {
public isActive = false;
Expand All @@ -25,9 +26,20 @@ export abstract class TicketProviderRoot {
public async getDeploymentTag(): Promise<string> {
const currentGitBranch = await getCurrentGitBranch() || "";
let tag = currentGitBranch.toUpperCase() + "_DEPLOYED";

if (GitProvider.isDeployBeforeMerge()) {
const prInfo = await GitProvider.getPullRequestInfo();
const targetBranch = prInfo?.targetBranch || process.env.FORCE_TARGET_BRANCH;
if (targetBranch) {
tag = targetBranch.toUpperCase() + "_DEPLOYED";
}
}

if (process.env?.DEPLOYED_TAG_TEMPLATE && !(process.env?.DEPLOYED_TAG_TEMPLATE || "").includes("$(")) {
tag = process.env?.DEPLOYED_TAG_TEMPLATE.replace("{BRANCH}", currentGitBranch.toUpperCase());
const branchToUse = tag.replace("_DEPLOYED", "");
tag = process.env?.DEPLOYED_TAG_TEMPLATE.replace("{BRANCH}", branchToUse);
}

return tag;
}
}

0 comments on commit 4b442ef

Please sign in to comment.