gclient_eval: Support unpinned dependencies in SetRevision.

If a dependency was unpinned, support adding a revision to it.

R=agable@chromium.org

Bug: 760633
Change-Id: Id2c9fe5174458acaea334726176b88558425ef5a
Reviewed-on: https://chromium-review.googlesource.com/998735
Reviewed-by: Aaron Gable <agable@chromium.org>
Reviewed-by: Michael Moss <mmoss@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
changes/35/998735/4
Edward Lesmes 7 years ago committed by Commit Bot
parent 8d6265766b
commit 1118a2193b

@ -666,7 +666,13 @@ def SetRevision(gclient_dict, dep_name, new_revision):
SetVar(gclient_dict, var_name, new_revision)
else:
if '@' in node.s:
# '@' is part of the last string, which we want to modify. Discard
# whatever was after the '@' and put the new revision in its place.
new_revision = node.s.split('@')[0] + '@' + new_revision
elif '@' not in dep_dict[dep_key]:
# '@' is not part of the URL at all. This mean the dependency is
# unpinned and we should pin it.
new_revision = node.s + '@' + new_revision
_UpdateAstString(tokens, node, new_revision)
dep_dict.SetNode(dep_key, new_revision, node)

@ -504,6 +504,20 @@ class SetRevisionTest(unittest.TestCase):
]
self.assert_changes_revision(before, after)
def test_pins_revision(self):
before = [
'deps = {',
' "src/dep": "https://example.com/dep.git",',
'}',
]
after = [
'deps = {',
' "src/dep": "https://example.com/dep.git@deadfeed",',
'}',
]
self.assert_changes_revision(before, after)
def test_preserves_formatting(self):
before = [
'vars = {',

Loading…
Cancel
Save