Пример #1
0
 def test_fetch_default_branch(self):
     # On GitHub 'main' is the default
     repo = utils.fetch_repo(GIT_REPO)
     output, _ = run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], repo)
     assert 'main' in output
     # The beakerlib library still uses 'master'
     repo = utils.fetch_repo(GIT_REPO_MASTER)
     output, _ = run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], repo)
     assert 'master' in output
Пример #2
0
 def test_fetch_default_branch(self):
     # On GitHub 'master' is the default
     repo = utils.fetch(GIT_REPO)
     output, _ = run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], repo)
     assert 'master' in output
     # Fedora uses 'rawide'
     repo = utils.fetch(GIT_REPO_FEDORA)
     output, _ = run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], repo)
     assert 'rawhide' in output
Пример #3
0
 def test_out_of_sync_ref(self, ref):
     """ Solve Your branch is behind ... """
     repo = utils.fetch_repo(GIT_REPO, ref)
     out, err = run(["git", "rev-parse", "HEAD"], repo)
     old_ref = out
     # Move head one commit back, doesn't invalidate FETCH!
     out, err = run(["git", "reset", "--hard", "HEAD^1"], repo)
     out, err = run(["git", "rev-parse", "HEAD"], repo)
     assert out != old_ref
     # Fetch again, it should move the head back to origin/main
     repo = utils.fetch_repo(GIT_REPO, ref)
     out, err = run(["git", "rev-parse", "HEAD"], repo)
     assert out == old_ref
Пример #4
0
 def test_switch_branches(self):
     # Default branch
     repo = utils.fetch_repo(GIT_REPO)
     output, _ = run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], repo)
     assert 'main' in output
     # Custom commit
     repo = utils.fetch_repo(GIT_REPO, '0.12')
     output, _ = run(['git', 'rev-parse', 'HEAD'], repo)
     assert '6570aa5' in output
     # Back to the default branch
     repo = utils.fetch_repo(GIT_REPO)
     output, _ = run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], repo)
     assert 'main' in output
Пример #5
0
    def commit(self):
        """
        Commit hash if tree grows under a git repo, False otherwise

        Return current commit hash if the metadata tree root is located
        under a git repository. For metadata initialized from a dict or
        local directory with no git repo 'False' is returned instead.
        """
        if self._commit is not None:
            return self._commit

        # No root, no commit (tree parsed from a dictionary)
        if self.root is None:
            self._commit = False
            return self._commit

        # Check root directory for current commit
        try:
            output, _ = utils.run(['git', 'rev-parse', '--verify', 'HEAD'],
                                  cwd=self.root)
            self._commit = output.strip()
        except subprocess.CalledProcessError:
            self._commit = False
        return self._commit