Skip to content

Commit 203d5c3

Browse files
authored
Merge pull request #116 from moremoban/dev
release 0.3.3
2 parents 9a322e2 + 104f82c commit 203d5c3

File tree

13 files changed

+154
-19
lines changed

13 files changed

+154
-19
lines changed

.moban.cd/changelog.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ releases:
44
- changes:
55
- action: Added
66
details:
7-
- "`requires` shall support configuration dirs. In other words, configuration file could be stored in python package or git repository."
7+
- "alternative and expanded syntax for requires, so as to accomendate github submodule recursive"
88
date: 05-11-2018
9+
version: 0.3.3
10+
- changes:
11+
- action: Added
12+
details:
13+
- "`requires` shall support configuration dirs. In other words, configuration file could be stored in python package or git repository."
14+
date: 04-11-2018
915
version: 0.3.2
1016
- changes:
1117
- action: Added

.moban.cd/moban.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ organisation: moremoban
33
author: C. W.
44
contact: wangc_2011@hotmail.com
55
license: MIT
6-
version: 0.3.2
7-
current_version: 0.3.2
8-
release: 0.3.2
6+
version: 0.3.3
7+
current_version: 0.3.3
8+
release: 0.3.3
99
branch: master
1010
command_line_interface: "moban"
1111
entry_point: "moban.main:main"

CHANGELOG.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
Change log
22
================================================================================
33

4-
0.3.2 - 05-11-2018
4+
0.3.3 - 05-11-2018
5+
--------------------------------------------------------------------------------
6+
7+
Added
8+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+
10+
#. alternative and expanded syntax for requires, so as to accomendate github
11+
submodule recursive
12+
13+
0.3.2 - 04-11-2018
514
--------------------------------------------------------------------------------
615

716
Added

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
author = u'C. W.'
2929

3030
# The short X.Y version
31-
version = u'0.3.2'
31+
version = u'0.3.3'
3232
# The full version, including alpha/beta/rc tags
33-
release = u'0.3.2'
33+
release = u'0.3.3'
3434

3535

3636
# -- General configuration ---------------------------------------------------

docs/level-10-moban-dependency-as-git-repo/README.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,17 @@ Here are the sample file::
2323
- test.txt: demo.txt.jj2
2424

2525
where `requires` lead to a list of pypi packages. And when you refer to it,
26-
please use "pypi-mobans:"
26+
as in level-9 section, please use "pypi-mobans:"
27+
28+
29+
Alternative syntax when submodule exists
30+
--------------------------------------------------------------------------------
31+
32+
The alternative syntax is::
33+
34+
requires:
35+
- type: git
36+
url: https://github.com/your-git-url
37+
submodule: true
38+
...
39+

docs/level-9-moban-dependency-as-pypi-package/README.rst

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,29 @@ Here are the sample file::
2121
- mytravis.yml: travis.yml.jj2
2222
- test.txt: demo.txt.jj2
2323

24-
where `requires` lead to a list of pypi packages. And when you refer to it,
25-
please use "pypi-mobans:"
24+
where `requires` lead to a list of pypi packages. The short syntax is::
25+
26+
requires:
27+
- python-package-name
28+
29+
When you refer to it in configuration section, here is the syntax::
30+
31+
configuration:
32+
- template_dir:
33+
- "python-package-name:relative-folder-inside-the-package"
34+
35+
Note: when you do not have relative directory, please keep semi-colon::
36+
37+
configuration:
38+
template_dir:
39+
- "python-package-name:"
40+
41+
Alternative syntax
42+
--------------------------------------------------------------------------------
43+
44+
The alternative syntax is::
45+
46+
requires:
47+
- type: pypi
48+
name: pypi-mobans
49+
...

moban/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.3.2"
1+
__version__ = "0.3.3"
22
__author__ = "C. W."

moban/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@
7272
ERROR = 2
7373
NO_CHANGES = 0
7474

75+
# Require
76+
GIT_REQUIRE = "GIT"
77+
GIT_HAS_SUBMODULE = "submodule"
78+
GIT_URL = "url"
79+
PYPI_REQUIRE = "PYPI"
80+
PYPI_PACKAGE_NAME = "name"
81+
REQUIRE_TYPE = "type"
82+
7583

7684
# Extension
7785
JINJA_FILTER_EXTENSION = "jinja_filter"

moban/mobanfile.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,29 @@ def extract_target(options):
156156
def handle_requires(requires):
157157
pypi_pkgs = []
158158
git_repos = []
159+
git_repos_with_sub = []
159160
for require in requires:
160-
if is_repo(require):
161-
git_repos.append(require)
161+
if isinstance(require, dict):
162+
require_type = require.get(constants.REQUIRE_TYPE, "")
163+
if require_type.upper() == constants.GIT_REQUIRE:
164+
submodule_flag = require.get(constants.GIT_HAS_SUBMODULE)
165+
if submodule_flag is True:
166+
git_repos_with_sub.append(require.get(constants.GIT_URL))
167+
else:
168+
git_repos.append(require.get(constants.GIT_URL))
169+
elif require_type.upper() == constants.PYPI_REQUIRE:
170+
pypi_pkgs.append(require.get(constants.PYPI_PACKAGE_NAME))
162171
else:
163-
pypi_pkgs.append(require)
172+
if is_repo(require):
173+
git_repos.append(require)
174+
else:
175+
pypi_pkgs.append(require)
164176
if pypi_pkgs:
165177
pip_install(pypi_pkgs)
166178
if git_repos:
167179
git_clone(git_repos)
180+
if git_repos_with_sub:
181+
git_clone(git_repos_with_sub, submodule=True)
168182

169183

170184
def is_repo(require):

moban/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def pip_install(packages):
149149
)
150150

151151

152-
def git_clone(repos):
152+
def git_clone(repos, submodule=False):
153153
import subprocess
154154

155155
moban_home = get_moban_home()
@@ -163,10 +163,16 @@ def git_clone(repos):
163163
reporter.report_git_pull(repo_name)
164164
os.chdir(local_repo_folder)
165165
subprocess.check_call(["git", "pull"])
166+
if submodule:
167+
subprocess.check_call(["git", "submodule", "update"])
166168
else:
167169
reporter.report_git_clone(repo_name)
168170
os.chdir(moban_home)
169171
subprocess.check_call(["git", "clone", repo, repo_name])
172+
if submodule:
173+
os.chdir(os.path.join(moban_home, repo_name))
174+
subprocess.check_call(["git", "submodule", "init"])
175+
subprocess.check_call(["git", "submodule", "update"])
170176
os.chdir(current_working_dir)
171177

172178

0 commit comments

Comments
 (0)