Skip to content

Commit

Permalink
EdkRepo: Update includeifs in gitconfig
Browse files Browse the repository at this point in the history
Changing includeif path syntax to be up-to-date with newer versions
of Git

Signed-off-by: Kevin Sun <[email protected]>
Reviewed-by: Ashley E Desimone <[email protected]>
  • Loading branch information
kevinsun49 authored and ashedesimone committed May 17, 2022
1 parent dcb0466 commit 1f3fbeb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions edkrepo/commands/sync_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def __check_submodule_config(self, workspace_path, manifest, repo_sources):
gitglobalconfig = git.GitConfigParser(gitconfigpath, read_only=False)
try:
local_manifest_dir = os.path.join(workspace_path, "repo")
includeif_regex = re.compile('^includeIf "gitdir:(/.+)/"$')
includeif_regex = re.compile('^includeIf "gitdir:%\(prefix\)(/.+)/"$')
rewrite_everything = False
#Generate list of .gitconfig files that should be present in the workspace
included_configs = []
Expand Down Expand Up @@ -515,7 +515,7 @@ def __check_submodule_config(self, workspace_path, manifest, repo_sources):
else:
path = included_config[1]
path = path.replace('\\', '/')
section = 'includeIf "gitdir:{}/"'.format(gitdir)
section = 'includeIf "gitdir:%(prefix){}/"'.format(gitdir)
gitglobalconfig.add_section(section)
gitglobalconfig.set(section, 'path', path)
gitglobalconfig.release()
Expand Down
2 changes: 1 addition & 1 deletion edkrepo/common/common_repo_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def write_conditional_include(workspace_path, repo_sources, included_configs):
else:
path = included_config[1]
path = path.replace('\\', '/')
section = 'includeIf "gitdir:{}/"'.format(gitdir)
section = 'includeIf "gitdir:%(prefix){}/"'.format(gitdir)
with git.GitConfigParser(gitconfigpath, read_only=False) as gitglobalconfig:
gitglobalconfig.add_section(section)
gitglobalconfig.set(section, 'path', path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
def clean_git_globalconfig():
global_gitconfig_path = os.path.normpath(expanduser("~/.gitconfig"))
with git.GitConfigParser(global_gitconfig_path, read_only=False) as git_globalconfig:
includeif_regex = re.compile('^includeIf "gitdir:(/.+)/"$')
includeif_regex = re.compile('^includeIf "gitdir:%\(prefix\)(/.+)/"$')
includeif_regex_old = re.compile('^includeIf "gitdir:(/.+)/"$')
for section in git_globalconfig.sections():
data = includeif_regex.match(section)
if data:
Expand All @@ -34,10 +35,14 @@ def clean_git_globalconfig():
if not os.path.isdir(gitrepo_path) and not os.path.isfile(gitconfig_path):
if not os.path.isfile(repo_manifest_path):
git_globalconfig.remove_section(section)

data_old = includeif_regex_old.match(section)
if data_old:
git_globalconfig.remove_section(section)

def set_long_path_support():
global_git_config_path = os.path.normpath(expanduser("~/.gitconfig"))
with git.GitConfigParser(global_git_config_path, read_only=False) as git_globalconfig:
if 'core' not in git_globalconfig.sections():
git_globalconfig.add_section('core')
git_globalconfig.set('core', 'longpaths', 'true')
git_globalconfig.set('core', 'longpaths', 'true')

0 comments on commit 1f3fbeb

Please sign in to comment.