Ejemplo n.º 1
0
def initialise_here():
    """Return a new default Accessor after initialising the current directory.

    :returns: a new Accessor, mounted at the current directory

    """
    layout = Layout()

    phlsys_subprocess.run('git', 'init')
    repo = phlsys_git.Repo('.')

    # create filesystem hierarchy
    phlsys_fs.write_text_file(layout.arcydroot, 'this dir is an arcydroot')
    phlsys_fs.write_text_file('README', _README)
    phlsys_fs.write_text_file('config/README', _CONFIG_README)
    phlsys_fs.write_text_file(
        'config/phabricator/README', _CONFIG_PHABRICATOR_README)
    phlsys_fs.write_text_file(
        'config/repository/README', _CONFIG_REPOSITORY_README)
    phlsys_fs.write_text_file('var/README', _VAR_README)
    phlsys_fs.write_text_file('var/repo/README', _VAR_REPO_README)
    phlsys_fs.write_text_file('var/log/README', _VAR_LOG_README)
    phlsys_fs.write_text_file('var/status/README', _VAR_STATUS_README)
    phlsys_fs.write_text_file('var/command/README', _VAR_COMMAND_README)
    phlsys_fs.write_text_file('var/run/README', _VAR_RUN_README)

    repo('add', '.')
    phlsys_fs.write_text_file('.gitignore', 'var\n')
    repo('add', '.')
    phlgit_commit.index(repo, 'Initialised new Arcyd instance')

    return Accessor(Layout(), '.')
Ejemplo n.º 2
0
def initialise_here():
    """Return a new default Accessor after initialising the current directory.

    :returns: a new Accessor, mounted at the current directory

    """
    layout = Layout()

    phlsys_subprocess.run('git', 'init')
    repo = phlsys_git.Repo('.')

    # create filesystem hierarchy
    phlsys_fs.write_text_file(layout.arcydroot, 'this dir is an arcydroot')
    phlsys_fs.write_text_file('README', _README)
    phlsys_fs.write_text_file('var/README', _VAR_README)
    phlsys_fs.write_text_file('var/repo/README', _VAR_REPO_README)
    phlsys_fs.write_text_file('var/log/README', _VAR_LOG_README)
    phlsys_fs.write_text_file('var/status/README', _VAR_STATUS_README)
    phlsys_fs.write_text_file('var/command/README', _VAR_COMMAND_README)
    phlsys_fs.write_text_file('var/run/README', _VAR_RUN_README)

    repo.call('add', '.')
    phlsys_fs.write_text_file('.gitignore', 'var\n')
    repo.call('add', '.')
    phlgit_commit.index(repo, 'Initialised new Arcyd instance')

    return Accessor(Layout(), '.')
Ejemplo n.º 3
0
    def _create_config(self, rel_path, content, message):
        """Create and commit the a new config file.

        :rel_path: the string relative path to the config file
        :content: the string contents of the new config file
        :message: the string commit message for the file

        """
        path = self._make_abspath(rel_path)

        if os.path.exists(path):
            raise Exception("config already exists")

        phlsys_fs.write_text_file(path, content)
        self._repo.call('add', rel_path)
        phlgit_commit.index(self._repo, message)
Ejemplo n.º 4
0
    def _remove_config(self, rel_path, message):
        """Remove and commit the removal of an existing config file.

        :rel_path: the string relative path to the config file
        :message: the string commit message for the file

        """
        if phlgit_diffindex.is_index_dirty(self._repo):
            raise Error("git index has staged changes")

        path = self._make_abspath(rel_path)

        if not os.path.exists(path):
            raise Error("config doesn't exist: {}".format(rel_path))

        self._repo('rm', rel_path)
        phlgit_commit.index(self._repo, message)
Ejemplo n.º 5
0
    def _remove_config(self, rel_path, message):
        """Remove and commit the removal of an existing config file.

        :rel_path: the string relative path to the config file
        :message: the string commit message for the file

        """
        if phlgit_diffindex.is_index_dirty(self._repo):
            raise Error("git index has staged changes")

        path = self._make_abspath(rel_path)

        if not os.path.exists(path):
            raise Error("config doesn't exist: {}".format(rel_path))

        self._repo('rm', rel_path)
        phlgit_commit.index(self._repo, message)
Ejemplo n.º 6
0
    def _create_config(self, rel_path, content, message):
        """Create and commit a new config file.

        :rel_path: the string relative path to the config file
        :content: the string contents of the new config file
        :message: the string commit message for the file

        """
        if phlgit_diffindex.is_index_dirty(self._repo):
            raise Error("git index has staged changes")

        path = self._make_abspath(rel_path)

        if os.path.exists(path):
            raise Error("config already exists")

        phlsys_fs.write_text_file(path, content)
        self._repo('add', rel_path)
        phlgit_commit.index(self._repo, message)
Ejemplo n.º 7
0
    def _create_config(self, rel_path, content, message):
        """Create and commit a new config file.

        :rel_path: the string relative path to the config file
        :content: the string contents of the new config file
        :message: the string commit message for the file

        """
        if phlgit_diffindex.is_index_dirty(self._repo):
            raise Error("git index has staged changes")

        path = self._make_abspath(rel_path)

        if os.path.exists(path):
            raise Error("config already exists")

        phlsys_fs.write_text_file(path, content)
        self._repo('add', rel_path)
        phlgit_commit.index(self._repo, message)
