Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert svn access to github to git sparse checkout #204

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions manic/repository_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,20 @@ def _checkout_external_ref(self, verbosity, submodules, dirname):

def _sparse_checkout(self, repo_dir, verbosity):
"""Use git read-tree to thin the working tree."""
cmd = ['cp', os.path.join(repo_dir, self._sparse),
os.path.join(repo_dir,
'.git/info/sparse-checkout')]
if verbosity >= VERBOSITY_VERBOSE:
printlog(' {0}'.format(' '.join(cmd)))
execute_subprocess(cmd)

sparse_filepath = os.path.join(repo_dir, self._sparse)
if os.path.isfile(sparse_filepath):
cmd = ['cp', os.path.join(repo_dir, self._sparse),
os.path.join(repo_dir,
'.git/info/sparse-checkout')]
if verbosity >= VERBOSITY_VERBOSE:
printlog(' {0}'.format(' '.join(cmd)))
execute_subprocess(cmd)
else:
with open(os.path.join(repo_dir,'.git/info/sparse-checkout'),"w") as fsc:
fsc.write("/"+self._sparse+"/")


self._git_sparse_checkout(verbosity, repo_dir)

def _check_for_valid_ref(self, ref, remote_name, dirname):
Expand All @@ -380,6 +388,7 @@ def _check_for_valid_ref(self, ref, remote_name, dirname):
is_tag = self._ref_is_tag(ref, dirname)
is_branch = self._ref_is_branch(ref, remote_name, dirname)
is_hash = self._ref_is_hash(ref, dirname)

is_valid = is_tag or is_branch or is_hash
if not is_valid:
msg = ('In repo "{0}": reference "{1}" does not appear to be a '
Expand Down Expand Up @@ -709,10 +718,7 @@ def _git_lsremote_branch(ref, remote_name, dirname):
cmd = ('git -C {dirname} ls-remote --exit-code --heads '
'{remote_name} {ref}').format(
dirname=dirname, remote_name=remote_name, ref=ref).split()
status, output = execute_subprocess(cmd, status_to_caller=True, output_to_caller=True)
if not status and not f"refs/heads/{ref}" in output:
# In this case the ref is contained in the branch name but is not the complete branch name
return -1
status = execute_subprocess(cmd, status_to_caller=True)
return status

@staticmethod
Expand Down
3 changes: 3 additions & 0 deletions manic/repository_svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def __init__(self, component_name, repo, ignore_ancestry=False):
Parse repo (a <repo> XML element).
"""
Repository.__init__(self, component_name, repo)
if 'github.com' in self._url:
msg = "SVN access to github.com is no longer supported"
fatal_error(msg)
self._ignore_ancestry = ignore_ancestry
if self._url.endswith('/'):
# there is already a '/' separator in the URL; no need to add another
Expand Down
10 changes: 9 additions & 1 deletion manic/sourcetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,15 @@ def __init__(self, root_dir, ext_description, svn_ignore_ancestry=False):
required = desc[ExternalsDescription.REQUIRED]
repo_info = desc[ExternalsDescription.REPO]
subexternals_path = desc[ExternalsDescription.EXTERNALS]

if repo_info['protocol'] == 'svn' and 'github.com' in repo_info['repo_url']:
# change to git sparse checkout
repo_info['protocol'] = 'git'
if repo_info['repo_url'].endswith('tags/'):
repo_info['repo_url'] = (repo_info['repo_url'])[:-5]
slash_index = repo_info['tag'].index('/')
repo_info['sparse'] = (repo_info['tag'])[slash_index+1:]
repo_info['tag'] = (repo_info['tag'])[:slash_index]

repo = create_repository(comp,
repo_info,
svn_ignore_ancestry=svn_ignore_ancestry)
Expand Down
Loading