Use target branch in suggested push command
Formerly, the push command in the upload help dialog was hard-coded to be the master branch. Use the actual target branch of the current change in the command suggestion instead. Bug: Issue 9703 Change-Id: I6f44f7c239fb3c3f4b292bdd7d9f931a043a70e6
This commit is contained in:
@@ -606,6 +606,7 @@ limitations under the License.
|
|||||||
</gr-overlay>
|
</gr-overlay>
|
||||||
<gr-overlay id="uploadHelpOverlay" with-backdrop>
|
<gr-overlay id="uploadHelpOverlay" with-backdrop>
|
||||||
<gr-upload-help-dialog
|
<gr-upload-help-dialog
|
||||||
|
target-branch="[[_change.branch]]"
|
||||||
on-close="_handleCloseUploadHelpDialog"></gr-upload-help-dialog>
|
on-close="_handleCloseUploadHelpDialog"></gr-upload-help-dialog>
|
||||||
</gr-overlay>
|
</gr-overlay>
|
||||||
<gr-overlay id="includedInOverlay" with-backdrop>
|
<gr-overlay id="includedInOverlay" with-backdrop>
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const COMMIT_COMMAND = 'git add . && git commit --amend --no-edit';
|
const COMMIT_COMMAND = 'git add . && git commit --amend --no-edit';
|
||||||
const PUSH_COMMAND = 'git push origin HEAD:refs/for/master';
|
const PUSH_COMMAND_PREFIX = 'git push origin HEAD:refs/for/';
|
||||||
|
|
||||||
Polymer({
|
Polymer({
|
||||||
is: 'gr-upload-help-dialog',
|
is: 'gr-upload-help-dialog',
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
|
targetBranch: String,
|
||||||
_commitCommand: {
|
_commitCommand: {
|
||||||
type: String,
|
type: String,
|
||||||
value: COMMIT_COMMAND,
|
value: COMMIT_COMMAND,
|
||||||
@@ -37,8 +38,7 @@
|
|||||||
},
|
},
|
||||||
_pushCommand: {
|
_pushCommand: {
|
||||||
type: String,
|
type: String,
|
||||||
value: PUSH_COMMAND,
|
computed: '_computePushCommand(targetBranch)',
|
||||||
readOnly: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -46,5 +46,9 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.fire('close', null, {bubbles: false});
|
this.fire('close', null, {bubbles: false});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_computePushCommand(targetBranch) {
|
||||||
|
return PUSH_COMMAND_PREFIX + targetBranch;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
@@ -0,0 +1,52 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
@license
|
||||||
|
Copyright (C) 2018 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
||||||
|
<title>gr-upload-help-dialog</title>
|
||||||
|
|
||||||
|
<script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
|
||||||
|
<script src="../../../bower_components/web-component-tester/browser.js"></script>
|
||||||
|
<link rel="import" href="../../../test/common-test-setup.html"/>
|
||||||
|
<link rel="import" href="gr-upload-help-dialog.html">
|
||||||
|
|
||||||
|
<script>void(0);</script>
|
||||||
|
|
||||||
|
<test-fixture id="basic">
|
||||||
|
<template>
|
||||||
|
<gr-upload-help-dialog></gr-upload-help-dialog>
|
||||||
|
</template>
|
||||||
|
</test-fixture>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
suite('gr-upload-help-dialog tests', () => {
|
||||||
|
let element;
|
||||||
|
|
||||||
|
setup(() => {
|
||||||
|
element = fixture('basic');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('constructs push command from branch', () => {
|
||||||
|
element.targetBranch = 'foo';
|
||||||
|
assert.equal(element._pushCommand, 'git push origin HEAD:refs/for/foo');
|
||||||
|
|
||||||
|
element.targetBranch = 'master';
|
||||||
|
assert.equal(element._pushCommand,
|
||||||
|
'git push origin HEAD:refs/for/master');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
@@ -86,6 +86,7 @@ limitations under the License.
|
|||||||
'change/gr-reply-dialog/gr-reply-dialog_test.html',
|
'change/gr-reply-dialog/gr-reply-dialog_test.html',
|
||||||
'change/gr-reviewer-list/gr-reviewer-list_test.html',
|
'change/gr-reviewer-list/gr-reviewer-list_test.html',
|
||||||
'change/gr-thread-list/gr-thread-list_test.html',
|
'change/gr-thread-list/gr-thread-list_test.html',
|
||||||
|
'change/gr-upload-help-dialog/gr-upload-help-dialog_test.html',
|
||||||
'core/gr-account-dropdown/gr-account-dropdown_test.html',
|
'core/gr-account-dropdown/gr-account-dropdown_test.html',
|
||||||
'core/gr-error-dialog/gr-error-dialog_test.html',
|
'core/gr-error-dialog/gr-error-dialog_test.html',
|
||||||
'core/gr-error-manager/gr-error-manager_test.html',
|
'core/gr-error-manager/gr-error-manager_test.html',
|
||||||
|
Reference in New Issue
Block a user