blob: acf3a62955dc4785665a56c077e70d98ce4b642f [file] [log] [blame]
<!--
Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script>
(function(window) {
'use strict';
/** @polymerBehavior Gerrit.PatchSetBehavior */
var PatchSetBehavior = {
/**
* Given an object of revisions, get a particular revision based on patch
* num.
*
* @param {Object} revisions The object of revisions given by the API
* @param {number|string} patchNum The number index of the revision
* @return {Object} The correspondent revision obj from {revisions}
*/
getRevisionByPatchNum: function(revisions, patchNum) {
patchNum = parseInt(patchNum, 10);
for (var rev in revisions) {
if (revisions.hasOwnProperty(rev) &&
revisions[rev]._number === patchNum) {
return revisions[rev];
}
}
},
};
window.Gerrit = window.Gerrit || {};
window.Gerrit.PatchSetBehavior = PatchSetBehavior;
})(window);
</script>