Skip to content

Commit

Permalink
Refactored the way of detecting git-url in the create command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Munda committed Oct 29, 2012
1 parent 61f0ae4 commit 9da2318
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions baboon/baboon/commands.py
Expand Up @@ -130,9 +130,14 @@ def create():
if not _on_action_finished(ret_status, msg):
return

_auto_init(path)
dump()

# Do an init() if the git-url can be guessed.
git_url = _get_git_url(path)
if git_url:
config['parser']['git-url'] = git_url
init()


@command
def delete():
Expand Down Expand Up @@ -446,22 +451,13 @@ def _get_project_path(project_name):
"configuration file.")


def _auto_init(path):
""" Try to auto-detect the git origin url in the path dir and do an init()
with that url.
def _get_git_url(path):
""" Try to auto-detect the git origin url in the path dir. If found, return
it.
"""

err = "Cannot find the git origin url. Please run the init command."
if not os.path.isdir(path):
cwarn(err)
return

ret_code, output, _ = exec_cmd('git config --get remote.origin.url', path)
if ret_code == 0:
config['parser']['git-url'] = output
init()
else:
cwarn(err)
return output if ret_code == 0 else None


def _delete_metadir(project_name, project_path):
Expand Down

0 comments on commit 9da2318

Please sign in to comment.