Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2fc8643

Browse filesBrowse files
committed
needed pull #43 from gitpython-developers/GitPython @f362d10fa24395c21b1629923ccd705ba73ae996
1 parent 6f95551 commit 2fc8643
Copy full SHA for 2fc8643

2 files changed

+20-6Lines changed: 20 additions & 6 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.rst‎

Copy file name to clipboardExpand all lines: README.rst
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Patches
2+
=======
3+
4+
GitPython has not released a patch that allows the library to figure out the active process user. So, this branch pulls #43 from gitpython-developers/GitPython @f362d10fa24395c21b1629923ccd705ba73ae996.
5+
16
==========
27
GitPython
38
==========
Collapse file

‎git/util.py‎

Copy file name to clipboardExpand all lines: git/util.py
+15-6Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
import tempfile
1414
import platform
1515

16+
# Import the user database on unix based systems
17+
if os.name == "posix":
18+
import pwd
19+
1620
from gitdb.util import (
1721
make_sha,
1822
LockedFD,
@@ -113,12 +117,17 @@ def assure_directory_exists(path, is_file=False):
113117

114118
def get_user_id():
115119
""":return: string identifying the currently active system user as name@node
116-
:note: user can be set with the 'USER' environment variable, usually set on windows"""
117-
ukn = 'UNKNOWN'
118-
username = os.environ.get('USER', os.environ.get('USERNAME', ukn))
119-
if username == ukn and hasattr(os, 'getlogin'):
120-
username = os.getlogin()
121-
# END get username from login
120+
:note: user can be set with the 'USER' environment variable, usually set on windows
121+
:note: on unix based systems you can use the password database
122+
to get the login name of the effective process user"""
123+
if os.name == "posix":
124+
username = pwd.getpwuid(os.geteuid()).pw_name
125+
else:
126+
ukn = 'UNKNOWN'
127+
username = os.environ.get('USER', os.environ.get('USERNAME', ukn))
128+
if username == ukn and hasattr(os, 'getlogin'):
129+
username = os.getlogin()
130+
# END get username from login
122131
return "%s@%s" % (username, platform.node())
123132

124133
#} END utilities

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.