Set topic by Change-Id

When setting a topic, GR-CHANGE-METADATA would call the set-topic API
endpoint identifying the change using the following format:

    <project>~<branch>~<Change-Id>

When the project or branch contained characters that needed to be URI-
encoded, the endpoint would fail to identify the change, resulting in a
404. This API behavior is encoded in Issue 4746.

The workaround in this change is to instead identify the change by the
shorter Change-Id format (`Ie<hex ...>`), which needs no additional
encoding.

Bug: Issue 4555
Change-Id: I00181387bc2a85dfea90b9db46fb017749963579
This commit is contained in:
Wyatt Allen
2016-10-10 14:04:20 -07:00
parent 4b9082e57a
commit 2f2a3a55f8
2 changed files with 10 additions and 1 deletions

View File

@@ -88,7 +88,7 @@
_handleTopicChanged: function(e, topic) {
if (!topic.length) { topic = null; }
this.$.restAPI.setChangeTopic(this.change.id, topic);
this.$.restAPI.setChangeTopic(this.change.change_id, topic);
},
_computeTopicReadOnly: function(mutable, change) {

View File

@@ -85,6 +85,8 @@ limitations under the License.
sandbox.stub(element, '_computeValueTooltip').returns('');
sandbox.stub(element, '_computeTopicReadOnly').returns(true);
element.change = {
change_id: 'the id',
topic: 'the topic',
status: 'NEW',
submit_type: 'CHERRY_PICK',
labels: {
@@ -145,6 +147,13 @@ limitations under the License.
done();
});
});
test('changing topic calls setChangeTopic', function() {
var topicStub = sandbox.stub(element.$.restAPI, 'setChangeTopic',
function() {});
element._handleTopicChanged({}, 'the new topic');
assert.isTrue(topicStub.calledWith('the id', 'the new topic'));
});
});
});
</script>