Wrap long lines
* git-review: Long lines of output are wrapped for readability. Change-Id: I63c01585a28137b2a09557c0a41589348c23ebbb
This commit is contained in:
parent
08f878bc02
commit
fed8751db7
42
git-review
42
git-review
@ -25,6 +25,7 @@ import re
|
|||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import textwrap
|
||||||
import time
|
import time
|
||||||
|
|
||||||
if sys.version < '3':
|
if sys.version < '3':
|
||||||
@ -100,6 +101,10 @@ class ChangeSetException(GitReviewException):
|
|||||||
return self.__doc__ % self.e
|
return self.__doc__ % self.e
|
||||||
|
|
||||||
|
|
||||||
|
def printwrap(unwrapped):
|
||||||
|
print('\n'.join(textwrap.wrap(unwrapped)))
|
||||||
|
|
||||||
|
|
||||||
def parse_review_number(review):
|
def parse_review_number(review):
|
||||||
parts = review.split(',')
|
parts = review.split(',')
|
||||||
if len(parts) < 2:
|
if len(parts) < 2:
|
||||||
@ -349,8 +354,9 @@ def add_remote(hostname, port, project, remote):
|
|||||||
|
|
||||||
if asked_for_username:
|
if asked_for_username:
|
||||||
print()
|
print()
|
||||||
print("This repository is now set up for use with git-review.")
|
printwrap("This repository is now set up for use with git-review. "
|
||||||
print("You can set the default username for future repositories with:")
|
"You can set the default username for future repositories "
|
||||||
|
"with:")
|
||||||
print(' git config --global --add gitreview.username "%s"' % username)
|
print(' git config --global --add gitreview.username "%s"' % username)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
@ -473,9 +479,9 @@ def check_remote(branch, remote, hostname, port, project):
|
|||||||
|
|
||||||
if hostname is False or port is False or project is False:
|
if hostname is False or port is False or project is False:
|
||||||
# This means there was no .gitreview file
|
# This means there was no .gitreview file
|
||||||
print("No '.gitreview' file found in this repository.")
|
printwrap("No '.gitreview' file found in this repository. We don't "
|
||||||
print("We don't know where your gerrit is. Please manually create ")
|
"know where your gerrit is. Please manually create a remote "
|
||||||
print("a remote named \"%s\" and try again." % remote)
|
"named \"%s\" and try again." % remote)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Gerrit remote not present, try to add it
|
# Gerrit remote not present, try to add it
|
||||||
@ -483,8 +489,8 @@ def check_remote(branch, remote, hostname, port, project):
|
|||||||
add_remote(hostname, port, project, remote)
|
add_remote(hostname, port, project, remote)
|
||||||
except Exception:
|
except Exception:
|
||||||
print(sys.exc_info()[2])
|
print(sys.exc_info()[2])
|
||||||
print("We don't know where your gerrit is. Please manually create ")
|
printwrap("We don't know where your gerrit is. Please manually create "
|
||||||
print("a remote named \"%s\" and try again." % remote)
|
"a remote named \"%s\" and try again." % remote)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@ -564,22 +570,22 @@ def assert_one_change(remote, branch, yes, have_hook):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
output_lines = len(output.split("\n"))
|
output_lines = len(output.split("\n"))
|
||||||
if output_lines == 1 and not have_hook:
|
if output_lines == 1 and not have_hook:
|
||||||
print("Your change was committed before the commit hook was installed")
|
printwrap("Your change was committed before the commit hook was "
|
||||||
print("Amending the commit to add a gerrit change id")
|
"installed. Amending the commit to add a gerrit change id.")
|
||||||
run_command("git commit --amend", GIT_EDITOR='true')
|
run_command("git commit --amend", GIT_EDITOR='true')
|
||||||
elif output_lines == 0:
|
elif output_lines == 0:
|
||||||
print("No changes between HEAD and %s/%s." % (remote, branch))
|
printwrap("No changes between HEAD and %s/%s. Submitting for review "
|
||||||
print("Submitting for review would be pointless.")
|
"would be pointless." % (remote, branch))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif output_lines > 1:
|
elif output_lines > 1:
|
||||||
if not yes:
|
if not yes:
|
||||||
print("You are about to submit multiple commits. This is expected"
|
printwrap("You are about to submit multiple commits. This is "
|
||||||
" if you are submitting a commit that is dependant on one"
|
"expected if you are submitting a commit that is "
|
||||||
" or more in-review commits. Otherwise you should consider"
|
"dependent on one or more in-review commits. Otherwise "
|
||||||
" squashing your changes into one commit before"
|
"you should consider squashing your changes into one "
|
||||||
" submitting.")
|
"commit before submitting.")
|
||||||
print("The outstanding commits are:\n\n%s\n" % output)
|
print("\nThe outstanding commits are:\n\n%s\n\n"
|
||||||
print("Do you really want to submit the above commits?")
|
"Do you really want to submit the above commits?" % output)
|
||||||
yes_no = do_input("Type 'yes' to confirm, other to cancel: ")
|
yes_no = do_input("Type 'yes' to confirm, other to cancel: ")
|
||||||
if yes_no.lower().strip() != "yes":
|
if yes_no.lower().strip() != "yes":
|
||||||
print("Aborting.")
|
print("Aborting.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user