# Path: ellen/utils/process.py
# def git_with_repo(repository):
#     git_dir = repository.path
#     work_tree = repository.workdir
#     return git_with_path(git_dir, work_tree)


from ellen.utils.process import git_with_repo
#!/usr/bin/env python
# -*- coding: utf-8 -*-



def format_patch(repository, ref, from_ref=None):
    git = git_with_repo(repository)
    rev_range = '%s...%s' % (from_ref, ref) if from_ref else ref
    git_format_patch = git.bake('format-patch', stdout=True)
    if not from_ref:
        git_format_patch = git_format_patch.bake('-1')

# Path: ellen/utils/process.py
# def git_with_repo(repository):
#     git_dir = repository.path
#     work_tree = repository.workdir
#     return git_with_path(git_dir, work_tree)


# Path: ellen/git/format_patch.py
from ellen.utils.process import git_with_repo

#!/usr/bin/env python
# -*- coding: utf-8 -*-



def format_patch(repository, ref, from_ref=None):
    git = git_with_repo(repository)
    rev_range = '%s...%s' % (from_ref, ref) if from_ref else ref
    git_format_patch = git.bake('format-patch', stdout=True)
    if not from_ref:
        git_format_patch = git_format_patch.bake('-1')

    ret = git_format_patch(rev_range)