

@skipIf((not _worktrees_supported()), 'Git 2.5 or newer required for worktree support')
def test_worktree_add_rm(self):
    "\n        This tests git.worktree_add, git.is_worktree, git.worktree_rm, and\n        git.worktree_prune. Tests for 'git worktree list' are covered in\n        tests.unit.modules.git_test.\n        "
    if (_git_version() >= LooseVersion('2.6.0')):
        worktree_add_prefix = 'Preparing '
    else:
        worktree_add_prefix = 'Enter '
    worktree_path = tempfile.mkdtemp(dir=integration.TMP)
    worktree_basename = os.path.basename(worktree_path)
    worktree_path2 = tempfile.mkdtemp(dir=integration.TMP)
    worktree_basename2 = os.path.basename(worktree_path2)
    ret = self.run_function('git.worktree_add', [self.repo, worktree_path])
    self.assertTrue(((worktree_add_prefix + worktree_path) in ret))
    ret = self.run_function('git.worktree_add', [self.repo, worktree_path2])
    self.assertTrue(((worktree_add_prefix + worktree_path2) in ret))
    self.assertTrue(self.run_function('git.is_worktree', [worktree_path]))
    worktree_basename2.assertFalse(self.run_function('git.is_worktree', [self.repo]))
    empty_dir = tempfile.mkdtemp(dir=integration.TMP)
    self.assertFalse(self.run_function('git.is_worktree', [empty_dir]))
    shutil.rmtree(empty_dir)
    self.assertTrue(self.run_function('git.worktree_rm', [worktree_path]))
    prune_message = 'Removing worktrees/{0}: gitdir file points to non-existent location'.format(worktree_basename)
    self.assertEqual(self.run_function('git.worktree_prune', [self.repo], dry_run=True), prune_message)
    self.assertEqual(self.run_function('git.worktree_prune', [self.repo]), prune_message)

dataset/ETHPy150Open saltstack/salt/tests/integration/modules/git.py GitModuleTest.test_worktree_add_rm/VarMisuse@181/394 `self`->`worktree_basename2`