diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2011-03-16 16:23:14 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2011-03-16 16:23:14 +0100 |
commit | 157a996e1d48b504df922f995bf1104dc2c57c7b (patch) | |
tree | 0fb85806b1f86b0ea9d2520197213070b60f8b6d /org.eclipse.jgit.test | |
parent | 8aef29c114910b8212306880d914c085e94a2fcd (diff) | |
download | jgit-157a996e1d48b504df922f995bf1104dc2c57c7b.tar.gz jgit-157a996e1d48b504df922f995bf1104dc2c57c7b.zip |
Expose if name or email is based on a guess
This enables applications to differentiate between explicitly set
configuration parameters and best effort attempts to guess these
parameters from the operating system.
Change-Id: I67cc4099238a40c6dca795e64f0155ced6008ef1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java index d5da16ad80..b9f62177cc 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java @@ -148,17 +148,21 @@ public class ConfigTest { authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail(); assertEquals(Constants.UNKNOWN_USER_DEFAULT, authorName); assertEquals(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail); + assertTrue(localConfig.get(UserConfig.KEY).isAuthorNameImplicit()); + assertTrue(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit()); // the system user name is defined mockSystemReader.setProperty(Constants.OS_USER_NAME_KEY, "os user name"); localConfig.uncache(UserConfig.KEY); authorName = localConfig.get(UserConfig.KEY).getAuthorName(); assertEquals("os user name", authorName); + assertTrue(localConfig.get(UserConfig.KEY).isAuthorNameImplicit()); if (hostname != null && hostname.length() != 0) { authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail(); assertEquals("os user name@" + hostname, authorEmail); } + assertTrue(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit()); // the git environment variables are defined mockSystemReader.setProperty(Constants.GIT_AUTHOR_NAME_KEY, "git author name"); @@ -168,6 +172,8 @@ public class ConfigTest { authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail(); assertEquals("git author name", authorName); assertEquals("author@email", authorEmail); + assertFalse(localConfig.get(UserConfig.KEY).isAuthorNameImplicit()); + assertFalse(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit()); // the values are defined in the global configuration userGitConfig.setString("user", null, "name", "global username"); @@ -176,6 +182,8 @@ public class ConfigTest { authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail(); assertEquals("global username", authorName); assertEquals("author@globalemail", authorEmail); + assertFalse(localConfig.get(UserConfig.KEY).isAuthorNameImplicit()); + assertFalse(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit()); // the values are defined in the local configuration localConfig.setString("user", null, "name", "local username"); @@ -184,11 +192,15 @@ public class ConfigTest { authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail(); assertEquals("local username", authorName); assertEquals("author@localemail", authorEmail); + assertFalse(localConfig.get(UserConfig.KEY).isAuthorNameImplicit()); + assertFalse(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit()); authorName = localConfig.get(UserConfig.KEY).getCommitterName(); authorEmail = localConfig.get(UserConfig.KEY).getCommitterEmail(); assertEquals("local username", authorName); assertEquals("author@localemail", authorEmail); + assertFalse(localConfig.get(UserConfig.KEY).isCommitterNameImplicit()); + assertFalse(localConfig.get(UserConfig.KEY).isCommitterEmailImplicit()); } @Test |