Format all Java files with google-java-format
Having a standard tool for formatting saves reviewers' valuable time. google-java-format is Google's standard formatter and is somewhat inspired by gofmt[1]. This commit formats everything using google-java-format version 1.2. The downside of this one-off formatting is breaking blame. This can be somewhat hacked around with a tool like git-hyper-blame[2], but it's definitely not optimal until/unless this kind of feature makes its way to git core. Not in this change: * Tool support, e.g. Eclipse. The command must be run manually [3]. * Documentation of best practice, e.g. new 100-column default. [1] https://talks.golang.org/2015/gofmt-en.slide#3 [2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html [3] git ls-files | grep java$ | xargs google-java-format -i Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3 Signed-off-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
committed by
David Pursehouse
parent
6723b6d0fa
commit
292fa154c1
@@ -34,28 +34,26 @@ import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(
|
||||
SubmittedTogether.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(SubmittedTogether.class);
|
||||
|
||||
private final EnumSet<SubmittedTogetherOption> options =
|
||||
EnumSet.noneOf(SubmittedTogetherOption.class);
|
||||
|
||||
private final EnumSet<ListChangesOption> jsonOpt = EnumSet.of(
|
||||
ListChangesOption.CURRENT_REVISION,
|
||||
ListChangesOption.CURRENT_COMMIT,
|
||||
ListChangesOption.SUBMITTABLE);
|
||||
private final EnumSet<ListChangesOption> jsonOpt =
|
||||
EnumSet.of(
|
||||
ListChangesOption.CURRENT_REVISION,
|
||||
ListChangesOption.CURRENT_COMMIT,
|
||||
ListChangesOption.SUBMITTABLE);
|
||||
|
||||
private final ChangeJson.Factory json;
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
@@ -83,7 +81,8 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
}
|
||||
|
||||
@Inject
|
||||
SubmittedTogether(ChangeJson.Factory json,
|
||||
SubmittedTogether(
|
||||
ChangeJson.Factory json,
|
||||
Provider<ReviewDb> dbProvider,
|
||||
Provider<InternalChangeQuery> queryProvider,
|
||||
Provider<MergeSuperSet> mergeSuperSet,
|
||||
@@ -100,16 +99,15 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SubmittedTogether addSubmittedTogetherOption(
|
||||
EnumSet<SubmittedTogetherOption> o) {
|
||||
public SubmittedTogether addSubmittedTogetherOption(EnumSet<SubmittedTogetherOption> o) {
|
||||
options.addAll(o);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(ChangeResource resource)
|
||||
throws AuthException, BadRequestException,
|
||||
ResourceConflictException, IOException, OrmException {
|
||||
throws AuthException, BadRequestException, ResourceConflictException, IOException,
|
||||
OrmException {
|
||||
SubmittedTogetherInfo info = applyInfo(resource);
|
||||
if (options.isEmpty()) {
|
||||
return info.changes;
|
||||
@@ -126,8 +124,9 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
|
||||
if (c.getStatus().isOpen()) {
|
||||
ChangeSet cs =
|
||||
mergeSuperSet.get().completeChangeSet(
|
||||
dbProvider.get(), c, resource.getControl().getUser());
|
||||
mergeSuperSet
|
||||
.get()
|
||||
.completeChangeSet(dbProvider.get(), c, resource.getControl().getUser());
|
||||
cds = cs.changes().asList();
|
||||
hidden = cs.nonVisibleChanges().size();
|
||||
} else if (c.getStatus().asChangeStatus() == ChangeStatus.MERGED) {
|
||||
@@ -138,10 +137,8 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
hidden = 0;
|
||||
}
|
||||
|
||||
if (hidden != 0
|
||||
&& !options.contains(NON_VISIBLE_CHANGES)) {
|
||||
throw new AuthException(
|
||||
"change would be submitted with a change that you cannot see");
|
||||
if (hidden != 0 && !options.contains(NON_VISIBLE_CHANGES)) {
|
||||
throw new AuthException("change would be submitted with a change that you cannot see");
|
||||
}
|
||||
|
||||
if (cds.size() <= 1 && hidden == 0) {
|
||||
@@ -162,8 +159,7 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
}
|
||||
}
|
||||
|
||||
private List<ChangeData> sort(List<ChangeData> cds)
|
||||
throws OrmException, IOException {
|
||||
private List<ChangeData> sort(List<ChangeData> cds) throws OrmException, IOException {
|
||||
List<ChangeData> sorted = new ArrayList<>(cds.size());
|
||||
for (PatchSetData psd : sorter.get().sort(cds)) {
|
||||
sorted.add(psd.data());
|
||||
|
||||
Reference in New Issue
Block a user