fromupstream: rstrip '/' from remote urls
Strip the trailing '/' from any remote urls before comparing them to the
list of upstream urls. This fixes 'Error: need a valid upstream remote'
that is seen when you make this mistake.
BUG=None
TEST=Used fromupstream.py to merge an upstream patch using a remote with
and without the trailing /
Change-Id: I164db2c4882047299bf3a30eff87bdb43a3bb1fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2515264
Tested-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Commit-Queue: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
diff --git a/contrib/fromupstream.py b/contrib/fromupstream.py
index b7674ca..a6dafd6 100755
--- a/contrib/fromupstream.py
+++ b/contrib/fromupstream.py
@@ -25,6 +25,7 @@
errprint = functools.partial(print, file=sys.stderr)
# pylint: disable=line-too-long
+# Note: Do not include trailing / in any of these
UPSTREAM_URLS = (
'git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git',
'https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git',
@@ -106,7 +107,7 @@
"""Find a remote pointing to an upstream repository."""
for remote in _git(['remote']).splitlines():
try:
- if _git(['remote', 'get-url', remote]) in urls:
+ if _git(['remote', 'get-url', remote]).rstrip('/') in urls:
return remote
except subprocess.CalledProcessError:
# Kinda weird, get-url failing on an item that git just gave us.