Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: git_common.py

Issue 238213006: Abort git tools if git repo has too many local branches. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: change message Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_common_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_common.py
diff --git a/git_common.py b/git_common.py
index d730fed7f9239a4fed47d7ee36391f5dc19024bf..6952c1ee318765ebe40622ec9a7b5d10334c888f 100644
--- a/git_common.py
+++ b/git_common.py
@@ -25,6 +25,7 @@ import re
import signal
import sys
import tempfile
+import textwrap
import threading
import subprocess2
@@ -239,7 +240,27 @@ def branch_config_map(option):
def branches(*args):
NO_BRANCH = ('* (no branch', '* (detached from ')
- for line in run('branch', *args).splitlines():
+
+ key = 'depot-tools.branch-limit'
+ limit = 20
+ try:
+ limit = int(config(key, limit))
+ except ValueError:
+ pass
+
+ raw_branches = run('branch', *args).splitlines()
+
+ num = len(raw_branches)
+ if num > limit:
+ print >> sys.stderr, textwrap.dedent("""\
+ Your git repo has too many branches (%d/%d) for this tool to work well.
+
+ You may adjust this limit by running:
+ git config %s <new_limit>
+ """ % (num, limit, key))
+ sys.exit(1)
+
+ for line in raw_branches:
if line.startswith(NO_BRANCH):
continue
yield line.split()[-1]
« no previous file with comments | « no previous file | tests/git_common_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698