BanCommit: Only record timezone from server identity

If we really want to use the server identity from a singleton we
should use a Provider, which will evaluate to the current time.
However, in this case we just need the timezone for constructing an
identity from the current user. Make this explicitly the only
dependency.

Change-Id: Iba29d2a5dddb17eb5a9803fc1bf7bbfc06e0f4d9
This commit is contained in:
Dave Borowitz
2014-08-01 16:06:40 -07:00
parent fe04fe7f58
commit 2abd2d35b3

View File

@@ -74,7 +74,7 @@ public class BanCommit {
private final Provider<IdentifiedUser> currentUser;
private final GitRepositoryManager repoManager;
private final PersonIdent gerritIdent;
private final TimeZone tz;
private NotesBranchUtil.Factory notesBranchUtilFactory;
@Inject
@@ -84,8 +84,8 @@ public class BanCommit {
final NotesBranchUtil.Factory notesBranchUtilFactory) {
this.currentUser = currentUser;
this.repoManager = repoManager;
this.gerritIdent = gerritIdent;
this.notesBranchUtilFactory = notesBranchUtilFactory;
this.tz = gerritIdent.getTimeZone();
}
public BanCommitResult ban(final ProjectControl projectControl,
@@ -152,7 +152,6 @@ public class BanCommit {
private PersonIdent createPersonIdent() {
Date now = new Date();
TimeZone tz = gerritIdent.getTimeZone();
return currentUser.get().newCommitterIdent(now, tz);
}