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
@@ -28,27 +28,25 @@ import com.google.gerrit.server.git.UserConfigSections;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@Singleton
|
||||
public class GetDiffPreferences implements RestReadView<AccountResource> {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(GetDiffPreferences.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(GetDiffPreferences.class);
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final Provider<AllUsersName> allUsersName;
|
||||
private final GitRepositoryManager gitMgr;
|
||||
|
||||
@Inject
|
||||
GetDiffPreferences(Provider<CurrentUser> self,
|
||||
GetDiffPreferences(
|
||||
Provider<CurrentUser> self,
|
||||
Provider<AllUsersName> allUsersName,
|
||||
GitRepositoryManager gitMgr) {
|
||||
this.self = self;
|
||||
@@ -59,8 +57,7 @@ public class GetDiffPreferences implements RestReadView<AccountResource> {
|
||||
@Override
|
||||
public DiffPreferencesInfo apply(AccountResource rsrc)
|
||||
throws AuthException, ConfigInvalidException, IOException {
|
||||
if (self.get() != rsrc.getUser()
|
||||
&& !self.get().getCapabilities().canAdministrateServer()) {
|
||||
if (self.get() != rsrc.getUser() && !self.get().getCapabilities().canAdministrateServer()) {
|
||||
throw new AuthException("restricted to administrator");
|
||||
}
|
||||
|
||||
@@ -68,26 +65,28 @@ public class GetDiffPreferences implements RestReadView<AccountResource> {
|
||||
return readFromGit(id, gitMgr, allUsersName.get(), null);
|
||||
}
|
||||
|
||||
static DiffPreferencesInfo readFromGit(Account.Id id,
|
||||
GitRepositoryManager gitMgr, AllUsersName allUsersName,
|
||||
DiffPreferencesInfo in)
|
||||
static DiffPreferencesInfo readFromGit(
|
||||
Account.Id id, GitRepositoryManager gitMgr, AllUsersName allUsersName, DiffPreferencesInfo in)
|
||||
throws IOException, ConfigInvalidException, RepositoryNotFoundException {
|
||||
try (Repository git = gitMgr.openRepository(allUsersName)) {
|
||||
// Load all users prefs.
|
||||
VersionedAccountPreferences dp =
|
||||
VersionedAccountPreferences.forDefault();
|
||||
VersionedAccountPreferences dp = VersionedAccountPreferences.forDefault();
|
||||
dp.load(git);
|
||||
DiffPreferencesInfo allUserPrefs = new DiffPreferencesInfo();
|
||||
loadSection(dp.getConfig(), UserConfigSections.DIFF, null, allUserPrefs,
|
||||
DiffPreferencesInfo.defaults(), in);
|
||||
loadSection(
|
||||
dp.getConfig(),
|
||||
UserConfigSections.DIFF,
|
||||
null,
|
||||
allUserPrefs,
|
||||
DiffPreferencesInfo.defaults(),
|
||||
in);
|
||||
|
||||
// Load user prefs
|
||||
VersionedAccountPreferences p =
|
||||
VersionedAccountPreferences.forUser(id);
|
||||
VersionedAccountPreferences p = VersionedAccountPreferences.forUser(id);
|
||||
p.load(git);
|
||||
DiffPreferencesInfo prefs = new DiffPreferencesInfo();
|
||||
loadSection(p.getConfig(), UserConfigSections.DIFF, null, prefs,
|
||||
updateDefaults(allUserPrefs), in);
|
||||
loadSection(
|
||||
p.getConfig(), UserConfigSections.DIFF, null, prefs, updateDefaults(allUserPrefs), in);
|
||||
return prefs;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user