commit-updater 0.6.0__tar.gz → 0.7.0__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.
@@ -12,6 +12,7 @@ import subprocess
12
12
  from CommitUpdater.CommitFetcher import CommitFetcher
13
13
  from CommitUpdater.ComponentGitFinder import ComponentGitFinder
14
14
  from CommitUpdater.LockFileUpdater import LockFileUpdater
15
+ from CommitUpdater.ToolInfo import PACKAGE_NAME, PYPI_URL, TOOL_NAME, tool_version
15
16
 
16
17
 
17
18
  class MainProjUpdater:
@@ -27,16 +28,22 @@ class MainProjUpdater:
27
28
  print(f"[✓] Pulled latest changes for main project at {self.current_proj_dir}")
28
29
 
29
30
 
30
- def _git_commit_and_push(self, component_names):
31
- os.chdir(self.current_proj_dir)
32
- subprocess.run(["git", "add", "Podfile.lock"], check=True)
33
-
31
+ def _build_commit_message(self, component_names):
34
32
  if len(component_names) == 1:
35
- commit_message = f"[update] {component_names[0]}"
33
+ subject = f"[update] {component_names[0]}"
36
34
  else:
37
- components_str = ", ".join(component_names)
38
- commit_message = f"[update] Multiple components: {components_str}"
35
+ subject = f"[update] Multiple components: {', '.join(component_names)}"
36
+ # 标注提交来源,便于从主工程历史回溯 Podfile.lock 改动由哪次 bbcu 生成
37
+ return (
38
+ f"{subject}\n\n"
39
+ f"Committed-By: {TOOL_NAME} ({PACKAGE_NAME}) {tool_version()}\n"
40
+ f"Tool: {PYPI_URL}\n"
41
+ )
39
42
 
43
+ def _git_commit_and_push(self, component_names):
44
+ os.chdir(self.current_proj_dir)
45
+ subprocess.run(["git", "add", "Podfile.lock"], check=True)
46
+ commit_message = self._build_commit_message(component_names)
40
47
  subprocess.run(["git", "commit", "-m", commit_message], check=True)
41
48
  subprocess.run(["git", "push"], check=True)
42
49
  print(f"[✓] Git commit and push complete for {', '.join(component_names)}")
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: commit-updater
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Update Podfile.lock component commits from local git repos and push
5
5
  Author: Aron
6
6
  License: MIT
@@ -27,7 +27,7 @@ Description-Content-Type: text/markdown
27
27
  - 拉取主工程最新代码
28
28
  - 获取组件仓库最新 commit
29
29
  - 更新 `Podfile.lock` 中对应组件的 `:commit:`
30
- - 自动提交并推送主工程改动
30
+ - 自动提交并推送主工程改动(提交正文附带工具名、版本与 PyPI 地址,便于回溯)
31
31
 
32
32
  另有 `bbpull` 命令:自动识别当前开发者配置,批量拉取更新 `:method => LOCAL` 的本地组件仓库代码(不做任何 lock 文件改动)。
33
33
 
@@ -7,7 +7,7 @@
7
7
  - 拉取主工程最新代码
8
8
  - 获取组件仓库最新 commit
9
9
  - 更新 `Podfile.lock` 中对应组件的 `:commit:`
10
- - 自动提交并推送主工程改动
10
+ - 自动提交并推送主工程改动(提交正文附带工具名、版本与 PyPI 地址,便于回溯)
11
11
 
12
12
  另有 `bbpull` 命令:自动识别当前开发者配置,批量拉取更新 `:method => LOCAL` 的本地组件仓库代码(不做任何 lock 文件改动)。
13
13
 
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: UTF-8 -*-
3
+ """
4
+ 工具身份信息:提交信息里标注由哪个工具、哪个版本提交。
5
+ """
6
+ import importlib.metadata
7
+ import os
8
+ import re
9
+
10
+ PACKAGE_NAME = "commit-updater"
11
+ TOOL_NAME = "bbcu"
12
+ PYPI_URL = "https://pypi.org/project/commit-updater/"
13
+
14
+ _PYPROJECT_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "pyproject.toml")
15
+
16
+
17
+ def tool_version() -> str:
18
+ """优先读安装元数据;源码未安装时回退 pyproject,都取不到就返回 unknown"""
19
+ try:
20
+ return importlib.metadata.version(PACKAGE_NAME)
21
+ except importlib.metadata.PackageNotFoundError:
22
+ pass
23
+ try:
24
+ with open(_PYPROJECT_PATH, "r", encoding="utf-8") as f:
25
+ match = re.search(r'^\s*version\s*=\s*"([^"]+)"', f.read(), re.MULTILINE)
26
+ if match:
27
+ return match.group(1)
28
+ except OSError:
29
+ pass
30
+ return "unknown"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: commit-updater
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Update Podfile.lock component commits from local git repos and push
5
5
  Author: Aron
6
6
  License: MIT
@@ -27,7 +27,7 @@ Description-Content-Type: text/markdown
27
27
  - 拉取主工程最新代码
28
28
  - 获取组件仓库最新 commit
29
29
  - 更新 `Podfile.lock` 中对应组件的 `:commit:`
30
- - 自动提交并推送主工程改动
30
+ - 自动提交并推送主工程改动(提交正文附带工具名、版本与 PyPI 地址,便于回溯)
31
31
 
32
32
  另有 `bbpull` 命令:自动识别当前开发者配置,批量拉取更新 `:method => LOCAL` 的本地组件仓库代码(不做任何 lock 文件改动)。
33
33
 
@@ -4,6 +4,7 @@ LocalModulesUpdater.py
4
4
  LockFileUpdater.py
5
5
  MainProjUpdater.py
6
6
  README.md
7
+ ToolInfo.py
7
8
  __init__.py
8
9
  main.py
9
10
  pull_main.py
@@ -13,6 +14,7 @@ pyproject.toml
13
14
  ./LocalModulesUpdater.py
14
15
  ./LockFileUpdater.py
15
16
  ./MainProjUpdater.py
17
+ ./ToolInfo.py
16
18
  ./__init__.py
17
19
  ./main.py
18
20
  ./pull_main.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "commit-updater"
7
- version = "0.6.0"
7
+ version = "0.7.0"
8
8
  description = "Update Podfile.lock component commits from local git repos and push"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
File without changes
File without changes