mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Always set .gitconfig dir to user's home
This commit is contained in:
parent
b0446f527e
commit
d3620c3356
1 changed files with 6 additions and 11 deletions
|
@ -11,6 +11,7 @@ import glob
|
|||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
import pwd
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
|
@ -1424,6 +1425,10 @@ class Pygit2(GitProvider):
|
|||
will let the calling function know whether or not a new repo was
|
||||
initialized by this function.
|
||||
'''
|
||||
# https://github.com/libgit2/pygit2/issues/339
|
||||
# https://github.com/libgit2/libgit2/issues/2122
|
||||
home = pwd.getpwnam(salt.utils.get_user()).pw_dir
|
||||
pygit2.settings.search_path[pygit2.GIT_CONFIG_LEVEL_GLOBAL] = home
|
||||
new = False
|
||||
if not os.listdir(self.cachedir):
|
||||
# Repo cachedir is empty, initialize a new repo there
|
||||
|
@ -1432,17 +1437,7 @@ class Pygit2(GitProvider):
|
|||
else:
|
||||
# Repo cachedir exists, try to attach
|
||||
try:
|
||||
try:
|
||||
self.repo = pygit2.Repository(self.cachedir)
|
||||
except GitError as exc:
|
||||
import pwd
|
||||
# https://github.com/libgit2/pygit2/issues/339
|
||||
# https://github.com/libgit2/libgit2/issues/2122
|
||||
if "Error stat'ing config file" not in str(exc):
|
||||
raise
|
||||
home = pwd.getpwnam(salt.utils.get_user()).pw_dir
|
||||
pygit2.settings.search_path[pygit2.GIT_CONFIG_LEVEL_GLOBAL] = home
|
||||
self.repo = pygit2.Repository(self.cachedir)
|
||||
self.repo = pygit2.Repository(self.cachedir)
|
||||
except KeyError:
|
||||
log.error(_INVALID_REPO.format(self.cachedir, self.url, self.role))
|
||||
return new
|
||||
|
|
Loading…
Add table
Reference in a new issue