|
| 1 | +import subprocess |
1 | 2 | import os |
2 | 3 | import git |
3 | 4 | import sys |
|
14 | 15 | print("No commit hash specified") |
15 | 16 | commit_diff = "f8b529a956da57d8623247bea594e65469cac1c5" |
16 | 17 |
|
| 18 | +tag = commit_diff # 替换为您要使用的标签 |
| 19 | +output_file = "diff.md" # 替换为您要写入的文件名 |
| 20 | + |
| 21 | +f = open(output_file, "w") |
| 22 | + |
17 | 23 | # checkout to the commit_diff |
18 | 24 | repo.git.checkout(commit_diff) |
19 | 25 | pkgReleases_diff = PackageReleaseList(PACKAGE_RELEASE_PATH) |
20 | 26 |
|
21 | 27 | # checkout master |
22 | 28 | repo.git.checkout("master") |
23 | 29 |
|
| 30 | +f.write(f"# Diff from PikaPython {commit_diff}\n") |
| 31 | + |
| 32 | +f.write(f"## package diff\n") |
| 33 | +f.write("|package|state|version|\n") |
| 34 | +f.write("|---|---|---|\n") |
| 35 | + |
24 | 36 | # find new released package and package version |
25 | 37 | for pkg in pkgReleases.packages: |
26 | 38 | # find pkg in pkgReleases_diff |
27 | 39 | pkg_diff = pkgReleases_diff.findPackage(pkg.name) |
28 | 40 | if None == pkg_diff: |
29 | 41 | # print("New package: " + pkg.name + pkg.latestVersion().version) |
30 | | - print(f"|{pkg.name}| Create | {pkg.latestVersion().version}|") |
| 42 | + out_str = f"|{pkg.name}| Create | {pkg.latestVersion().version}|" |
| 43 | + print(out_str) |
| 44 | + f.write(out_str + '\n') |
31 | 45 | continue |
32 | 46 |
|
33 | 47 | pkg_diff = pkgReleases_diff.findPackage(pkg.name) |
34 | 48 | if pkg_diff.latestVersion().version != pkg.latestVersion().version: |
35 | | - print( |
36 | | - f"|{pkg.name}| Update | {pkg_diff.latestVersion().version} --> {pkg.latestVersion().version}|") |
| 49 | + out_str = f"|{pkg.name}| Update | {pkg_diff.latestVersion().version} --> {pkg.latestVersion().version}|" |
| 50 | + print(out_str) |
| 51 | + f.write(out_str + '\n') |
| 52 | + |
| 53 | +# 构建 git log 命令并调用 subprocess 执行 |
| 54 | +git_log_cmd = f"git log {tag}..HEAD --pretty=format:%s" |
| 55 | +result = subprocess.run(git_log_cmd, stdout=subprocess.PIPE, shell=True) |
37 | 56 |
|
| 57 | +# 从结果中获取输出并将其写入文件 |
| 58 | +output_str = result.stdout.decode("utf-8").replace('\n', '\n\n') |
| 59 | +f.write('## git diff\n') |
| 60 | +f.write(output_str) |
| 61 | +f.close() |
38 | 62 | exit() |
0 commit comments