Skip to content

Commit

Permalink
#6401 Support to "alwayssignoff" commitsSigned-off-by: Jonas Helming …
Browse files Browse the repository at this point in the history
…<jhelming@eclipsesource.com>

Signed-off-by: Jonas Helming <jhelming@eclipsesource.com>
  • Loading branch information
JonasHelming authored and kittaakos committed Nov 20, 2019
1 parent 2bfbe4a commit 21da05e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
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

0 comments on commit 21da05e

Please sign in to comment.