From 885f65199c20eef7233dd9d46db4e5bf8ea16db5 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Sat, 27 Jul 2013 02:17:26 +0000 Subject: [PATCH] Disable colors if not a tty. Otherwise this breaks git cl unit tests. Update references to 'git cl' in git cl smoke tests to $GIT_CL. TBR=ilevy@chromium.org BUG= Review URL: https://chromiumcodereview.appspot.com/20888002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@214019 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 6 +++++- tests/basic.sh | 2 +- tests/patch.sh | 2 +- tests/push-basic.sh | 2 +- tests/push-from-logs.sh | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/git_cl.py b/git_cl.py index 1dcb1fe8c..0ac0f861c 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1169,8 +1169,12 @@ def CMDstatus(parser, args): b, i, color = output.get() tmp[b] = (i, color) issue, color = tmp.pop(branch) + reset = Fore.RESET + if not sys.stdout.isatty(): + color = '' + reset = '' print ' %*s: %s%s%s' % ( - alignment, ShortBranchName(branch), color, issue, Fore.RESET) + alignment, ShortBranchName(branch), color, issue, reset) cl = Changelist() print diff --git a/tests/basic.sh b/tests/basic.sh index 430ce29c4..edf1cb8d7 100755 --- a/tests/basic.sh +++ b/tests/basic.sh @@ -54,7 +54,7 @@ setup_gitsvn "git show | grep -q 'foo-quux'" test_expect_success "issue no longer has a branch" \ - "git cl status | grep -q 'work: None'" + "$GIT_CL status | grep -q 'work: None'" test_expect_success "upstream svn has our commit" \ "svn log $REPO_URL 2>/dev/null | grep -q 'foo-quux'" diff --git a/tests/patch.sh b/tests/patch.sh index 84254b22c..6a70b0eea 100755 --- a/tests/patch.sh +++ b/tests/patch.sh @@ -33,7 +33,7 @@ setup_gitsvn git checkout -q -b test2 master - test_expect_success "git cl patch $ISSUE" + test_expect_success "$GIT_CL patch $ISSUE" ) SUCCESS=$? diff --git a/tests/push-basic.sh b/tests/push-basic.sh index 0a63c73ae..1c3c696e6 100755 --- a/tests/push-basic.sh +++ b/tests/push-basic.sh @@ -57,7 +57,7 @@ setup_gitgit "git show | grep -q 'foo-quux'" test_expect_success "issue no longer has a branch" \ - "git cl status | grep -q 'work: None'" + "$GIT_CL status | grep -q 'work: None'" cd $GITREPO_PATH test_expect_success "upstream repo has our commit" \ diff --git a/tests/push-from-logs.sh b/tests/push-from-logs.sh index bb15c3fa0..e68b3d246 100755 --- a/tests/push-from-logs.sh +++ b/tests/push-from-logs.sh @@ -56,7 +56,7 @@ setup_gitgit "git show | [ $( egrep -q '^branch work$' -c ) -eq 2 ] test_expect_success "issue no longer has a branch" \ - "git cl status | grep -q 'work: None'" + "$GIT_CL status | grep -q 'work: None'" cd $GITREPO_PATH test_expect_success "upstream repo has our commit" \