Merge branch 'stable-2.15'
* stable-2.15: Add action_env flag to bazel.rc CreateChange: Strip comment lines out of input commit message Change-Id: I20d84ce716cc2455a04c64729039250f7221f846
This commit is contained in:
@@ -382,16 +382,6 @@ link:https://github.com/bazelbuild/bazel/issues/5139[this bazel issue] for
|
|||||||
details. Users should watch the cache sizes and clean them manually if
|
details. Users should watch the cache sizes and clean them manually if
|
||||||
necessary.
|
necessary.
|
||||||
|
|
||||||
Due to the `--experimental_strict_action_env` option used in `bazelrc`
|
|
||||||
it is possible that some commands required by the build are not found
|
|
||||||
on the PATH, causing the build to fail. In this case the PATH used in
|
|
||||||
the build can be overridden with the `--action_env=PATH` directive in
|
|
||||||
the user's `~/.bazelrc` file, for example:
|
|
||||||
|
|
||||||
----
|
|
||||||
build --action_env=PATH=/usr/local/opt/coreutils/libexec/gnubin/:/usr/local/bin/:/usr/bin/
|
|
||||||
----
|
|
||||||
|
|
||||||
GERRIT
|
GERRIT
|
||||||
------
|
------
|
||||||
Part of link:index.html[Gerrit Code Review]
|
Part of link:index.html[Gerrit Code Review]
|
||||||
|
|||||||
@@ -5809,7 +5809,8 @@ The `ChangeInput` entity contains information about creating a new change.
|
|||||||
The name of the target branch. +
|
The name of the target branch. +
|
||||||
The `refs/heads/` prefix is omitted.
|
The `refs/heads/` prefix is omitted.
|
||||||
|`subject` ||
|
|`subject` ||
|
||||||
The subject of the change (header line of the commit message).
|
The commit message of the change. Comment lines (beginning with `#`) will
|
||||||
|
be removed.
|
||||||
|`topic` |optional|The topic to which this change belongs.
|
|`topic` |optional|The topic to which this change belongs.
|
||||||
|`status` |optional, default to `NEW`|
|
|`status` |optional, default to `NEW`|
|
||||||
The status of the change (only `NEW` accepted here).
|
The status of the change (only `NEW` accepted here).
|
||||||
|
|||||||
@@ -171,7 +171,8 @@ public class CreateChange
|
|||||||
throw new BadRequestException("branch must be non-empty");
|
throw new BadRequestException("branch must be non-empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(input.subject)) {
|
String subject = clean(Strings.nullToEmpty(input.subject));
|
||||||
|
if (Strings.isNullOrEmpty(subject)) {
|
||||||
throw new BadRequestException("commit message must be non-empty");
|
throw new BadRequestException("commit message must be non-empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +265,7 @@ public class CreateChange
|
|||||||
GeneralPreferencesInfo info = accountState.getGeneralPreferences();
|
GeneralPreferencesInfo info = accountState.getGeneralPreferences();
|
||||||
|
|
||||||
// Add a Change-Id line if there isn't already one
|
// Add a Change-Id line if there isn't already one
|
||||||
String commitMessage = input.subject;
|
String commitMessage = subject;
|
||||||
if (ChangeIdUtil.indexOfChangeId(commitMessage, "\n") == -1) {
|
if (ChangeIdUtil.indexOfChangeId(commitMessage, "\n") == -1) {
|
||||||
ObjectId treeId = mergeTip == null ? emptyTreeId(oi) : mergeTip.getTree();
|
ObjectId treeId = mergeTip == null ? emptyTreeId(oi) : mergeTip.getTree();
|
||||||
ObjectId id = ChangeIdUtil.computeChangeId(treeId, mergeTip, author, author, commitMessage);
|
ObjectId id = ChangeIdUtil.computeChangeId(treeId, mergeTip, author, author, commitMessage);
|
||||||
@@ -388,4 +389,16 @@ public class CreateChange
|
|||||||
private static ObjectId emptyTreeId(ObjectInserter inserter) throws IOException {
|
private static ObjectId emptyTreeId(ObjectInserter inserter) throws IOException {
|
||||||
return inserter.insert(new TreeFormatter());
|
return inserter.insert(new TreeFormatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove comment lines from a commit message.
|
||||||
|
*
|
||||||
|
* <p>Based on {@link org.eclipse.jgit.util.ChangeIdUtil#clean}.
|
||||||
|
*
|
||||||
|
* @param msg
|
||||||
|
* @return message without comment lines, possibly empty.
|
||||||
|
*/
|
||||||
|
private String clean(String msg) {
|
||||||
|
return msg.replaceAll("(?m)^#.*$\n?", "").trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,13 @@ public class CreateChangeIT extends AbstractDaemonTest {
|
|||||||
"missing subject; Change-Id must be in commit message footer");
|
"missing subject; Change-Id must be in commit message footer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createNewChange_InvalidCommentInCommitMessage() throws Exception {
|
||||||
|
ChangeInput ci = newChangeInput(ChangeStatus.NEW);
|
||||||
|
ci.subject = "#12345 Test";
|
||||||
|
assertCreateFails(ci, BadRequestException.class, "commit message must be non-empty");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createNewChange() throws Exception {
|
public void createNewChange() throws Exception {
|
||||||
ChangeInfo info = assertCreateSucceeds(newChangeInput(ChangeStatus.NEW));
|
ChangeInfo info = assertCreateSucceeds(newChangeInput(ChangeStatus.NEW));
|
||||||
@@ -123,6 +130,15 @@ public class CreateChangeIT extends AbstractDaemonTest {
|
|||||||
.contains("Change-Id: " + info.changeId);
|
.contains("Change-Id: " + info.changeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createNewChangeWithCommentsInCommitMessage() throws Exception {
|
||||||
|
ChangeInput ci = newChangeInput(ChangeStatus.NEW);
|
||||||
|
ci.subject += "\n# Comment line";
|
||||||
|
ChangeInfo info = gApi.changes().create(ci).get();
|
||||||
|
assertThat(info.revisions.get(info.currentRevision).commit.message)
|
||||||
|
.doesNotContain("# Comment line");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createNewChangeWithChangeId() throws Exception {
|
public void createNewChangeWithChangeId() throws Exception {
|
||||||
ChangeInput ci = newChangeInput(ChangeStatus.NEW);
|
ChangeInput ci = newChangeInput(ChangeStatus.NEW);
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ build --workspace_status_command=./tools/workspace-status.sh --strategy=Closure=
|
|||||||
build --disk_cache=~/.gerritcodereview/bazel-cache/cas
|
build --disk_cache=~/.gerritcodereview/bazel-cache/cas
|
||||||
build --repository_cache=~/.gerritcodereview/bazel-cache/repository
|
build --repository_cache=~/.gerritcodereview/bazel-cache/repository
|
||||||
build --experimental_strict_action_env
|
build --experimental_strict_action_env
|
||||||
|
build --action_env=PATH
|
||||||
test --build_tests_only
|
test --build_tests_only
|
||||||
|
|||||||
Reference in New Issue
Block a user