Преглед изворни кода

fail gracefully if git new-branch is called in cog

Bug: 339231299
Change-Id: I21084c12815c82f7c0a90b5755de4d5551b6d94d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5540434
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Yiwei Zhang пре 1 година
родитељ
комит
da41d62982
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      git_new_branch.py

+ 5 - 0
git_new_branch.py

@@ -9,6 +9,7 @@ Create new branch tracking origin HEAD by default.
 import argparse
 import sys
 
+import gclient_utils
 import git_common
 import subprocess2
 
@@ -52,6 +53,10 @@ def create_new_branch(branch_name,
 
 
 def main(args):
+    if gclient_utils.IsEnvCog():
+        print('new-branch command is not supported in non-git environment.',
+              file=sys.stderr)
+        return 1
     parser = argparse.ArgumentParser(
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         description=__doc__,