Permalink
Browse files

add -C to git.get_arg

  • Loading branch information...
1 parent 3745c63 commit 65d3828a2d36684b97480bdf06716503228a8da8 @rzeng-baina rzeng-baina committed Jan 19, 2016
Showing with 32 additions and 7 deletions.
  1. +1 −1 rookout/__init__.py
  2. +7 −4 rookout/git.py
  3. +24 −2 setup.py
View
@@ -14,7 +14,7 @@
import logging
-__version__ = "0.4.0"
+__version__ = "0.4.6"
__all__ = ['base', 'git', 'lua', 'ftp', 'gettext', 'conf']
slog = logging.getLogger("system")
View
@@ -3,7 +3,7 @@
# Author zrong(zengrong.net)
#
# Creation 2014-10-23
-# Last Editing 2015-06-14
+# Last Editing 2016-01-18
########################################
"""
.. module:: git
@@ -46,7 +46,7 @@ def call(path, *args, encoding="utf-8"):
output = err.output
return returncode, output
-def get_args(path, *args, bare=False):
+def get_args(path, *args, work_tree=True, bare=False):
"""获取可被 subprogress 执行的 git 参数 list。
:param str path: git 仓库文件夹路径。
@@ -56,11 +56,14 @@ def get_args(path, *args, bare=False):
"""
base = [ 'git' ]
if path:
+ base.append('-C')
+ base.append(path)
if bare:
base.append('--bare')
base.append("--git-dir="+path)
else:
base.append("--git-dir="+os.path.join(path, ".git"))
+ if work_tree:
base.append("--work-tree="+path)
for arg in args:
base.append(arg)
@@ -148,14 +151,14 @@ def update_submodules(path, init=True, update=True):
"""
succ = None
if init:
- arg = get_args(path, 'submodule', 'init')
+ arg = get_args(path, 'submodule', 'init', work_tree=False)
slog.info(' '.join(arg))
succ = subprocess.call(arg)
if succ>0:
slog.error('git execute error!')
return succ
if update:
- arg = get_args(path, "submodule", "update")
+ arg = get_args(path, "submodule", "update", work_tree=False)
slog.info(' '.join(arg))
succ = subprocess.call(arg)
if succ>0:
View
@@ -1,12 +1,34 @@
+import os
+import re
from setuptools import setup, find_packages
+here = os.path.abspath(os.path.dirname(__file__))
+
+def read(*parts):
+ content = None
+ with open(os.path.join(here, *parts), 'r', encoding='utf-8') as f:
+ content = f.read()
+ return content
+
+def find_version(*file_paths):
+ version_file = read(*file_paths)
+ version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
+ version_file, re.M)
+ if version_match:
+ return version_match.group(1)
+ raise RuntimeError("Unable to find version string.")
+
+def find_requires(*file_paths):
+ require_file = read(*file_paths)
+ return require_file.splitlines()
+
setup(
name = "rookout",
- version = "0.4.5",
+ version=find_version('rookout', '__init__.py'),
description = "A rookie's workout library by zrong.",
author = "zrong",
author_email = "zrongzrong@gmail.com",
- url = "http://github.com/zrong/python",
+ url = "http://github.com/zrong/rookout",
license = "MIT",
keywords = "utils development zrong rookie workout",
packages = find_packages(exclude=["tests*","docs"]),

0 comments on commit 65d3828

Please sign in to comment.