Ejemplo n.º 8
0
    def test_B_RawDiffNewCommits(self):
        base, branch_name, branch = self._setup_for_tracked_branch()

        self.assertIs(branch.has_new_commits(), False)

        # push a new commit on branch as dev
        phlgit_checkout.branch(self.repo_dev, branch_name)
        filename = 'new_on_branch'
        self._create_new_file(self.repo_dev, filename)
        self.repo_dev('add', filename)
        phlgit_commit.index(self.repo_dev, message=filename)
        phlgit_push.branch(self.repo_dev, branch_name)

        branch = self._get_updated_branch(branch_name)

        # check for new stuff as arcyd
        self.assertIs(branch.has_new_commits(), True)
        branch.describe_new_commits()  # just exercise
        self.assertIn(filename, branch.make_raw_diff().diff)
        branch.mark_ok_in_review()
        self.assertIs(branch.has_new_commits(), False)
        branch.describe_new_commits()  # just exercise

        # exercise queries a bit
        self.assertIn(filename, branch.make_raw_diff().diff)
        self.assertIn(filename, branch.make_message_digest())
        self.assertEqual(
            branch.get_commit_message_from_tip().strip(),
            filename)
        self.assertTrue(len(branch.get_any_author_emails()) > 0)
        self.assertTrue(len(branch.get_author_names_emails()) > 0)

        # make a new commit on master as dev
        phlgit_checkout.branch(self.repo_dev, 'master')
        filename = 'new_on_master'
        self._create_new_file(self.repo_dev, filename)
        self.repo_dev('add', filename)
        phlgit_commit.index(self.repo_dev, message=filename)
        phlgit_push.branch(self.repo_dev, 'master')

        # refresh the branch
        branch = self._get_updated_branch(branch_name)
        self.assertIs(branch.has_new_commits(), False)

        # merge master into branch, check for new stuff as arcyd
        phlgit_checkout.branch(self.repo_dev, branch_name)
        phlgit_merge.no_ff(self.repo_dev, 'master')
        phlgit_push.branch(self.repo_dev, branch_name)

        # check for new stuff as arcyd
        self.assertIs(branch.has_new_commits(), False)
        branch = self._get_updated_branch(branch_name)
        self.assertNotIn(filename, branch.make_raw_diff().diff)
        branch.mark_ok_in_review()
        self.assertIs(branch.has_new_commits(), False)

        # rebase branch onto master
        phlgit_checkout.branch(self.repo_dev, branch_name)
        phlgit_rebase.onto_upstream(self.repo_dev, 'master')
        phlgit_push.force_branch(self.repo_dev, branch_name)

        # check for new stuff as arcyd
        self.assertIs(branch.has_new_commits(), False)
        branch = self._get_updated_branch(branch_name)
        self.assertIs(branch.has_new_commits(), True)
        branch.describe_new_commits()  # just exercise
        branch.mark_ok_in_review()
        self.assertIs(branch.has_new_commits(), False)
Ejemplo n.º 9
0
    def test_B_RawDiffNewCommits(self):
        base, branch_name, branch = self._setup_for_tracked_branch()

        self.assertIs(branch.has_new_commits(), False)

        # push a new commit on branch as dev
        phlgit_checkout.branch(self.repo_dev, branch_name)
        filename = 'new_on_branch'
        self._create_new_file(self.repo_dev, filename)
        self.repo_dev('add', filename)
        phlgit_commit.index(self.repo_dev, message=filename)
        phlgit_push.branch(self.repo_dev, branch_name)

        branch = self._get_updated_branch(branch_name)

        # check for new stuff as arcyd
        self.assertIs(branch.has_new_commits(), True)
        branch.describe_new_commits()  # just exercise
        self.assertIn(filename, branch.make_raw_diff().diff)
        branch.mark_ok_in_review()
        self.assertIs(branch.has_new_commits(), False)
        branch.describe_new_commits()  # just exercise

        # exercise queries a bit
        self.assertIn(filename, branch.make_raw_diff().diff)
        self.assertIn(filename, branch.make_message_digest())
        self.assertEqual(branch.get_commit_message_from_tip().strip(),
                         filename)
        self.assertTrue(len(branch.get_any_author_emails()) > 0)
        self.assertTrue(len(branch.get_author_names_emails()) > 0)

        # make a new commit on master as dev
        phlgit_checkout.branch(self.repo_dev, 'master')
        filename = 'new_on_master'
        self._create_new_file(self.repo_dev, filename)
        self.repo_dev('add', filename)
        phlgit_commit.index(self.repo_dev, message=filename)
        phlgit_push.branch(self.repo_dev, 'master')

        # refresh the branch
        branch = self._get_updated_branch(branch_name)
        self.assertIs(branch.has_new_commits(), False)

        # merge master into branch, check for new stuff as arcyd
        phlgit_checkout.branch(self.repo_dev, branch_name)
        phlgit_merge.no_ff(self.repo_dev, 'master')
        phlgit_push.branch(self.repo_dev, branch_name)

        # check for new stuff as arcyd
        self.assertIs(branch.has_new_commits(), False)
        branch = self._get_updated_branch(branch_name)
        self.assertNotIn(filename, branch.make_raw_diff().diff)
        branch.mark_ok_in_review()
        self.assertIs(branch.has_new_commits(), False)

        # rebase branch onto master
        phlgit_checkout.branch(self.repo_dev, branch_name)
        phlgit_rebase.onto_upstream(self.repo_dev, 'master')
        phlgit_push.force_branch(self.repo_dev, branch_name)

        # check for new stuff as arcyd
        self.assertIs(branch.has_new_commits(), False)
        branch = self._get_updated_branch(branch_name)
        self.assertIs(branch.has_new_commits(), True)
        branch.describe_new_commits()  # just exercise
        branch.mark_ok_in_review()
        self.assertIs(branch.has_new_commits(), False)