Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ releases:
- action: Removed
details:
- "`#253`: symbolic link in regression pack causes python setup.py to do recursive include"
- "`#209`: Alert moban user when `git` is not available and is used."
date: unreleased
version: 0.4.3
- changes:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Removed

#. `#253 <https://github.com/moremoban/moban/issues/253>`_: symbolic link in
regression pack causes python setup.py to do recursive include
#. `#209 <https://github.com/moremoban/moban/issues/209>`_: Alert moban user
when `git` is not available and is used.

0.4.2 - 08.03.2019
--------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions moban/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ class IncorrectDataInput(Exception):

class GroupTargetNotFound(Exception):
pass


class NoGitCommand(Exception):
pass
17 changes: 16 additions & 1 deletion moban/repo.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import os
import sys
import subprocess

from moban import reporter, constants
from moban import reporter, constants, exceptions
from moban.utils import mkdir_p


def git_clone(requires):
from git import Repo

if sys.platform != "win32":
# Unfortunately for windows user, the following function
# needs shell=True, which expose security risk. I would
# rather not to trade it with its marginal benefit
make_sure_git_is_available()

moban_home = get_moban_home()
mkdir_p(moban_home)

Expand Down Expand Up @@ -51,3 +59,10 @@ def get_moban_home():

home_dir = user_cache_dir(appname=constants.PROGRAM_NAME)
return os.path.join(home_dir, constants.MOBAN_REPOS_DIR_NAME)


def make_sure_git_is_available():
try:
subprocess.check_output(["git", "--help"])
except Exception:
raise exceptions.NoGitCommand("Please install git command")
2 changes: 1 addition & 1 deletion tests/mobanfile/test_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_handling_group_target():
def test_extract_group_targets():
test_targets = [
{"output": "a.output", "template": "a.template.jj2"},
{"copy": [{"output": "source"}], "copy1": [{"output1": "source1"}]}
{"copy": [{"output": "source"}], "copy1": [{"output1": "source1"}]},
]
actual = targets.extract_group_targets("copy1", test_targets)
expected = [{"copy1": [{"output1": "source1"}]}]
Expand Down
16 changes: 14 additions & 2 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import os

from mock import patch
from nose.tools import eq_
from nose.tools import eq_, raises

from moban.repo import git_clone, get_repo_name, get_moban_home
from moban.repo import (
git_clone,
get_repo_name,
get_moban_home,
make_sure_git_is_available,
)
from moban.exceptions import NoGitCommand
from moban.definitions import GitRequire


Expand Down Expand Up @@ -112,3 +118,9 @@ def test_get_repo_name_can_handle_invalid_url(fake_reporter):
def test_get_moban_home(_):
actual = get_moban_home()
eq_(os.path.join("root", "repos"), actual)


@raises(NoGitCommand)
@patch("subprocess.check_output", side_effect=Exception)
def test_make_git_is_available(_):
make_sure_git_is_available()