Commit 3ce57e20 authored by Michal Čihař's avatar Michal Čihař

Implement needs_push/needs_merge to vcs abstraction

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 4fa82270
......@@ -85,3 +85,8 @@ class VCSGitTest(RepoTestCase):
self.assertTrue('authordate' in info)
self.assertTrue('commit' in info)
self.assertTrue('commitdate' in info)
def test_merge(self):
repo = GitRepository.clone(self.repo_path, self._tempdir)
self.assertFalse(repo.needs_merge('master'))
self.assertFalse(repo.needs_push('master'))
......@@ -38,7 +38,6 @@ class Repository(object):
- repository configuration (SubProject.configure_repo)
- branch configuration (SubProject.configure_branch)
- needs merge/push (SubProject.git_needs_merge/push)
- get object hash (Translation.get_git_blob_hash)
- commit (Translation.__git_commit)
- configuration (Translation.__configure_committer)
......@@ -143,6 +142,20 @@ class Repository(object):
"""
raise NotImplementedError()
def needs_merge(self, branch):
"""
Checks whether repository needs merge with upstream
(is missing some revisions).
"""
raise NotImplementedError()
def needs_push(self, branch):
"""
Checks whether repository needs push to upstream
(has additional revisions).
"""
raise NotImplementedError()
def get_revision_info(self, revision):
"""
Returns dictionary with detailed revision information.
......@@ -221,3 +234,25 @@ class GitRepository(Repository):
result['summary'] = message[0]
return result
def _log_revisions(self, refspec):
"""
Returns revisin log for given refspec.
"""
return self._execute(
['log', '--oneline', refspec, '--']
)
def needs_merge(self, branch):
"""
Checks whether repository needs merge with upstream
(is missing some revisions).
"""
return self._log_revisions('..origin/{0}'.format(branch)) != ''
def needs_push(self, branch):
"""
Checks whether repository needs push to upstream
(has additional revisions).
"""
return self._log_revisions('origin/{0}..'.format(branch)) != ''
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment