Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1254 from atom/mkt-never-use-color
Browse files Browse the repository at this point in the history
Disable all relevant color options when executing Git commands
  • Loading branch information
BinaryMuse committed Nov 27, 2017
2 parents 0925039 + 773c43b commit abc8bc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/git-shell-out-strategy.js
Expand Up @@ -41,6 +41,13 @@ export class LargeRepoError extends Error {
}
}

const DISABLE_COLOR_FLAGS = [
'branch', 'diff', 'showBranch', 'status', 'ui',
].reduce((acc, type) => {
acc.unshift('-c', `color.${type}=false`);
return acc;
}, []);

export default class GitShellOutStrategy {
static defaultExecArgs = {
stdin: null,
Expand Down Expand Up @@ -79,6 +86,8 @@ export default class GitShellOutStrategy {

// Execute a command and read the output using the embedded Git environment
async exec(args, options = GitShellOutStrategy.defaultExecArgs) {
args.unshift(...DISABLE_COLOR_FLAGS);

/* eslint-disable no-console */
const {stdin, useGitPromptServer, useGpgWrapper, useGpgAtomPrompt, writeOperation} = options;
const subscriptions = new CompositeDisposable();
Expand Down
2 changes: 1 addition & 1 deletion test/models/repository.test.js
Expand Up @@ -830,7 +830,7 @@ describe('Repository', function() {
await repo.abortMerge();
assert.fail(null, null, 'repo.abortMerge() unexepctedly succeeded');
} catch (e) {
assert.match(e.command, /^git merge --abort/);
assert.match(e.command, /^git .* merge --abort/);
}
assert.equal(await repo.isMerging(), true);
assert.deepEqual(await repo.getStagedChanges(), stagedChanges);
Expand Down

0 comments on commit abc8bc9

Please sign in to comment.