def fetch(): cmd = ['git', 'fetch', get_remote(), 'refs/heads/{0}:refs/remotes/origin/{0}'.format(get_branch())] p = Popen(cmd, cwd=get_repository().workdir) status = p.wait() if status: raise GitError('git-fetch returned with exit status {}'.format(status))
def fetch(): cmd = [ 'git', 'fetch', get_remote(), 'refs/heads/{0}:refs/remotes/origin/{0}'.format(get_branch()), ] p = Popen(cmd, cwd=get_repository().workdir) status = p.wait() if status: raise GitError('git-fetch returned with exit status {}'.format(status))
def begin(): global _transaction if _transaction: raise GitError('there is already a transaction running') repo = get_repository() if repo is None: raise GitError('no repository found') ref = 'refs/heads/{}'.format(get_branch()) try: parents = [repo.lookup_reference(ref).oid] except KeyError: parents = [] _transaction = Transaction(repo, parents)
def commit(self, message=None): if not self.has_changes: raise GitError( 'nothing changed; use rollback to abort the transaction') if not message: if not self.messages: raise GitError('no message for commit') message = '\n'.join(self.messages) elif self.messages: message += '\n\n' + '\n'.join(self.messages) tree_id = self._store_objects(self.memory_tree) try: name = self.repo.config['user.name'] email = self.repo.config['user.email'] except KeyError as e: raise GitError('{} not found in git config'.format(e)) sig = pygit2.Signature(name, email) ref = 'refs/heads/{}'.format(get_branch()) self.repo.create_commit( ref, sig, sig, message, tree_id, self.parents, 'utf-8')
def commit(self, message=None): if not self.has_changes: raise GitError( 'nothing changed; use rollback to abort the transaction') if not message: if not self.messages: raise GitError('no message for commit') message = '\n'.join(self.messages) elif self.messages: message += '\n\n' + '\n'.join(self.messages) tree_id = self._store_objects(self.memory_tree) try: name = self.repo.config['user.name'] email = self.repo.config['user.email'] except KeyError as e: raise GitError('{} not found in git config'.format(e)) sig = pygit2.Signature(name, email) ref = 'refs/heads/{}'.format(get_branch()) self.repo.create_commit(ref, sig, sig, message, tree_id, self.parents, 'utf-8')
def setup(self): self.repo = pygit2.init_repository(mkdtemp(), False) set_repository(self.repo.path) self.branchref = 'refs/heads/{}'.format(get_branch()) self.assert_commit_count(0)
def begin(): global _transaction if _transaction: raise GitError('there is already a transaction running') _transaction = Transaction(repository_path=get_repository(), branch_name=get_branch())
def format(self, repo): return super().format(git_orm.get_branch())
def clean(self, value): git_orm.set_branch(value) return git_orm.get_branch()