Merge branch 'stable-3.1'

* stable-3.1:
  Fix formatting issues flagged by eslint
  Bump Bazel version to 2.0.0
  Set version in package.json to 3.0.7-SNAPSHOT
  Set version in package.json to 2.16.16-SNAPSHOT
  Use gerritCheck API for posting checker result
  Update git submodules
  Downport "Replace deprecated `require-jsdoc`, `valid-jsdoc` with jsdoc plugin for eslint"
  Downport "Add a shared pre-commit to run eslintfix for frontend code changes"
  Downport "Remove `|| exit 0` as eslint already supported correct exit code"
  Downport "Update eslint version and eslint rules"
  Downport "Simplify installing / running polylint"
  Downport "Make `npm start` run run-server.sh"
  Downport "Simplify installing / running template tests"
  Downport "Simplify installing and running eslint"
  Downport "Simplify running frontend tests via package.json"

Change-Id: I77ea844ecfb46937c0d93058e9c1370bc0a558ac
This commit is contained in:
David Ostrovsky
2020-01-04 20:45:00 +01:00
13 changed files with 41 additions and 56 deletions

View File

@@ -1 +1 @@
1.2.0 2.0.0

26
Jenkinsfile vendored
View File

@@ -53,15 +53,11 @@ class Builds {
class GerritCheck { class GerritCheck {
String uuid String uuid
String changeNum
String sha1
Build build Build build
GerritCheck(name, changeNum, sha1, build) { GerritCheck(name, build) {
this.uuid = "gerritforge:" + name.replaceAll("(bazel/)", "") + this.uuid = "gerritforge:" + name.replaceAll("(bazel/)", "") +
Globals.gerritRepositoryNameSha1Suffix Globals.gerritRepositoryNameSha1Suffix
this.changeNum = changeNum
this.sha1 = sha1
this.build = build this.build = build
} }
@@ -93,21 +89,7 @@ def hasChangeNumber() {
} }
def postCheck(check) { def postCheck(check) {
def gerritPostUrl = Globals.gerritUrl + gerritCheck(checks: [ "${check.uuid}" : "${check.getCheckResultFromBuild()}" ])
"a/changes/${check.changeNum}/revisions/${check.sha1}/checks"
try {
def json = check.createCheckPayload()
httpRequest(httpMode: 'POST', authentication: Globals.gerritCredentialsId,
contentType: 'APPLICATION_JSON', requestBody: json,
validResponseCodes: '200', url: gerritPostUrl)
echo "----------------------------------------------------------------------------"
echo "Gerrit Check: ${check.uuid}=" + check.build.result + " to change " +
check.changeNum + "/" + check.sha1
echo "----------------------------------------------------------------------------"
} catch(Exception e) {
echo "ERROR> Failed to post check results to Gerrit: ${e}"
}
} }
def queryChangedFiles(url, changeNum, sha1) { def queryChangedFiles(url, changeNum, sha1) {
@@ -313,7 +295,7 @@ node ('master') {
gerritReview( gerritReview(
labels: ['Code-Style': resCodeStyle], labels: ['Code-Style': resCodeStyle],
message: createCodeStyleMsgBody(Builds.codeStyle, resCodeStyle)) message: createCodeStyleMsgBody(Builds.codeStyle, resCodeStyle))
postCheck(new GerritCheck("codestyle", Change.number, Change.sha1, Builds.codeStyle)) postCheck(new GerritCheck("codestyle", Builds.codeStyle))
def verificationResults = Builds.verification.collect { k, v -> v } def verificationResults = Builds.verification.collect { k, v -> v }
def resVerify = verificationResults.inject(1) { def resVerify = verificationResults.inject(1) {
@@ -324,7 +306,7 @@ node ('master') {
message: createVerifyMsgBody(Builds.verification)) message: createVerifyMsgBody(Builds.verification))
Builds.verification.each { type, build -> postCheck( Builds.verification.each { type, build -> postCheck(
new GerritCheck(type, Change.number, Change.sha1, build) new GerritCheck(type, build)
)} )}
setResult(resVerify, resCodeStyle) setResult(resVerify, resCodeStyle)

View File

@@ -51,7 +51,13 @@ simply execute:
npm run start npm run start
``` ```
Then visit <http://localhost:8081>. Then visit http://localhost:8081
## Local UI, Test Data
```sh
./polygerrit-ui/run-server.sh --plugins=plugins/my_plugin/static/my_plugin.js,plugins/my_plugin/static/my_plugin.html
```
This method is based on a This method is based on a
[simple hand-written Go webserver](https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/server.go). [simple hand-written Go webserver](https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/server.go).

View File

@@ -205,8 +205,7 @@ limitations under the License.
id: 'administrateServer', id: 'administrateServer',
value: {}, value: {},
}; };
assert.equal( assert.equal(element._computePermissionName(name, permission,
element._computePermissionName(name, permission,
element.permissionValues, element.capabilities), element.permissionValues, element.capabilities),
element.capabilities[permission.id].name); element.capabilities[permission.id].name);
@@ -216,8 +215,7 @@ limitations under the License.
value: {}, value: {},
}; };
assert.equal( assert.equal(element._computePermissionName(
element._computePermissionName(
name, permission, element.permissionValues, element.capabilities), name, permission, element.permissionValues, element.capabilities),
element.permissionValues[permission.id].name); element.permissionValues[permission.id].name);
@@ -229,8 +227,7 @@ limitations under the License.
}, },
}; };
assert.equal( assert.equal(element._computePermissionName(name, permission,
element._computePermissionName(name, permission,
element.permissionValues, element.capabilities), element.permissionValues, element.capabilities),
'Label Code-Review'); 'Label Code-Review');
@@ -241,8 +238,7 @@ limitations under the License.
}, },
}; };
assert.equal( assert.equal(element._computePermissionName(name, permission,
element._computePermissionName(name, permission,
element.permissionValues, element.capabilities), element.permissionValues, element.capabilities),
'Label Code-Review(On Behalf Of)'); 'Label Code-Review(On Behalf Of)');
}); });

