Skip to content

Commit

Permalink
add configure for auto push
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemaio committed Feb 26, 2024
1 parent 266eceb commit d20e2c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"type": "string",
"default": "/([A-Za-z]+-\\d+)",
"description": "The regex to match ticket numbers in the branch name."
},
"saveMeBaby.pushOnSave": {
"type": "boolean",
"default": true,
"description": "Whether to push to the remote repo on save."
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ export function activate(context: vscode.ExtensionContext) {
const customCommitMessage = config.get("commitMessage") as string;
const ticketRegex = config.get("ticketRegex") as string;
const useTicketRegex = config.get("useTicketRegex") as boolean;
const pushOnSave = config.get("pushOnSave") as boolean;

Presenter.getInstance({
customCommitMessage,
ticketRegex,
useTicketRegex,
pushOnSave,
}).setupCommands(context);
console.log('Congratulations, your extension "save-me-baby" is now active!');
}
Expand Down
9 changes: 7 additions & 2 deletions src/presenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { execSync } from "node:child_process";
interface PresenterInput {
customCommitMessage: string | undefined;
ticketRegex: string;
useTicketRegex: boolean
useTicketRegex: boolean;
pushOnSave: boolean;
}

export class Presenter {
Expand All @@ -24,6 +25,7 @@ export class Presenter {
private customCommitMessage: string | undefined;
private ticketRegex: string;
private useTicketRegex: boolean;
private pushOnSave: boolean;

// Hold onSalve listener object
onSaveListener = false;
Expand All @@ -32,6 +34,7 @@ export class Presenter {
this.customCommitMessage = input.customCommitMessage;
this.ticketRegex = input.ticketRegex;
this.useTicketRegex = input.useTicketRegex;
this.pushOnSave = input.pushOnSave;
}

static getInstance(input: PresenterInput): Presenter {
Expand All @@ -55,7 +58,9 @@ export class Presenter {
startGitCommit(logMsg, file, (commitStatus) => {
if (commitStatus.status === "Comitted") {
//start git push
gitPush(getParentDir(file));
if (this.pushOnSave) {
gitPush(getParentDir(file));
}
} else if (commitStatus.status === "Error") {
//show popup of error
vscode.window.showErrorMessage(
Expand Down

0 comments on commit d20e2c7

Please sign in to comment.