Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6401 Support to "alwaysSignOff" commits #6402

Merged
merged 1 commit into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/git/src/browser/git-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { GitErrorHandler } from '../browser/git-error-handler';
import { ScmWidget } from '@theia/scm/lib/browser/scm-widget';
import { ScmResource, ScmCommand } from '@theia/scm/lib/browser/scm-provider';
import { ProgressService } from '@theia/core/lib/common/progress-service';
import { GitPreferences } from './git-preferences';

export const EDITOR_CONTEXT_MENU_GIT = [...EDITOR_CONTEXT_MENU, '3_git'];

Expand Down Expand Up @@ -207,6 +208,7 @@ export class GitContribution implements CommandContribution, MenuContribution, T
@inject(GitErrorHandler) protected readonly gitErrorHandler: GitErrorHandler;
@inject(CommandRegistry) protected readonly commands: CommandRegistry;
@inject(ProgressService) protected readonly progressService: ProgressService;
@inject(GitPreferences) protected readonly gitPreferences: GitPreferences;

onStart(): void {
this.updateStatusBar();
Expand Down Expand Up @@ -690,7 +692,8 @@ export class GitContribution implements CommandContribution, MenuContribution, T
scmRepository.input.issue = undefined;
try {
// We can make sure, repository exists, otherwise we would not have this button.
const { signOff, amend } = options;
const amend = options.amend;
const signOff = options.signOff || this.gitPreferences['git.alwaysSignOff'];
const repository = scmRepository.provider.repository;
await this.git.commit(repository, message, { signOff, amend });
scmRepository.input.value = '';
Expand Down
6 changes: 6 additions & 0 deletions packages/git/src/browser/git-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export const GitConfigSchema: PreferenceSchema = {
'type': 'number',
'description': 'Do not show dirty diff decorations, if editor\'s line count exceeds this limit.',
'default': 1000
},
'git.alwaysSignOff': {
'type': 'boolean',
'description': 'Always sign off commits.',
'default': false
}
}
};
Expand All @@ -48,6 +53,7 @@ export interface GitConfiguration {
'git.decorations.colors': boolean,
'git.editor.decorations.enabled': boolean,
'git.editor.dirtyDiff.linesLimit': number,
'git.alwaysSignOff': boolean
}

export const GitPreferences = Symbol('GitPreferences');
Expand Down
2 changes: 2 additions & 0 deletions packages/git/src/browser/git-repository-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
import { GitScmProvider } from './git-scm-provider';
import { EditorManager } from '@theia/editor/lib/browser';
import { GitErrorHandler } from './git-error-handler';
import { GitPreferences } from './git-preferences';
const expect = chai.expect;

disableJSDOM();
Expand Down Expand Up @@ -106,6 +107,7 @@ describe('GitRepositoryProvider', () => {
testContainer.bind(GitErrorHandler).toConstantValue(<GitErrorHandler>{});
testContainer.bind(CommandService).toConstantValue(<CommandService>{});
testContainer.bind(LabelProvider).toConstantValue(<LabelProvider>{});
testContainer.bind(GitPreferences).toConstantValue(<GitPreferences>{});

sinon.stub(mockWorkspaceService, 'onWorkspaceChanged').value(mockRootChangeEmitter.event);
sinon.stub(mockFileSystemWatcher, 'onFilesChanged').value(mockFileChangeEmitter.event);
Expand Down