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
@@ -40,20 +40,19 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
UiAction<ChangeResource> {
|
||||
public class PutTopic implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final ChangeMessagesUtil cmUtil;
|
||||
private final BatchUpdate.Factory batchUpdateFactory;
|
||||
private final TopicEdited topicEdited;
|
||||
|
||||
public static class Input {
|
||||
@DefaultInput
|
||||
public String topic;
|
||||
@DefaultInput public String topic;
|
||||
}
|
||||
|
||||
@Inject
|
||||
PutTopic(Provider<ReviewDb> dbProvider,
|
||||
PutTopic(
|
||||
Provider<ReviewDb> dbProvider,
|
||||
ChangeMessagesUtil cmUtil,
|
||||
BatchUpdate.Factory batchUpdateFactory,
|
||||
TopicEdited topicEdited) {
|
||||
@@ -72,13 +71,14 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
}
|
||||
|
||||
Op op = new Op(input != null ? input : new Input());
|
||||
try (BatchUpdate u = batchUpdateFactory.create(dbProvider.get(),
|
||||
req.getChange().getProject(), ctl.getUser(), TimeUtil.nowTs())) {
|
||||
try (BatchUpdate u =
|
||||
batchUpdateFactory.create(
|
||||
dbProvider.get(), req.getChange().getProject(), ctl.getUser(), TimeUtil.nowTs())) {
|
||||
u.addOp(req.getId(), op);
|
||||
u.execute();
|
||||
}
|
||||
return Strings.isNullOrEmpty(op.newTopicName)
|
||||
? Response.<String> none()
|
||||
? Response.<String>none()
|
||||
: Response.ok(op.newTopicName);
|
||||
}
|
||||
|
||||
@@ -108,14 +108,13 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
} else if (newTopicName.isEmpty()) {
|
||||
summary = "Topic " + oldTopicName + " removed";
|
||||
} else {
|
||||
summary = String.format("Topic changed from %s to %s",
|
||||
oldTopicName, newTopicName);
|
||||
summary = String.format("Topic changed from %s to %s", oldTopicName, newTopicName);
|
||||
}
|
||||
change.setTopic(Strings.emptyToNull(newTopicName));
|
||||
update.setTopic(change.getTopic());
|
||||
|
||||
ChangeMessage cmsg = ChangeMessagesUtil.newMessage(ctx, summary,
|
||||
ChangeMessagesUtil.TAG_SET_TOPIC);
|
||||
ChangeMessage cmsg =
|
||||
ChangeMessagesUtil.newMessage(ctx, summary, ChangeMessagesUtil.TAG_SET_TOPIC);
|
||||
cmUtil.addChangeMessage(ctx.getDb(), update, cmsg);
|
||||
return true;
|
||||
}
|
||||
@@ -123,10 +122,7 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
@Override
|
||||
public void postUpdate(Context ctx) {
|
||||
if (change != null) {
|
||||
topicEdited.fire(change,
|
||||
ctx.getAccount(),
|
||||
oldTopicName,
|
||||
ctx.getWhen());
|
||||
topicEdited.fire(change, ctx.getAccount(), oldTopicName, ctx.getWhen());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +130,7 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
@Override
|
||||
public UiAction.Description getDescription(ChangeResource resource) {
|
||||
return new UiAction.Description()
|
||||
.setLabel("Edit Topic")
|
||||
.setVisible(resource.getControl().canEditTopicName());
|
||||
.setLabel("Edit Topic")
|
||||
.setVisible(resource.getControl().canEditTopicName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user