diff options
author | Shawn O. Pearce <sop@google.com> | 2009-04-17 12:11:24 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-04-17 12:11:24 -0700 |
commit | a608fb024ba0d6b1534e514e3ad2265a9f187182 (patch) | |
tree | c0f7e2f688fd78eeb0a4a70585968c5aa1fd6404 /subcmds/upload.py | |
parent | f8e3273decd883f334939cb24e542d47aba21a43 (diff) | |
download | git-repo-a608fb024ba0d6b1534e514e3ad2265a9f187182.tar.gz |
Allow review.URL.autoupload to skip prompting during `repo upload`
If review.URL.autoupload is set to true in a project's .git/config
or in ~/.gitconfig then `repo upload` will automatically upload,
and skip prompting the end-user.
Conversely, if review.URL.autoupload is set to false, then repo
will refuse to upload to that project.
Bug: REPO-25
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r-- | subcmds/upload.py | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index 3e664056..6a98a8bd 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -61,6 +61,28 @@ existing change(s) in Gerrit match up to the commits in the branch | |||
61 | being uploaded. For each matched pair of change,commit the commit | 61 | being uploaded. For each matched pair of change,commit the commit |
62 | will be added as a new patch set, completely replacing the set of | 62 | will be added as a new patch set, completely replacing the set of |
63 | files and description associated with the change in Gerrit. | 63 | files and description associated with the change in Gerrit. |
64 | |||
65 | Configuration | ||
66 | ------------- | ||
67 | |||
68 | review.URL.autoupload: | ||
69 | |||
70 | To disable the "Upload ... (y/n)?" prompt, you can set a per-project | ||
71 | or global Git configuration option. If review.URL.autoupload is set | ||
72 | to "true" then repo will assume you always answer "y" at the prompt, | ||
73 | and will not prompt you further. If it is set to "false" then repo | ||
74 | will assume you always answer "n", and will abort. | ||
75 | |||
76 | The URL must match the review URL listed in the manifest XML file, | ||
77 | or in the .git/config within the project. For example: | ||
78 | |||
79 | [remote "origin"] | ||
80 | url = git://git.example.com/project.git | ||
81 | review = http://review.example.com/ | ||
82 | |||
83 | [review "http://review.example.com/"] | ||
84 | autoupload = true | ||
85 | |||
64 | """ | 86 | """ |
65 | 87 | ||
66 | def _Options(self, p): | 88 | def _Options(self, p): |
@@ -79,19 +101,29 @@ files and description associated with the change in Gerrit. | |||
79 | name = branch.name | 101 | name = branch.name |
80 | date = branch.date | 102 | date = branch.date |
81 | list = branch.commits | 103 | list = branch.commits |
104 | remote = project.GetBranch(name).remote | ||
105 | |||
106 | key = 'review.%s.autoupload' % remote.review | ||
107 | answer = project.config.GetBoolean(key) | ||
108 | |||
109 | if answer is False: | ||
110 | _die("upload blocked by %s = false" % key) | ||
111 | |||
112 | if answer is None: | ||
113 | print 'Upload project %s/:' % project.relpath | ||
114 | print ' branch %s (%2d commit%s, %s):' % ( | ||
115 | name, | ||
116 | len(list), | ||
117 | len(list) != 1 and 's' or '', | ||
118 | date) | ||
119 | for commit in list: | ||
120 | print ' %s' % commit | ||
121 | |||
122 | sys.stdout.write('(y/n)? ') | ||
123 | answer = sys.stdin.readline().strip() | ||
124 | answer = answer in ('y', 'Y', 'yes', '1', 'true', 't') | ||
82 | 125 | ||
83 | print 'Upload project %s/:' % project.relpath | 126 | if answer: |
84 | print ' branch %s (%2d commit%s, %s):' % ( | ||
85 | name, | ||
86 | len(list), | ||
87 | len(list) != 1 and 's' or '', | ||
88 | date) | ||
89 | for commit in list: | ||
90 | print ' %s' % commit | ||
91 | |||
92 | sys.stdout.write('(y/n)? ') | ||
93 | answer = sys.stdin.readline().strip() | ||
94 | if answer in ('y', 'Y', 'yes', '1', 'true', 't'): | ||
95 | self._UploadAndReport([branch], people) | 127 | self._UploadAndReport([branch], people) |
96 | else: | 128 | else: |
97 | _die("upload aborted by user") | 129 | _die("upload aborted by user") |