Cleanup the reflog identity generation
Simplify the code, and ensure the SSH username field is always present in the identity even if the username hasn't bee populated in the account. Change-Id: I956fbd6f07ecd659c966e43c1e70001ac138b464 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -211,35 +211,32 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
|
|
||||||
public PersonIdent newRefLogIdent(final Date when, final TimeZone tz) {
|
public PersonIdent newRefLogIdent(final Date when, final TimeZone tz) {
|
||||||
final Account ua = getAccount();
|
final Account ua = getAccount();
|
||||||
|
|
||||||
String name = ua.getFullName();
|
String name = ua.getFullName();
|
||||||
if (name == null) {
|
if (name == null || name.isEmpty()) {
|
||||||
name = ua.getPreferredEmail();
|
name = ua.getPreferredEmail();
|
||||||
}
|
}
|
||||||
if (name == null) {
|
if (name == null || name.isEmpty()) {
|
||||||
name = "Anonymous Coward";
|
name = "Anonymous Coward";
|
||||||
}
|
}
|
||||||
|
|
||||||
final String userId = "account-" + ua.getId().toString();
|
String user = ua.getSshUserName();
|
||||||
final String user;
|
if (user == null) {
|
||||||
if (ua.getSshUserName() != null) {
|
user = "";
|
||||||
user = ua.getSshUserName() + "|" + userId;
|
|
||||||
} else {
|
|
||||||
user = userId;
|
|
||||||
}
|
}
|
||||||
|
user = user + "|" + "account-" + ua.getId().toString();
|
||||||
|
|
||||||
String host = null;
|
String host = null;
|
||||||
final SocketAddress remotePeer =
|
if (remotePeerProvider != null) {
|
||||||
remotePeerProvider != null ? remotePeerProvider.get() : null;
|
final SocketAddress remotePeer = remotePeerProvider.get();
|
||||||
if (remotePeer instanceof InetSocketAddress) {
|
if (remotePeer instanceof InetSocketAddress) {
|
||||||
final InetSocketAddress sa = (InetSocketAddress) remotePeer;
|
final InetSocketAddress sa = (InetSocketAddress) remotePeer;
|
||||||
final InetAddress in = sa.getAddress();
|
final InetAddress in = sa.getAddress();
|
||||||
if (in != null) {
|
|
||||||
host = in.getCanonicalHostName();
|
host = in != null ? in.getCanonicalHostName() : sa.getHostName();
|
||||||
} else {
|
|
||||||
host = sa.getHostName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (host == null) {
|
if (host == null || host.isEmpty()) {
|
||||||
host = "unknown";
|
host = "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user