allow working from inside the working dir
This commit is contained in:
parent
a76768e3dc
commit
7ade8ccd3a
|
@ -26,8 +26,11 @@ def slugify(title):
|
|||
return title
|
||||
|
||||
|
||||
def get_repo():
|
||||
return git.Repo(search_parent_directories=True)
|
||||
|
||||
def get_config(name, default=Ellipsis):
|
||||
repo = git.Repo()
|
||||
repo = get_repo()
|
||||
reader = repo.config_reader()
|
||||
if not reader.has_section('redmine'):
|
||||
raise click.UsageError('Please add a redmine section to your git configuration')
|
||||
|
@ -59,7 +62,7 @@ def get_redmine_api():
|
|||
|
||||
|
||||
def set_redmine(section, option, value):
|
||||
repo = git.Repo()
|
||||
repo = get_repo()
|
||||
config_writer = repo.config_writer()
|
||||
if not config_writer.has_section(section):
|
||||
config_writer.add_section(section)
|
||||
|
@ -84,7 +87,7 @@ def get_issue(issue_number=None):
|
|||
|
||||
|
||||
def get_current_issue():
|
||||
repo = git.Repo()
|
||||
repo = get_repo()
|
||||
branch_name = repo.head.reference.name
|
||||
splitted = branch_name.rsplit('/', 1)
|
||||
issue_number = splitted[-1].split('-')[0]
|
||||
|
@ -105,7 +108,7 @@ def get_current_project():
|
|||
|
||||
|
||||
def get_patches(number_of_commits=0):
|
||||
repo = git.Repo()
|
||||
repo = get_repo()
|
||||
tempdir = tempfile.mkdtemp()
|
||||
if number_of_commits:
|
||||
ref = 'HEAD' + '~' * number_of_commits
|
||||
|
@ -133,7 +136,7 @@ def redmine():
|
|||
def shell():
|
||||
import IPython
|
||||
api = get_redmine_api()
|
||||
repo = git.Repo()
|
||||
repo = get_repo()
|
||||
IPython.embed()
|
||||
|
||||
|
||||
|
@ -188,7 +191,7 @@ def take(issue_number):
|
|||
'''Create or switch to a branch to fix an issue'''
|
||||
api = get_redmine_api()
|
||||
issue = api.issue.get(issue_number, include='attachments')
|
||||
repo = git.Repo()
|
||||
repo = get_repo()
|
||||
new = False
|
||||
for head in repo.heads:
|
||||
if '/%s-' % issue_number in head.name:
|
||||
|
@ -221,7 +224,7 @@ def take(issue_number):
|
|||
@click.option('--issue', default=None, type=int)
|
||||
def apply(issue):
|
||||
issue = get_issue(issue)
|
||||
repo = git.Repo()
|
||||
repo = get_repo()
|
||||
apply_attachments(repo, issue)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue