Re: [PATCH JGIT] Compute the author/commiter name and email from the git configuration
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Feb 3, 2009, 23:20 UTC
- Message-ID
- <alpine.DEB.1.00.0902040019030.9822@pacific.mpi-cbg.de>
- In-Reply-To
- <20090203231357.GZ26880@spearce.org>
Hi,
On Tue, 3 Feb 2009, Shawn O. Pearce wrote:
Show 33 quoted lines
> Yann Simon <yann.simon.fr@gmail.com> wrote:
>
> > @@ -308,6 +312,83 @@ public String getString(final String section, String subsection, final String na
> > return result;
> > }
> >
> > + /**
> > + * @return the author name as defined in the git variables
> > + * and configurations. If no name could be found, try
> > + * to use the system user name instead.
> > + */
> > + public String getAuthorName() {
> > + return getUsernameInternal(Constants.GIT_AUTHOR_NAME_KEY);
> > + }
> > +
> > + /**
> > + * @return the commiter name as defined in the git variables
> > + * and configurations. If no name could be found, try
> > + * to use the system user name instead.
> > + */
> > + public String getCommiterName() {
> > + return getUsernameInternal(Constants.GIT_COMMITER_NAME_KEY);
> > + }
> > +
> > + private String getUsernameInternal(String gitVariableKey) {
> > + // try to get the user name from the local and global configurations.
> > + String username = getString("user", null, "name");
> > +
> > + if (username == null) {
> > + // try to get the user name for the system property GIT_XXX_NAME
> > + username = System.getProperty(gitVariableKey);
>
> Shouldn't that be System.getenv()?According to
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getenv(java.lang.String)
getenv() is deprecated. However, in later editions (Java5 and later, to be precise), that deprecation seems to be lifted...
Ciao, Dscho