Hello,
Thank you for considering my patch.
Le 04/14/11 20:20, W. Trevor King a écrit :
On Sun, Apr 10, 2011 at 08:28:14PM +0200, Julien Muchembled wrote:
+import pwd
Unfortunately the pwd module is Unix-only, and BE tries to be
platform-agnostic.
Ah yes, I forgot this.
In fact, my patch is entirely based on Git code (git.git/ident.c).
@@ -40,20 +41,14 @@ import libbe.storage.util.config
def get_fallback_username():
"""Return a username extracted from environmental variables.
"""
- name = None
- for env in ["LOGNAME", "USERNAME"]:
- if os.environ.has_key(env):
- name = os.environ[env]
- break
- assert name != None
- return name
+ pw_ent = pwd.getpwuid(os.getuid())
+ return pw_ent[4].split(',', 1)[0] or pw_ent[0]
I approve of not depending on environmental variables when possible,
but it's good to be able to use them to override stuff, so I'm against
throwing out the environmental variables entirely.
Ok.
I've pushed (and attached) my take on this:
http://www.physics.drexel.edu/~wking/code/git/gitweb.cgi?p=be.git;a=commitdiff;h=28b2fb89784f7a1f2dd61a4d157f6c511c5587fe
I guess "USERNAME" is for Windows and could contain capitals.
Now, get_fallback_email could be changed to:
def get_fallback_email():
"""Return an email address extracted from environmental variables.
"""
return os.getenv('EMAIL') or "%s@%s" % (get_fallback_username().lower(),
gethostname())
Out of curiosity, was there some sort of issue that inspired this patch?
Just trying bugs-everywhere outside any repository and saw that it didn't create
tickets with good values in 'Reporter' & 'Creator' fields.
In fact, even inside a Git one, it failed, because I don't redefine my email &
full name in gitconfig.
Regards,
Julien
PS: rahh, one day I'll get used to click on "reply all" button ... sorry for
spamming
_______________________________________________
Be-devel mailing list
[email protected]
http://void.printf.net/cgi-bin/mailman/listinfo/be-devel