Skip to content

Commit

Permalink
Fix the wrong CLA link for the translation PR (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiancai authored Dec 13, 2023
1 parent a5b222b commit 16a4d00
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions gh-util.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,16 @@
}

// This function can be used to modify the description of the translation PR
function UpdatePRDescription(sourceRepoOwner, sourceRepoName, sourcePRNumber, sourceDescription, baseRepo, targetRepoName) {
const sourcePRCLA = "https://cla-assistant.io/pingcap/" + baseRepo;
function UpdatePRDescription(sourceRepoOwner, sourceRepoName, sourcePRNumber, sourceDescription, targetRepoName) {
const sourcePRCLA = "https://cla-assistant.io/pingcap/" + sourceRepoName;
const newPRCLA = "https://cla-assistant.io/pingcap/" + targetRepoName;
const sourcePRURL = `https://github.com/${sourceRepoOwner}/${sourceRepoName}/pull/${sourcePRNumber}`;
let newPRDescription = sourceDescription.replace(sourcePRCLA, newPRCLA);

newPRDescription = newPRDescription.replace("This PR is translated from:", "This PR is translated from: " + sourcePRURL);

if (sourceDescription.includes("tips for choosing the affected versions")) {
newPRDescription = newPRDescription.replace(/.*?\[tips for choosing the affected version.*?\n\n?/, "");
}
const regexConstructor = new RegExp(".*?\\[tips for choosing the affected versions.*?\\n\\n?", "g");
newPRDescription = newPRDescription.replace(regexConstructor, "");
console.log(newPRDescription)

return newPRDescription;
}
Expand Down Expand Up @@ -395,7 +394,7 @@
await CreateFileInBranch(octokit, messageTextElement, myRepoOwner, myRepoName, newBranchName, filePath, FileContent, CommitMessage);
//6. Create a pull request
const title = sourceTitle;
const body = UpdatePRDescription(currentRepoOwner, currentRepoName, currentPRNumber, sourceDescription, baseRepo, targetRepoName);
const body = UpdatePRDescription(currentRepoOwner, currentRepoName, currentPRNumber, sourceDescription, targetRepoName);
targetLabels.push(translationLabel);
const labels = targetLabels;
const targetPRURL = await CreatePullRequest(octokit, messageTextElement, targetRepoOwner, targetRepoName, baseBranch, myRepoOwner, myRepoName, newBranchName, title, body, labels);
Expand Down

0 comments on commit 16a4d00

Please sign in to comment.