Last active
April 26, 2023 11:21
-
-
Save b4ldr/449d490b43fb3d2d01a74d28bc9a41e4 to your computer and use it in GitHub Desktop.
git get user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import git | |
import os | |
import pwd | |
import shutil | |
from git.util import get_user_id | |
from pathlib import Path | |
CHECKOUT = Path("/tmp/profile") | |
shutil.rmtree(CHECKOUT, ignore_errors=True) | |
ORIGIN_REPO = "https://gist.github.com/b4ldr/449d490b43fb3d2d01a74d28bc9a41e4" | |
os.seteuid(pwd.getpwnam('jbond').pw_uid) | |
euid = pwd.getpwuid(os.geteuid()).pw_name | |
print(f"git.utils.get_user_id: {get_user_id()}") | |
print(f"euid: {euid}") | |
repo = git.Repo.clone_from(ORIGIN_REPO, CHECKOUT) | |
print(f"directory owner: {CHECKOUT.owner()}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment