git-sanity 2.0.0__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {git-sanity-2.0.0 → git-sanity-2.0.2}/PKG-INFO +1 -1
  2. {git-sanity-2.0.0 → git-sanity-2.0.2}/setup.py +6 -3
  3. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/__init__.py +1 -1
  4. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/__main__.py +6 -0
  5. git-sanity-2.0.2/src/git_sanity/command.py +32 -0
  6. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/init.py +4 -0
  7. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/utils.py +0 -3
  8. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity.egg-info/PKG-INFO +1 -1
  9. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity.egg-info/SOURCES.txt +1 -0
  10. {git-sanity-2.0.0 → git-sanity-2.0.2}/LICENSE.txt +0 -0
  11. {git-sanity-2.0.0 → git-sanity-2.0.2}/README.md +0 -0
  12. {git-sanity-2.0.0 → git-sanity-2.0.2}/setup.cfg +0 -0
  13. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/branch.py +0 -0
  14. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/clone.py +0 -0
  15. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/push.py +0 -0
  16. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/switch.py +0 -0
  17. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity/sync.py +0 -0
  18. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity.egg-info/dependency_links.txt +0 -0
  19. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity.egg-info/entry_points.txt +0 -0
  20. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity.egg-info/requires.txt +0 -0
  21. {git-sanity-2.0.0 → git-sanity-2.0.2}/src/git_sanity.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: git-sanity
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: Manage multiple git repos with sanity
5
5
  Home-page: https://github.com/yuqiaoyu/git-sanity
6
6
  Author: yuqiaoyu
@@ -3,10 +3,13 @@
3
3
  """
4
4
 
5
5
  from setuptools import setup, find_packages
6
+ from src.git_sanity import __prog_name__
7
+ from src.git_sanity import __version__
8
+ from src.git_sanity import __author__
6
9
 
7
10
  setup(
8
- name="git-sanity",
9
- version="2.0.0",
11
+ name=__prog_name__,
12
+ version=__version__,
10
13
  package_dir={"":"src"},
11
14
  packages=find_packages(where="src"),
12
15
  license="MIT",
@@ -16,7 +19,7 @@ setup(
16
19
  url="https://github.com/yuqiaoyu/git-sanity",
17
20
  platforms=["linux", "osx", "win32"],
18
21
  keywords=["git", "manage multiple repositories", "cui", "command-line"],
19
- author="yuqiaoyu",
22
+ author=__author__,
20
23
  author_email="yu_junqiang@qq.com",
21
24
  entry_points={"console_scripts": ["git-sanity = git_sanity.__main__:main"]},
22
25
  python_requires="~=3.10",
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
 
3
3
  __prog_name__ = "git-sanity"
4
- __version__ = "1.0.0"
4
+ __version__ = "2.0.2"
5
5
  __author__ = "yuqiaoyu"
6
6
  __config_root_dir__ = "." + __prog_name__
7
7
  __config_file_name__ = __prog_name__ + "_config.json"
@@ -9,6 +9,7 @@ from git_sanity.sync import sync_impl
9
9
  from git_sanity.switch import switch_impl
10
10
  from git_sanity.branch import branch_impl
11
11
  from git_sanity.push import push_impl
12
+ from git_sanity.command import command_impl
12
13
 
13
14
  def main():
14
15
  logging.info("New Run ==================================================")
@@ -61,6 +62,11 @@ def main():
61
62
  prog_push.add_argument("-f", "--force", dest="force", action='store_true', help="force updates")
62
63
  prog_push.set_defaults(func=push_impl)
63
64
 
65
+ prog_command = subparsers.add_parser("command", description="Execute user-defined commands", help="execute user-defined commands")
66
+ prog_command.add_argument("-c", "--command", dest="command_name", help="execute 'command_name'")
67
+ prog_command.add_argument("-l", "--list", dest="list", action='store_true', help="list all user-defined commands")
68
+ prog_command.set_defaults(func=command_impl)
69
+
64
70
  args = prog.parse_args()
65
71
  logging.debug("command args={}".format(args))
66
72
  if "func" in args:
@@ -0,0 +1,32 @@
1
+ import logging
2
+ import os
3
+ from git_sanity import __config_root_dir__
4
+ from git_sanity import __config_file_name__
5
+ from git_sanity.utils import run
6
+ from git_sanity.utils import get_config_dir
7
+ from git_sanity.utils import load_user_config
8
+ from git_sanity.utils import get_user_config
9
+
10
+ def list_commands():
11
+ logging.info("user-defined commands:")
12
+ config_root_dir = os.path.join(get_config_dir(), __config_root_dir__)
13
+ for command in get_user_config(load_user_config(), "commands"):
14
+ print(command)
15
+
16
+
17
+ def execute_command(command_name):
18
+ config_root_dir = os.path.join(get_config_dir(), __config_root_dir__)
19
+ for command in get_user_config(load_user_config(), "commands"):
20
+ if command_name in command:
21
+ run(command[command_name], workspace=config_root_dir)
22
+ break
23
+ else:
24
+ logging.error("the command `{}` is not defined in {}:commands.".format(command_name, os.path.join(config_root_dir, __config_file_name__)))
25
+ exit(1)
26
+
27
+
28
+ def command_impl(args):
29
+ if args.list:
30
+ list_commands()
31
+ else:
32
+ execute_command(args.command_name)
@@ -30,6 +30,10 @@ default_config = {
30
30
  "<!--project_name, default=[]-->"
31
31
  ]
32
32
  }
33
+ ],
34
+ "commands" : [
35
+ {"<!--command_name-->": ["<!--command and command args-->"]},
36
+ {"<!--test-->": ["<!-- ls -->", "<!-- -l -->"]}
33
37
  ]
34
38
  }
35
39
 
@@ -26,9 +26,6 @@ def run(command, workspace="./", env=os.environ, capture_output=False):
26
26
  Examples:
27
27
  >>> run(["ls", "-l"], capture_output=True)
28
28
  ('total 8\n-rw-r--r-- 1 user group 1234 Jan 1 12:34 file.txt', '')
29
-
30
- >>> run("ls -l", capture_output=False)
31
- True
32
29
  """
33
30
  logging.debug("(cwd:{}) Running: {}".format(workspace, command))
34
31
  result = subprocess.run(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: git-sanity
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: Manage multiple git repos with sanity
5
5
  Home-page: https://github.com/yuqiaoyu/git-sanity
6
6
  Author: yuqiaoyu
@@ -5,6 +5,7 @@ src/git_sanity/__init__.py
5
5
  src/git_sanity/__main__.py
6
6
  src/git_sanity/branch.py
7
7
  src/git_sanity/clone.py
8
+ src/git_sanity/command.py
8
9
  src/git_sanity/init.py
9
10
  src/git_sanity/push.py
10
11
  src/git_sanity/switch.py
File without changes
File without changes
File without changes