View File

@@ -110,8 +110,7 @@
const message = change ? const message = change ?
CREATE_CHANGE_SUCCEEDED_MESSAGE : CREATE_CHANGE_SUCCEEDED_MESSAGE :
CREATE_CHANGE_FAILED_MESSAGE; CREATE_CHANGE_FAILED_MESSAGE;
this.dispatchEvent(new CustomEvent( this.dispatchEvent(new CustomEvent('show-alert',
'show-alert',
{detail: {message}, bubbles: true, composed: true})); {detail: {message}, bubbles: true, composed: true}));
if (!change) { return; } if (!change) { return; }

View File

@@ -57,8 +57,7 @@ limitations under the License.
'cell label u-gray-background'); 'cell label u-gray-background');
assert.equal(element._computeLabelClass( assert.equal(element._computeLabelClass(
{labels: {}}, 'Verified'), 'cell label u-gray-background'); {labels: {}}, 'Verified'), 'cell label u-gray-background');
assert.equal( assert.equal(element._computeLabelClass(
element._computeLabelClass(
{labels: {Verified: {approved: true, value: 1}}}, 'Verified'), {labels: {Verified: {approved: true, value: 1}}}, 'Verified'),
'cell label u-green u-monospace'); 'cell label u-green u-monospace');
assert.equal(element._computeLabelClass( assert.equal(element._computeLabelClass(

View File

@@ -236,8 +236,9 @@
this.change._number, {add: [newHashtag]}).then(newHashtag => { this.change._number, {add: [newHashtag]}).then(newHashtag => {
this.set(['change', 'hashtags'], newHashtag); this.set(['change', 'hashtags'], newHashtag);
if (newHashtag !== lastHashtag) { if (newHashtag !== lastHashtag) {
this.dispatchEvent(new CustomEvent( this.dispatchEvent(
'hashtag-changed', {bubbles: true, composed: true})); new CustomEvent('hashtag-changed', {
bubbles: true, composed: true}));
} }
}); });
} }

View File

