Merge branch 'stable-2.6'
* stable-2.6: Fix ls-user-refs command name in documentation Mark project and user options as required for LsUserRefs Fix setting account's full name via ssh TrivialRebase: tidy up docstrings to follow PEP-0257 Change-Id: Ibd4563a8418e823d700082bc4fbcf465085d4719
This commit is contained in:
@@ -8,7 +8,7 @@ gerrit ls-user-refs - List refs visible to a specific user
|
|||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'ssh' -p <port> <host> 'gerrit ls-user-ref'
|
'ssh' -p <port> <host> 'gerrit ls-user-refs'
|
||||||
[--project PROJECT> | -p <PROJECT>]
|
[--project PROJECT> | -p <PROJECT>]
|
||||||
[--user <USER> | -u <USER>]
|
[--user <USER> | -u <USER>]
|
||||||
[--only-refs-heads]
|
[--only-refs-heads]
|
||||||
@@ -31,11 +31,11 @@ OPTIONS
|
|||||||
-------
|
-------
|
||||||
--project::
|
--project::
|
||||||
-p::
|
-p::
|
||||||
Name of the project for which the refs should be listed.
|
Required; Name of the project for which the refs should be listed.
|
||||||
|
|
||||||
--user::
|
--user::
|
||||||
-u::
|
-u::
|
||||||
User for which the visible refs should be listed. Gerrit
|
Required; User for which the visible refs should be listed. Gerrit
|
||||||
will query the database to find matching users, so the
|
will query the database to find matching users, so the
|
||||||
full identity/name does not need to be specified.
|
full identity/name does not need to be specified.
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,14 @@
|
|||||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
# This script is designed to detect when a patchset uploaded to Gerrit is
|
""" This script is designed to detect when a patchset uploaded to Gerrit is
|
||||||
# 'identical' (determined via git-patch-id) and reapply reviews onto the new
|
'identical' (determined via git-patch-id) and reapply reviews onto the new
|
||||||
# patchset from the previous patchset.
|
patchset from the previous patchset.
|
||||||
|
|
||||||
# Get usage and help info by running: ./trivial_rebase.py --help
|
Get usage and help info by running: ./trivial_rebase.py --help
|
||||||
# Documentation is available here: https://www.codeaurora.org/xwiki/bin/QAEP/Gerrit
|
Documentation is available here: https://www.codeaurora.org/xwiki/bin/QAEP/Gerrit
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
@@ -88,6 +90,7 @@ class TrivialRebase:
|
|||||||
"""Like subprocess.check_call() but returns stdout.
|
"""Like subprocess.check_call() but returns stdout.
|
||||||
|
|
||||||
Works on python 2.4
|
Works on python 2.4
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
process = subprocess.Popen(command, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.Popen(command, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
@@ -99,7 +102,7 @@ class TrivialRebase:
|
|||||||
return std_out, std_err
|
return std_out, std_err
|
||||||
|
|
||||||
def GsqlQuery(self, sql_query):
|
def GsqlQuery(self, sql_query):
|
||||||
"""Runs a gerrit gsql query and returns the result"""
|
"""Run a gerrit gsql query and return the result."""
|
||||||
gsql_cmd = [self.ssh, self.ssh_port_flag, self.port, self.server, 'gerrit', 'gsql',
|
gsql_cmd = [self.ssh, self.ssh_port_flag, self.port, self.server, 'gerrit', 'gsql',
|
||||||
'--format', 'JSON', '-c', sql_query]
|
'--format', 'JSON', '-c', sql_query]
|
||||||
try:
|
try:
|
||||||
@@ -113,7 +116,7 @@ class TrivialRebase:
|
|||||||
return new_out.split('split here\n')
|
return new_out.split('split here\n')
|
||||||
|
|
||||||
def FindPrevRev(self):
|
def FindPrevRev(self):
|
||||||
"""Finds the revision of the previous patch set on the change"""
|
"""Find the revision of the previous patch set on the change."""
|
||||||
sql_query = ("\"SELECT revision FROM patch_sets WHERE "
|
sql_query = ("\"SELECT revision FROM patch_sets WHERE "
|
||||||
"change_id = %s AND patch_set_id = %s\"" %
|
"change_id = %s AND patch_set_id = %s\"" %
|
||||||
(self.changeId, (self.patchset - 1)))
|
(self.changeId, (self.patchset - 1)))
|
||||||
@@ -123,9 +126,11 @@ class TrivialRebase:
|
|||||||
return json_dict["columns"]["revision"]
|
return json_dict["columns"]["revision"]
|
||||||
|
|
||||||
def GetApprovals(self):
|
def GetApprovals(self):
|
||||||
"""Get all the approvals on a specific patch set
|
"""Get all the approvals on a specific patch set.
|
||||||
|
|
||||||
Returns a list of approval dicts"""
|
Returns a list of approval dicts.
|
||||||
|
|
||||||
|
"""
|
||||||
sql_query = ("\"SELECT value,account_id,category_id FROM patch_set_approvals "
|
sql_query = ("\"SELECT value,account_id,category_id FROM patch_set_approvals "
|
||||||
"WHERE change_id = %s AND patch_set_id = %s AND value != 0\""
|
"WHERE change_id = %s AND patch_set_id = %s AND value != 0\""
|
||||||
% (self.changeId, (self.patchset - 1)))
|
% (self.changeId, (self.patchset - 1)))
|
||||||
@@ -145,7 +150,7 @@ class TrivialRebase:
|
|||||||
self.acct_approvals[account_id] = newval
|
self.acct_approvals[account_id] = newval
|
||||||
|
|
||||||
def GetEmailFromAcctId(self, account_id):
|
def GetEmailFromAcctId(self, account_id):
|
||||||
"""Returns the preferred email address associated with the account_id"""
|
"""Return the preferred email address associated with the account_id."""
|
||||||
sql_query = ("\"SELECT preferred_email FROM accounts WHERE account_id = %s\""
|
sql_query = ("\"SELECT preferred_email FROM accounts WHERE account_id = %s\""
|
||||||
% account_id)
|
% account_id)
|
||||||
email_addr = self.GsqlQuery(sql_query)
|
email_addr = self.GsqlQuery(sql_query)
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ public class LsUserRefs extends SshCommand {
|
|||||||
private ChangeCache changeCache;
|
private ChangeCache changeCache;
|
||||||
|
|
||||||
@Option(name = "--project", aliases = {"-p"}, metaVar = "PROJECT",
|
@Option(name = "--project", aliases = {"-p"}, metaVar = "PROJECT",
|
||||||
usage = "project for which the refs should be listed")
|
required = true, usage = "project for which the refs should be listed")
|
||||||
private ProjectControl projectControl;
|
private ProjectControl projectControl;
|
||||||
|
|
||||||
@Option(name = "--user", aliases = {"-u"}, metaVar = "USER",
|
@Option(name = "--user", aliases = {"-u"}, metaVar = "USER",
|
||||||
usage = "user for which the groups should be listed")
|
required = true, usage = "user for which the groups should be listed")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
@Option(name = "--only-refs-heads", usage = "list only refs under refs/heads")
|
@Option(name = "--only-refs-heads", usage = "list only refs under refs/heads")
|
||||||
@@ -73,10 +73,6 @@ public class LsUserRefs extends SshCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Failure {
|
protected void run() throws Failure {
|
||||||
if (userName == null || projectControl == null) {
|
|
||||||
throw new UnloggedFailure(1, "fatal: --user and --project options must be used.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Account userAccount = null;
|
Account userAccount = null;
|
||||||
try {
|
try {
|
||||||
userAccount = accountResolver.find(userName);
|
userAccount = accountResolver.find(userName);
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ final class SetAccountCommand extends BaseCommand {
|
|||||||
if (fullName != null) {
|
if (fullName != null) {
|
||||||
if (realm.allowsEdit(FieldName.FULL_NAME)) {
|
if (realm.allowsEdit(FieldName.FULL_NAME)) {
|
||||||
account.setFullName(fullName);
|
account.setFullName(fullName);
|
||||||
|
accountUpdated = true;
|
||||||
} else {
|
} else {
|
||||||
throw new UnloggedFailure(1, "The realm doesn't allow editing names");
|
throw new UnloggedFailure(1, "The realm doesn't allow editing names");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user