Skip to content

Instantly share code, notes, and snippets.

@b4ldr
Last active April 26, 2023 11:21
Show Gist options
  • Save b4ldr/449d490b43fb3d2d01a74d28bc9a41e4 to your computer and use it in GitHub Desktop.
Save b4ldr/449d490b43fb3d2d01a74d28bc9a41e4 to your computer and use it in GitHub Desktop.
git get user
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