mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-01-12 09:30:28 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e91248655 | ||
|
|
630876f9e4 | ||
|
|
4aa8584ec6 | ||
|
|
b550501254 | ||
|
|
a535ae4418 | ||
|
|
67d6cdf2bc | ||
|
|
152032cca2 | ||
|
|
a3ac816278 | ||
|
|
98bb76577d | ||
|
|
d33dce0b77 | ||
|
|
89ed8acdbe | ||
|
|
71e48b7672 | ||
|
|
13576a8caf | ||
|
|
2345906d04 | ||
|
|
41289c62b4 | ||
|
|
c72bd8486a | ||
|
|
d53cb9549a | ||
|
|
cf0ba48649 |
@@ -163,6 +163,7 @@ User controlled settings are initialized when running `repo init`.
|
||||
| repo.clonefilter | `--clone-filter` | Filter setting when using [partial git clones] |
|
||||
| repo.depth | `--depth` | Create shallow checkouts when cloning |
|
||||
| repo.dissociate | `--dissociate` | Dissociate from any reference/mirrors after initial clone |
|
||||
| repo.git-lfs | `--git-lfs` | Enable [Git LFS] support |
|
||||
| repo.mirror | `--mirror` | Checkout is a repo mirror |
|
||||
| repo.partialclone | `--partial-clone` | Create [partial git clones] |
|
||||
| repo.partialcloneexclude | `--partial-clone-exclude` | Comma-delimited list of project names (not paths) to exclude while using [partial git clones] |
|
||||
@@ -254,6 +255,7 @@ Repo will create & maintain a few files in the user's home directory.
|
||||
|
||||
|
||||
[git-config]: https://git-scm.com/docs/git-config
|
||||
[Git LFS]: https://git-lfs.github.com/
|
||||
[git worktree]: https://git-scm.com/docs/git-worktree
|
||||
[gitsubmodules]: https://git-scm.com/docs/gitsubmodules
|
||||
[manifest-format.md]: ./manifest-format.md
|
||||
|
||||
@@ -169,7 +169,8 @@ class GitCommand(object):
|
||||
disable_editor=False,
|
||||
ssh_proxy=None,
|
||||
cwd=None,
|
||||
gitdir=None):
|
||||
gitdir=None,
|
||||
objdir=None):
|
||||
env = self._GetBasicEnv()
|
||||
|
||||
if disable_editor:
|
||||
@@ -194,13 +195,24 @@ class GitCommand(object):
|
||||
cwd = project.worktree
|
||||
if not gitdir:
|
||||
gitdir = project.gitdir
|
||||
# Git on Windows wants its paths only using / for reliability.
|
||||
if platform_utils.isWindows():
|
||||
if objdir:
|
||||
objdir = objdir.replace('\\', '/')
|
||||
if gitdir:
|
||||
gitdir = gitdir.replace('\\', '/')
|
||||
|
||||
if objdir:
|
||||
# Set to the place we want to save the objects.
|
||||
env['GIT_OBJECT_DIRECTORY'] = objdir
|
||||
if gitdir:
|
||||
# Allow git to search the original place in case of local or unique refs
|
||||
# that git will attempt to resolve even if we aren't fetching them.
|
||||
env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = gitdir + '/objects'
|
||||
|
||||
command = [GIT]
|
||||
if bare:
|
||||
if gitdir:
|
||||
# Git on Windows wants its paths only using / for reliability.
|
||||
if platform_utils.isWindows():
|
||||
gitdir = gitdir.replace('\\', '/')
|
||||
env[GIT_DIR] = gitdir
|
||||
cwd = None
|
||||
command.append(cmdv[0])
|
||||
@@ -234,6 +246,11 @@ class GitCommand(object):
|
||||
dbg += ': export GIT_DIR=%s\n' % env[GIT_DIR]
|
||||
LAST_GITDIR = env[GIT_DIR]
|
||||
|
||||
if 'GIT_OBJECT_DIRECTORY' in env:
|
||||
dbg += ': export GIT_OBJECT_DIRECTORY=%s\n' % env['GIT_OBJECT_DIRECTORY']
|
||||
if 'GIT_ALTERNATE_OBJECT_DIRECTORIES' in env:
|
||||
dbg += ': export GIT_ALTERNATE_OBJECT_DIRECTORIES=%s\n' % env['GIT_ALTERNATE_OBJECT_DIRECTORIES']
|
||||
|
||||
dbg += ': '
|
||||
dbg += ' '.join(command)
|
||||
if stdin == subprocess.PIPE:
|
||||
|
||||
@@ -666,6 +666,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
||||
def HasSubmodules(self):
|
||||
return self.manifestProject.config.GetBoolean('repo.submodules')
|
||||
|
||||
@property
|
||||
def EnableGitLfs(self):
|
||||
return self.manifestProject.config.GetBoolean('repo.git-lfs')
|
||||
|
||||
def GetDefaultGroupsStr(self):
|
||||
"""Returns the default group string for the platform."""
|
||||
return 'default,platform-' + platform.system().lower()
|
||||
|
||||
125
project.py
125
project.py
@@ -457,11 +457,7 @@ class RemoteSpec(object):
|
||||
|
||||
class Project(object):
|
||||
# These objects can be shared between several working trees.
|
||||
shareable_files = ['description', 'info']
|
||||
shareable_dirs = ['hooks', 'objects', 'rr-cache', 'svn']
|
||||
# These objects can only be used by a single working tree.
|
||||
working_tree_files = ['config', 'packed-refs', 'shallow']
|
||||
working_tree_dirs = ['logs', 'refs']
|
||||
shareable_dirs = ['hooks', 'objects', 'rr-cache']
|
||||
|
||||
def __init__(self,
|
||||
manifest,
|
||||
@@ -1124,7 +1120,7 @@ class Project(object):
|
||||
self._InitRemote()
|
||||
|
||||
if is_new:
|
||||
alt = os.path.join(self.gitdir, 'objects/info/alternates')
|
||||
alt = os.path.join(self.objdir, 'objects/info/alternates')
|
||||
try:
|
||||
with open(alt) as fd:
|
||||
# This works for both absolute and relative alternate directories.
|
||||
@@ -1173,7 +1169,7 @@ class Project(object):
|
||||
mp = self.manifest.manifestProject
|
||||
dissociate = mp.config.GetBoolean('repo.dissociate')
|
||||
if dissociate:
|
||||
alternates_file = os.path.join(self.gitdir, 'objects/info/alternates')
|
||||
alternates_file = os.path.join(self.objdir, 'objects/info/alternates')
|
||||
if os.path.exists(alternates_file):
|
||||
cmd = ['repack', '-a', '-d']
|
||||
p = GitCommand(self, cmd, bare=True, capture_stdout=bool(output_redir),
|
||||
@@ -2196,8 +2192,10 @@ class Project(object):
|
||||
retry_cur_sleep = retry_sleep_initial_sec
|
||||
ok = prune_tried = False
|
||||
for try_n in range(retry_fetches):
|
||||
gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy,
|
||||
merge_output=True, capture_stdout=quiet or bool(output_redir))
|
||||
gitcmd = GitCommand(
|
||||
self, cmd, bare=True, objdir=os.path.join(self.objdir, 'objects'),
|
||||
ssh_proxy=ssh_proxy,
|
||||
merge_output=True, capture_stdout=quiet or bool(output_redir))
|
||||
if gitcmd.stdout and not quiet and output_redir:
|
||||
output_redir.write(gitcmd.stdout)
|
||||
ret = gitcmd.Wait()
|
||||
@@ -2313,7 +2311,8 @@ class Project(object):
|
||||
cmd.append(str(f))
|
||||
cmd.append('+refs/tags/*:refs/tags/*')
|
||||
|
||||
ok = GitCommand(self, cmd, bare=True).Wait() == 0
|
||||
ok = GitCommand(
|
||||
self, cmd, bare=True, objdir=os.path.join(self.objdir, 'objects')).Wait() == 0
|
||||
platform_utils.remove(bundle_dst, missing_ok=True)
|
||||
platform_utils.remove(bundle_tmp, missing_ok=True)
|
||||
return ok
|
||||
@@ -2483,10 +2482,9 @@ class Project(object):
|
||||
os.makedirs(self.gitdir)
|
||||
|
||||
if init_obj_dir or init_git_dir:
|
||||
self._ReferenceGitDir(self.objdir, self.gitdir, share_refs=False,
|
||||
copy_all=True)
|
||||
self._ReferenceGitDir(self.objdir, self.gitdir, copy_all=True)
|
||||
try:
|
||||
self._CheckDirReference(self.objdir, self.gitdir, share_refs=False)
|
||||
self._CheckDirReference(self.objdir, self.gitdir)
|
||||
except GitError as e:
|
||||
if force_sync:
|
||||
print("Retrying clone after deleting %s" %
|
||||
@@ -2509,8 +2507,8 @@ class Project(object):
|
||||
if ref_dir or mirror_git:
|
||||
if not mirror_git:
|
||||
mirror_git = os.path.join(ref_dir, self.name + '.git')
|
||||
repo_git = os.path.join(ref_dir, '.repo', 'projects',
|
||||
self.relpath + '.git')
|
||||
repo_git = os.path.join(ref_dir, '.repo', 'project-objects',
|
||||
self.name + '.git')
|
||||
worktrees_git = os.path.join(ref_dir, '.repo', 'worktrees',
|
||||
self.name + '.git')
|
||||
|
||||
@@ -2528,15 +2526,16 @@ class Project(object):
|
||||
# The alternate directory is relative to the object database.
|
||||
ref_dir = os.path.relpath(ref_dir,
|
||||
os.path.join(self.objdir, 'objects'))
|
||||
_lwrite(os.path.join(self.gitdir, 'objects/info/alternates'),
|
||||
_lwrite(os.path.join(self.objdir, 'objects/info/alternates'),
|
||||
os.path.join(ref_dir, 'objects') + '\n')
|
||||
|
||||
m = self.manifest.manifestProject.config
|
||||
for key in ['user.name', 'user.email']:
|
||||
if m.Has(key, include_defaults=False):
|
||||
self.config.SetString(key, m.GetString(key))
|
||||
self.config.SetString('filter.lfs.smudge', 'git-lfs smudge --skip -- %f')
|
||||
self.config.SetString('filter.lfs.process', 'git-lfs filter-process --skip')
|
||||
if not self.manifest.EnableGitLfs:
|
||||
self.config.SetString('filter.lfs.smudge', 'git-lfs smudge --skip -- %f')
|
||||
self.config.SetString('filter.lfs.process', 'git-lfs filter-process --skip')
|
||||
self.config.SetBoolean('core.bare', True if self.manifest.IsMirror else None)
|
||||
except Exception:
|
||||
if init_obj_dir and os.path.exists(self.objdir):
|
||||
@@ -2553,6 +2552,14 @@ class Project(object):
|
||||
hooks = platform_utils.realpath(os.path.join(self.objdir, 'hooks'))
|
||||
if not os.path.exists(hooks):
|
||||
os.makedirs(hooks)
|
||||
|
||||
# Delete sample hooks. They're noise.
|
||||
for hook in glob.glob(os.path.join(hooks, '*.sample')):
|
||||
try:
|
||||
platform_utils.remove(hook, missing_ok=True)
|
||||
except PermissionError:
|
||||
pass
|
||||
|
||||
for stock_hook in _ProjectHooks():
|
||||
name = os.path.basename(stock_hook)
|
||||
|
||||
@@ -2650,40 +2657,16 @@ class Project(object):
|
||||
else:
|
||||
active_git.symbolic_ref('-m', msg, ref, dst)
|
||||
|
||||
def _CheckDirReference(self, srcdir, destdir, share_refs):
|
||||
def _CheckDirReference(self, srcdir, destdir):
|
||||
# Git worktrees don't use symlinks to share at all.
|
||||
if self.use_git_worktrees:
|
||||
return
|
||||
|
||||
symlink_files = self.shareable_files[:]
|
||||
symlink_dirs = self.shareable_dirs[:]
|
||||
if share_refs:
|
||||
symlink_files += self.working_tree_files
|
||||
symlink_dirs += self.working_tree_dirs
|
||||
to_symlink = symlink_files + symlink_dirs
|
||||
for name in set(to_symlink):
|
||||
for name in self.shareable_dirs:
|
||||
# Try to self-heal a bit in simple cases.
|
||||
dst_path = os.path.join(destdir, name)
|
||||
src_path = os.path.join(srcdir, name)
|
||||
|
||||
if name in self.working_tree_dirs:
|
||||
# If the dir is missing under .repo/projects/, create it.
|
||||
if not os.path.exists(src_path):
|
||||
os.makedirs(src_path)
|
||||
|
||||
elif name in self.working_tree_files:
|
||||
# If it's a file under the checkout .git/ and the .repo/projects/ has
|
||||
# nothing, move the file under the .repo/projects/ tree.
|
||||
if not os.path.exists(src_path) and os.path.isfile(dst_path):
|
||||
platform_utils.rename(dst_path, src_path)
|
||||
|
||||
# If the path exists under the .repo/projects/ and there's no symlink
|
||||
# under the checkout .git/, recreate the symlink.
|
||||
if name in self.working_tree_dirs or name in self.working_tree_files:
|
||||
if os.path.exists(src_path) and not os.path.exists(dst_path):
|
||||
platform_utils.symlink(
|
||||
os.path.relpath(src_path, os.path.dirname(dst_path)), dst_path)
|
||||
|
||||
dst = platform_utils.realpath(dst_path)
|
||||
if os.path.lexists(dst):
|
||||
src = platform_utils.realpath(src_path)
|
||||
@@ -2696,23 +2679,17 @@ class Project(object):
|
||||
' use `repo sync --force-sync {0}` to '
|
||||
'proceed.'.format(self.relpath))
|
||||
|
||||
def _ReferenceGitDir(self, gitdir, dotgit, share_refs, copy_all):
|
||||
def _ReferenceGitDir(self, gitdir, dotgit, copy_all):
|
||||
"""Update |dotgit| to reference |gitdir|, using symlinks where possible.
|
||||
|
||||
Args:
|
||||
gitdir: The bare git repository. Must already be initialized.
|
||||
dotgit: The repository you would like to initialize.
|
||||
share_refs: If true, |dotgit| will store its refs under |gitdir|.
|
||||
Only one work tree can store refs under a given |gitdir|.
|
||||
copy_all: If true, copy all remaining files from |gitdir| -> |dotgit|.
|
||||
This saves you the effort of initializing |dotgit| yourself.
|
||||
"""
|
||||
symlink_files = self.shareable_files[:]
|
||||
symlink_dirs = self.shareable_dirs[:]
|
||||
if share_refs:
|
||||
symlink_files += self.working_tree_files
|
||||
symlink_dirs += self.working_tree_dirs
|
||||
to_symlink = symlink_files + symlink_dirs
|
||||
to_symlink = symlink_dirs
|
||||
|
||||
to_copy = []
|
||||
if copy_all:
|
||||
@@ -2740,11 +2717,6 @@ class Project(object):
|
||||
elif os.path.isfile(src):
|
||||
shutil.copy(src, dst)
|
||||
|
||||
# If the source file doesn't exist, ensure the destination
|
||||
# file doesn't either.
|
||||
if name in symlink_files and not os.path.lexists(src):
|
||||
platform_utils.remove(dst, missing_ok=True)
|
||||
|
||||
except OSError as e:
|
||||
if e.errno == errno.EPERM:
|
||||
raise DownloadError(self._get_symlink_error_message())
|
||||
@@ -2848,24 +2820,41 @@ class Project(object):
|
||||
}
|
||||
# Paths that we know will be in both, but are safe to clobber in .repo/projects/.
|
||||
SAFE_TO_CLOBBER = {
|
||||
'COMMIT_EDITMSG', 'FETCH_HEAD', 'HEAD', 'index', 'ORIG_HEAD',
|
||||
'COMMIT_EDITMSG', 'FETCH_HEAD', 'HEAD', 'gc.log', 'gitk.cache', 'index',
|
||||
'ORIG_HEAD',
|
||||
}
|
||||
|
||||
# First see if we'd succeed before starting the migration.
|
||||
unknown_paths = []
|
||||
for name in platform_utils.listdir(dotgit):
|
||||
# Ignore all temporary/backup names. These are common with vim & emacs.
|
||||
if name.endswith('~') or (name[0] == '#' and name[-1] == '#'):
|
||||
continue
|
||||
|
||||
dotgit_path = os.path.join(dotgit, name)
|
||||
if name in KNOWN_LINKS:
|
||||
if not platform_utils.islink(dotgit_path):
|
||||
unknown_paths.append(f'{dotgit_path}: should be a symlink')
|
||||
else:
|
||||
gitdir_path = os.path.join(gitdir, name)
|
||||
if name not in SAFE_TO_CLOBBER and os.path.exists(gitdir_path):
|
||||
unknown_paths.append(f'{dotgit_path}: unknown file; please file a bug')
|
||||
if unknown_paths:
|
||||
raise GitError('Aborting migration: ' + '\n'.join(unknown_paths))
|
||||
|
||||
# Now walk the paths and sync the .git/ to .repo/projects/.
|
||||
for name in platform_utils.listdir(dotgit):
|
||||
dotgit_path = os.path.join(dotgit, name)
|
||||
if name in KNOWN_LINKS:
|
||||
if platform_utils.islink(dotgit_path):
|
||||
platform_utils.remove(dotgit_path)
|
||||
else:
|
||||
raise GitError(f'{dotgit_path}: should be a symlink')
|
||||
|
||||
# Ignore all temporary/backup names. These are common with vim & emacs.
|
||||
if name.endswith('~') or (name[0] == '#' and name[-1] == '#'):
|
||||
platform_utils.remove(dotgit_path)
|
||||
elif name in KNOWN_LINKS:
|
||||
platform_utils.remove(dotgit_path)
|
||||
else:
|
||||
gitdir_path = os.path.join(gitdir, name)
|
||||
if name in SAFE_TO_CLOBBER or not os.path.exists(gitdir_path):
|
||||
platform_utils.remove(gitdir_path, missing_ok=True)
|
||||
platform_utils.rename(dotgit_path, gitdir_path)
|
||||
else:
|
||||
raise GitError(f'{dotgit_path}: unknown file; please file a bug')
|
||||
platform_utils.remove(gitdir_path, missing_ok=True)
|
||||
platform_utils.rename(dotgit_path, gitdir_path)
|
||||
|
||||
# Now that the dir should be empty, clear it out, and symlink it over.
|
||||
platform_utils.rmdir(dotgit)
|
||||
|
||||
8
repo
8
repo
@@ -149,7 +149,7 @@ if not REPO_REV:
|
||||
BUG_URL = 'https://bugs.chromium.org/p/gerrit/issues/entry?template=Repo+tool+issue'
|
||||
|
||||
# increment this whenever we make important changes to this script
|
||||
VERSION = (2, 17)
|
||||
VERSION = (2, 21)
|
||||
|
||||
# increment this if the MAINTAINER_KEYS block is modified
|
||||
KEYRING_VERSION = (2, 3)
|
||||
@@ -382,6 +382,11 @@ def InitParser(parser, gitc_init=False):
|
||||
group.add_option('--no-clone-bundle',
|
||||
dest='clone_bundle', action='store_false',
|
||||
help='disable use of /clone.bundle on HTTP/HTTPS (default if --partial-clone)')
|
||||
group.add_option('--git-lfs', action='store_true',
|
||||
help='enable Git LFS support')
|
||||
group.add_option('--no-git-lfs',
|
||||
dest='git_lfs', action='store_false',
|
||||
help='disable Git LFS support')
|
||||
|
||||
# Tool.
|
||||
group = parser.add_option_group('repo Version options')
|
||||
@@ -618,6 +623,7 @@ def _Init(args, gitc_init=False):
|
||||
"REPO_URL set correctly?" % url, file=sys.stderr)
|
||||
|
||||
except CloneFailure:
|
||||
print('fatal: double check your --repo-rev setting.', file=sys.stderr)
|
||||
if opt.quiet:
|
||||
print('fatal: repo init failed; run without --quiet to see why',
|
||||
file=sys.stderr)
|
||||
|
||||
@@ -151,7 +151,7 @@ is shown, then the branch appears in all projects.
|
||||
fmt = out.write
|
||||
paths = []
|
||||
non_cur_paths = []
|
||||
if i.IsSplitCurrent or (in_cnt < project_cnt - in_cnt):
|
||||
if i.IsSplitCurrent or (in_cnt <= project_cnt - in_cnt):
|
||||
in_type = 'in'
|
||||
for b in i.projects:
|
||||
if not i.IsSplitCurrent or b.current:
|
||||
@@ -163,9 +163,9 @@ is shown, then the branch appears in all projects.
|
||||
in_type = 'not in'
|
||||
have = set()
|
||||
for b in i.projects:
|
||||
have.add(b.project)
|
||||
have.add(b.project.relpath)
|
||||
for p in projects:
|
||||
if p not in have:
|
||||
if p.relpath not in have:
|
||||
paths.append(p.relpath)
|
||||
|
||||
s = ' %s %s' % (in_type, ', '.join(paths))
|
||||
|
||||
@@ -291,6 +291,15 @@ to update the working directory files.
|
||||
if opt.submodules:
|
||||
m.config.SetBoolean('repo.submodules', opt.submodules)
|
||||
|
||||
if opt.git_lfs is not None:
|
||||
if opt.git_lfs:
|
||||
git_require((2, 17, 0), fail=True, msg='Git LFS support')
|
||||
|
||||
m.config.SetBoolean('repo.git-lfs', opt.git_lfs)
|
||||
if not is_new:
|
||||
print('warning: Changing --git-lfs settings will only affect new project checkouts.\n'
|
||||
' Existing projects will require manual updates.\n', file=sys.stderr)
|
||||
|
||||
if opt.use_superproject is not None:
|
||||
m.config.SetBoolean('repo.superproject', opt.use_superproject)
|
||||
|
||||
@@ -520,8 +529,12 @@ to update the working directory files.
|
||||
# Handle new --repo-rev requests.
|
||||
if opt.repo_rev:
|
||||
wrapper = Wrapper()
|
||||
remote_ref, rev = wrapper.check_repo_rev(
|
||||
rp.gitdir, opt.repo_rev, repo_verify=opt.repo_verify, quiet=opt.quiet)
|
||||
try:
|
||||
remote_ref, rev = wrapper.check_repo_rev(
|
||||
rp.gitdir, opt.repo_rev, repo_verify=opt.repo_verify, quiet=opt.quiet)
|
||||
except wrapper.CloneFailure:
|
||||
print('fatal: double check your --repo-rev setting.', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
branch = rp.GetBranch('default')
|
||||
branch.merge = remote_ref
|
||||
rp.work_git.reset('--hard', rev)
|
||||
|
||||
@@ -986,10 +986,11 @@ later is required to fix a server side protocol bug.
|
||||
|
||||
load_local_manifests = not self.manifest.HasLocalManifests
|
||||
use_superproject = git_superproject.UseSuperproject(opt, self.manifest)
|
||||
if self.manifest.IsMirror or self.manifest.IsArchive:
|
||||
if use_superproject and (self.manifest.IsMirror or self.manifest.IsArchive):
|
||||
# Don't use superproject, because we have no working tree.
|
||||
use_superproject = False
|
||||
print('Defaulting to no-use-superproject because there is no working tree.')
|
||||
if opt.use_superproject is not None:
|
||||
print('Defaulting to no-use-superproject because there is no working tree.')
|
||||
superproject_logging_data = {
|
||||
'superproject': use_superproject,
|
||||
'haslocalmanifests': bool(self.manifest.HasLocalManifests),
|
||||
|
||||
@@ -347,6 +347,10 @@ class MigrateWorkTreeTests(unittest.TestCase):
|
||||
}
|
||||
_FILES = {
|
||||
'COMMIT_EDITMSG', 'FETCH_HEAD', 'HEAD', 'index', 'ORIG_HEAD',
|
||||
'unknown-file-should-be-migrated',
|
||||
}
|
||||
_CLEAN_FILES = {
|
||||
'a-vim-temp-file~', '#an-emacs-temp-file#',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@@ -365,10 +369,9 @@ class MigrateWorkTreeTests(unittest.TestCase):
|
||||
dotgit.mkdir(parents=True)
|
||||
for name in cls._SYMLINKS:
|
||||
(dotgit / name).symlink_to(f'../../../.repo/projects/src/test.git/{name}')
|
||||
for name in cls._FILES:
|
||||
for name in cls._FILES | cls._CLEAN_FILES:
|
||||
(dotgit / name).write_text(name)
|
||||
|
||||
subprocess.run(['tree', '-a', str(dotgit)])
|
||||
yield tempdir
|
||||
|
||||
def test_standard(self):
|
||||
@@ -379,9 +382,30 @@ class MigrateWorkTreeTests(unittest.TestCase):
|
||||
|
||||
# Make sure the dir was transformed into a symlink.
|
||||
self.assertTrue(dotgit.is_symlink())
|
||||
self.assertEqual(str(dotgit.readlink()), '../../.repo/projects/src/test.git')
|
||||
self.assertEqual(os.readlink(dotgit), '../../.repo/projects/src/test.git')
|
||||
|
||||
# Make sure files were moved over.
|
||||
gitdir = tempdir / '.repo/projects/src/test.git'
|
||||
for name in self._FILES:
|
||||
self.assertEqual(name, (gitdir / name).read_text())
|
||||
# Make sure files were removed.
|
||||
for name in self._CLEAN_FILES:
|
||||
self.assertFalse((gitdir / name).exists())
|
||||
|
||||
def test_unknown(self):
|
||||
"""A checkout with unknown files should abort."""
|
||||
with self._simple_layout() as tempdir:
|
||||
dotgit = tempdir / 'src/test/.git'
|
||||
(tempdir / '.repo/projects/src/test.git/random-file').write_text('one')
|
||||
(dotgit / 'random-file').write_text('two')
|
||||
with self.assertRaises(error.GitError):
|
||||
project.Project._MigrateOldWorkTreeGitDir(str(dotgit))
|
||||
|
||||
# Make sure no content was actually changed.
|
||||
self.assertTrue(dotgit.is_dir())
|
||||
for name in self._FILES:
|
||||
self.assertTrue((dotgit / name).is_file())
|
||||
for name in self._CLEAN_FILES:
|
||||
self.assertTrue((dotgit / name).is_file())
|
||||
for name in self._SYMLINKS:
|
||||
self.assertTrue((dotgit / name).is_symlink())
|
||||
|
||||
Reference in New Issue
Block a user