mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor: Fix branch name generation in CopilotActionsBase.ts
The branch name generation in CopilotActionsBase.ts has been fixed to replace double hyphens with a single hyphen. This ensures that the branch name is correctly formatted and avoids any potential issues with branch creation and management.
This commit is contained in:
@@ -40,7 +40,7 @@ export default class CopilotActionBase {
|
||||
|
||||
public async getBranchName(): Promise<string> {
|
||||
const randomText: string = Text.generateRandomText(5);
|
||||
const bracnhName = `${Text.pascalCaseToDashes(this.copilotActionType).toLowerCase()}-${randomText}`;
|
||||
const bracnhName: string = `${Text.pascalCaseToDashes(this.copilotActionType).toLowerCase()}-${randomText}`;
|
||||
// replace -- with - in the branch name
|
||||
return Text.replaceAll(bracnhName, "--", "-");
|
||||
}
|
||||
@@ -54,7 +54,22 @@ export default class CopilotActionBase {
|
||||
public async getPullRequestBody(data: {
|
||||
vars: CopilotActionVars;
|
||||
}): Promise<string> {
|
||||
return `OneUptime Copilot: ${this.copilotActionType} on ${data.vars.filePath}`;
|
||||
return `OneUptime Copilot: ${this.copilotActionType} on ${data.vars.filePath}
|
||||
|
||||
${this.getDefaultPullRequestBody()}
|
||||
`;
|
||||
}
|
||||
|
||||
public async getDefaultPullRequestBody(): Promise<string> {
|
||||
return `
|
||||
|
||||
#### Warning
|
||||
OneUptime Copilot is an AI tool that improves your code. Please do not rely on it completely. Always review the changes before merging.
|
||||
|
||||
#### Feedback
|
||||
If you have any feedback or suggestions, please let us know. We would love to hear from you. Please contact us at copilot@oneuptime.com.
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
public async getCommitMessage(data: {
|
||||
|
||||
@@ -35,8 +35,6 @@ export default class CopilotActionService {
|
||||
copilotActionType: CopilotActionType;
|
||||
vars: CopilotActionVars;
|
||||
}): Promise<CopilotExecutionResult> {
|
||||
|
||||
|
||||
if (!actionDictionary[data.copilotActionType]) {
|
||||
throw new BadDataException("Invalid CopilotActionType");
|
||||
}
|
||||
@@ -64,9 +62,10 @@ export default class CopilotActionService {
|
||||
let pullRequest: PullRequest | null = null;
|
||||
|
||||
if (result) {
|
||||
|
||||
logger.debug("Obtained result from Copilot Action");
|
||||
logger.debug("Committing the changes to the repository and creating a PR");
|
||||
logger.debug(
|
||||
"Committing the changes to the repository and creating a PR",
|
||||
);
|
||||
|
||||
const branchName: string = CodeRepositoryUtil.getBranchName({
|
||||
branchName: await action.getBranchName(),
|
||||
@@ -133,7 +132,7 @@ export default class CopilotActionService {
|
||||
};
|
||||
}
|
||||
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
logger.debug("No result obtained from Copilot Action");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user