diff options
author | Bill Peck <bpeck@redhat.com> | 2015-05-11 13:17:58 -0400 |
---|---|---|
committer | Bill Peck <bpeck@redhat.com> | 2015-05-11 13:17:58 -0400 |
commit | 6e77de1d8e852071b2b3b2587fb1dd425a920d5d (patch) | |
tree | 960e82d3a4102316c9e5967a94a7a60eac0e956e | |
parent | b05f20ffe45fe2bea2f955bb4d318b86f7bc2f9b (diff) | |
download | taskrepo-6e77de1d8e852071b2b3b2587fb1dd425a920d5d.tar.gz taskrepo-6e77de1d8e852071b2b3b2587fb1dd425a920d5d.tar.xz taskrepo-6e77de1d8e852071b2b3b2587fb1dd425a920d5d.zip |
allow overriding the saved origin when generating the job xml.
-rw-r--r-- | git_taskrepo/sub_commands/cmd_list.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/git_taskrepo/sub_commands/cmd_list.py b/git_taskrepo/sub_commands/cmd_list.py index 20197b0..b8141e7 100644 --- a/git_taskrepo/sub_commands/cmd_list.py +++ b/git_taskrepo/sub_commands/cmd_list.py @@ -25,6 +25,10 @@ class List(Command): default=False, action="store_true", help="Generate job xml") + self.parser.add_option( + "--origin", + metavar="ORIGIN", + help="Specify an alternative ORIGIN to use.") def run(self, *args, **kwargs): self.set_repo(**kwargs) @@ -32,9 +36,14 @@ class List(Command): conn = self.taskrepo with conn: cur = conn.cursor() - cur.execute("SELECT origin FROM config") - result = cur.fetchone() - origin = result[0] + + # Which origin should we use. + if kwargs.get("origin"): + origin = kwargs.get("origin") + else: + cur.execute("SELECT origin FROM config") + result = cur.fetchone() + origin = "%s?%s" % (result[0], self.repo.active_branch.name) values = [] joins = [] @@ -56,7 +65,7 @@ class List(Command): extra = ' '.join(joins) extra = "%s WHERE %s" % (extra, ' AND '.join(where)) - cur.execute("SELECT name, description, owner FROM tasks %s" % extra, values) + cur.execute("SELECT name, description, owner FROM tasks %s ORDER BY name" % extra, values) rows = cur.fetchall() if kwargs.get("job"): xmldoc = xml.dom.minidom.Document() @@ -74,7 +83,7 @@ class List(Command): row[0])) fetch = xmldoc.createElement('fetch') task.appendChild(fetch) - fetch.setAttribute('url', "%s?%s#%s" % (origin, self.repo.active_branch.name, row[0])) + fetch.setAttribute('url', "%s#%s" % (origin, row[0])) else: print "%s\n\t[%s, %s]" % (row[0], row[1], row[2]) if kwargs.get("job"): |