@@ -1197,6 +1197,7 @@
* Compute size bar layout values from the file list. * Compute size bar layout values from the file list.
* *
* @return {Gerrit.LayoutStats|undefined} * @return {Gerrit.LayoutStats|undefined}
*
*/ */
_computeSizeBarLayout(shownFilesRecord) { _computeSizeBarLayout(shownFilesRecord) {
if (!shownFilesRecord || !shownFilesRecord.base) { return undefined; } if (!shownFilesRecord || !shownFilesRecord.base) { return undefined; }
@@ -1280,6 +1281,7 @@
* Get the x-offset of the deletion bar for a file. * Get the x-offset of the deletion bar for a file.
* *
* @param {Gerrit.LayoutStats} stats * @param {Gerrit.LayoutStats} stats
*
* @return {number} * @return {number}
*/ */
_computeBarDeletionX(stats) { _computeBarDeletionX(stats) {

View File

@@ -143,6 +143,7 @@
* *
* @param {!Array<!Gerrit.DiffChunk>} chunks * @param {!Array<!Gerrit.DiffChunk>} chunks
* @param {boolean} isBinary * @param {boolean} isBinary
*
* @return {!Promise<!Array<!Object>>} A promise that resolves with an * @return {!Promise<!Array<!Object>>} A promise that resolves with an
* array of GrDiffGroups when the diff is completely processed. * array of GrDiffGroups when the diff is completely processed.
*/ */

View File

@@ -36,7 +36,6 @@
const htmlPlugins = (plugins.html_resource_paths || []); const htmlPlugins = (plugins.html_resource_paths || []);
const jsPlugins = const jsPlugins =
this._handleMigrations(plugins.js_resource_paths || [], htmlPlugins); this._handleMigrations(plugins.js_resource_paths || [], htmlPlugins);
const shouldLoadTheme = config.default_theme && const shouldLoadTheme = config.default_theme &&
!Gerrit._isPluginPreloaded('preloaded:gerrit-theme'); !Gerrit._isPluginPreloaded('preloaded:gerrit-theme');
const themeToLoad = const themeToLoad =

View File

@@ -38,8 +38,8 @@
* @return {string} Appropriate class name for the element is returned * @return {string} Appropriate class name for the element is returned
*/ */
GrStyleObject.prototype.getClassName = function(element) { GrStyleObject.prototype.getClassName = function(element) {
let rootNode = Polymer.Settings.useShadow ? let rootNode = Polymer.Settings.useShadow
element.getRootNode() : document.body; ? element.getRootNode() : document.body;
if (rootNode === document) { if (rootNode === document) {
rootNode = document.head; rootNode = document.head;
} }

View File

@@ -45,9 +45,9 @@
const line = context.line; const line = context.line;
// Highlight lines missing coverage with this background color if // Highlight lines missing coverage with this background color if
// coverage should be displayed, else do nothing. // coverage should be displayed, else do nothing.
const annotationStyle = displayCoverage ? const annotationStyle = displayCoverage
coverageStyle : ? coverageStyle
emptyStyle; : emptyStyle;
if (coverageData[path] && if (coverageData[path] &&
coverageData[path].changeNum === context.changeNum && coverageData[path].changeNum === context.changeNum &&
coverageData[path].patchNum === context.patchNum) { coverageData[path].patchNum === context.patchNum) {

View File

@@ -35,8 +35,8 @@
switch (usersType) { switch (usersType) {
case Gerrit.SUGGESTIONS_PROVIDERS_USERS_TYPES.REVIEWER: case Gerrit.SUGGESTIONS_PROVIDERS_USERS_TYPES.REVIEWER:
return new GrReviewerSuggestionsProvider(restApi, changeNumber, return new GrReviewerSuggestionsProvider(restApi, changeNumber,
input => input => restApi.getChangeSuggestedReviewers(changeNumber,
restApi.getChangeSuggestedReviewers(changeNumber, input)); input));
case Gerrit.SUGGESTIONS_PROVIDERS_USERS_TYPES.CC: case Gerrit.SUGGESTIONS_PROVIDERS_USERS_TYPES.CC:
return new GrReviewerSuggestionsProvider(restApi, changeNumber, return new GrReviewerSuggestionsProvider(restApi, changeNumber,
input => restApi.getChangeSuggestedCCs(changeNumber, input)); input => restApi.getChangeSuggestedCCs(changeNumber, input));