From cf7c0834cfc24c5c9584695c657c6baf97d0fbb3 Mon Sep 17 00:00:00 2001 From: Akshay Verma Date: Thu, 15 Mar 2018 21:56:30 +0530 Subject: Download latest patch when no patch is specified When someone does "repo download -c " without specifying a patch number, by default patch 1 is downloaded. An alternative is to look for the latest patch and download the same when no explicit patch is given. This commit does the same by identifying the latest patch using "git ls-remote". Change-Id: Ia5fa7364415f53a3d9436df4643e38f3c90ded58 --- subcmds/download.py | 8 ++++++++ 1 file changed, 8 insertions(+) mode change 100644 => 100755 subcmds/download.py (limited to 'subcmds') diff --git a/subcmds/download.py b/subcmds/download.py old mode 100644 new mode 100755 index e1010aa2..384af781 --- a/subcmds/download.py +++ b/subcmds/download.py @@ -62,6 +62,14 @@ If no project is specified try to use current directory as a project. ps_id = int(m.group(2)) else: ps_id = 1 + regex = r'refs/changes/%2.2d/%d/(\d+)' % (chg_id % 100, chg_id) + output = project._LsRemote() + if output: + rcomp = re.compile(regex, re.I) + for line in output.splitlines(): + match = rcomp.search(line) + if match: + ps_id = max(int(match.group(1)), ps_id) to_get.append((project, chg_id, ps_id)) else: project = self.GetProjects([a])[0] -- cgit v1.2.3-54-g00ecf