diff --git a/package.json b/package.json index 33470215..32b07ab8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "git-graph-2", "displayName": "Git Graph 2", - "version": "1.31.6", + "version": "1.31.6-alpha-1", "publisher": "hansu", "author": { "name": "Michael Hutchison", diff --git a/src/baseGitGraphView.ts b/src/baseGitGraphView.ts index 4cf8de6b..5f517925 100644 --- a/src/baseGitGraphView.ts +++ b/src/baseGitGraphView.ts @@ -264,7 +264,7 @@ export abstract class BaseGitGraphView extends Disposable { }); break; case 'createPullRequest': - errorInfos = [msg.push ? await this.dataSource.pushBranch(msg.repo, msg.sourceBranch, msg.sourceRemote, true, GitPushBranchMode.Normal) : null]; + errorInfos = [msg.push ? await this.dataSource.pushBranch(msg.repo, msg.sourceBranch, msg.sourceRemote, true, GitPushBranchMode.Normal, false) : null]; if (errorInfos[0] === null) { errorInfos.push(await createPullRequest(msg.config, msg.sourceOwner, msg.sourceRepo, msg.sourceBranch)); } @@ -493,7 +493,7 @@ export abstract class BaseGitGraphView extends Disposable { this.sendMessage({ command: 'pushBranch', willUpdateBranchConfig: msg.willUpdateBranchConfig, - errors: await this.dataSource.pushBranchToMultipleRemotes(msg.repo, msg.branchName, msg.remotes, msg.setUpstream, msg.mode) + errors: await this.dataSource.pushBranchToMultipleRemotes(msg.repo, msg.branchName, msg.remotes, msg.setUpstream, msg.mode, msg.noVerify) }); break; case 'pushStash': @@ -558,7 +558,7 @@ export abstract class BaseGitGraphView extends Disposable { case 'editCommitMessage': this.sendMessage({ command: 'editCommitMessage', - error: await this.dataSource.editCommitMessage(msg.repo, msg.commitHash, msg.message) + error: await this.dataSource.editCommitMessage(msg.repo, msg.commitHash, msg.message, msg.noVerify) }); break; case 'setGlobalViewState': diff --git a/src/dataSource.ts b/src/dataSource.ts index c5297445..92c1e056 100644 --- a/src/dataSource.ts +++ b/src/dataSource.ts @@ -817,11 +817,12 @@ export class DataSource extends Disposable { * @param mode The mode of the push. * @returns The ErrorInfo from the executed command. */ - public pushBranch(repo: string, branchName: string, remote: string, setUpstream: boolean, mode: GitPushBranchMode) { + public pushBranch(repo: string, branchName: string, remote: string, setUpstream: boolean, mode: GitPushBranchMode, noVerify: boolean) { let args = ['push']; args.push(remote, branchName); if (setUpstream) args.push('--set-upstream'); if (mode !== GitPushBranchMode.Normal) args.push('--' + mode); + if (noVerify) args.push('--no-verify'); return this.runGitCommand(args, repo); } @@ -835,14 +836,14 @@ export class DataSource extends Disposable { * @param mode The mode of the push. * @returns The ErrorInfo's from the executed commands. */ - public async pushBranchToMultipleRemotes(repo: string, branchName: string, remotes: string[], setUpstream: boolean, mode: GitPushBranchMode): Promise { + public async pushBranchToMultipleRemotes(repo: string, branchName: string, remotes: string[], setUpstream: boolean, mode: GitPushBranchMode, noVerify: boolean): Promise { if (remotes.length === 0) { return ['No remote(s) were specified to push the branch ' + branchName + ' to.']; } const results: ErrorInfo[] = []; for (let i = 0; i < remotes.length; i++) { - const result = await this.pushBranch(repo, branchName, remotes[i], setUpstream, mode); + const result = await this.pushBranch(repo, branchName, remotes[i], setUpstream, mode, noVerify); results.push(result); if (result !== null) break; } @@ -1194,6 +1195,7 @@ export class DataSource extends Disposable { * @returns The ErrorInfo from the executed command. */ public async squashCommits(repo: string, commits: ReadonlyArray, commitMessage: string): Promise { + if (commits.length < 2) { return 'At least 2 commits are required for squashing.'; } @@ -1261,7 +1263,7 @@ export class DataSource extends Disposable { * @param message The new commit message. * @returns The ErrorInfo from the executed command. */ - public async editCommitMessage(repo: string, commitHash: string, message: string): Promise { + public async editCommitMessage(repo: string, commitHash: string, message: string, noVerify: boolean): Promise { try { const headCommit = await this.spawnGit(['rev-parse', 'HEAD'], repo, (stdout) => stdout.trim()); @@ -1270,6 +1272,8 @@ export class DataSource extends Disposable { if (getConfig().signCommits) { args.push('-S'); } + if (noVerify) args.push('--no-verify'); + return this.runGitCommand(args, repo); } else { return this.rebaseEditCommitMessage(repo, commitHash, message); diff --git a/src/types.ts b/src/types.ts index 664dd257..cb24c4a6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1096,6 +1096,7 @@ export interface RequestPushBranch extends RepoRequest { readonly branchName: string; readonly remotes: string[]; readonly setUpstream: boolean; + readonly noVerify: boolean; readonly mode: GitPushBranchMode; readonly willUpdateBranchConfig: boolean; } @@ -1200,6 +1201,7 @@ export interface RequestEditCommitMessage extends RepoRequest { readonly command: 'editCommitMessage'; readonly commitHash: string; readonly message: string; + readonly noVerify: boolean; } export interface ResponseEditCommitMessage extends ResponseWithErrorInfo { readonly command: 'editCommitMessage'; diff --git a/web/main.ts b/web/main.ts index 31c14bde..296f0ac4 100644 --- a/web/main.ts +++ b/web/main.ts @@ -1033,7 +1033,8 @@ class GitGraphView { name: 'Commit Message', default: commit.message, placeholder: 'Enter the new commit message' - }], + }, + { type: DialogInputType.Checkbox, name: 'No Verify', value: false }], 'Update Message', (values) => { const newMessage = values[0]; @@ -1048,7 +1049,8 @@ class GitGraphView { command: 'editCommitMessage', repo: this.currentRepo, commitHash: hash, - message: newMessage + message: newMessage, + noVerify: values[1] }, 'Editing Commit Message'); }, target @@ -1322,7 +1324,8 @@ class GitGraphView { { name: 'Force', value: GG.GitPushBranchMode.Force } ], default: GG.GitPushBranchMode.Normal - } + }, + { type: DialogInputType.Checkbox, name: 'No Verify', value: false } ]; if (multipleRemotes) { @@ -1338,6 +1341,7 @@ class GitGraphView { dialog.showForm('Are you sure you want to push the branch ' + escapeHtml(refName) + '' + (multipleRemotes ? '' : ' to the remote ' + escapeHtml(this.gitRemotes[0]) + '') + '?', inputs, 'Yes, push', (values) => { const remotes = multipleRemotes ? values.shift() : [this.gitRemotes[0]]; const setUpstream = values[0]; + const noVerify = values[2]; runAction({ command: 'pushBranch', repo: this.currentRepo, @@ -1345,6 +1349,7 @@ class GitGraphView { remotes: remotes, setUpstream: setUpstream, mode: values[1], + noVerify: noVerify, willUpdateBranchConfig: setUpstream && remotes.length > 0 && (this.gitConfig === null || typeof this.gitConfig.branches[refName] === 'undefined' || this.gitConfig.branches[refName].remote !== remotes[remotes.length - 1]) }, 'Pushing Branch'); }, target);