@jetthai/cuora 1.1.427-hotfix.1 → 1.1.427-qa.0
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.
- package/.claude/commands/commit-push.md +13 -69
- package/.husky/post-checkout +3 -7
- package/.husky/pre-commit +0 -1
- package/.husky/pre-push +0 -25
- package/CHANGELOG.md +1 -15
- package/package.json +1 -1
- package/scripts/auto-version.js +14 -16
- package/scripts/auto-version.sh +6 -10
- package/scripts/branch-auto-npm-publish.js +5 -7
- package/scripts/clean-tags.sh +11 -16
- package/src/machine/withdraw/withdraw_crypto_cash.js +1 -1
- package/src/machine/withdraw/withdraw_manual_cash.js +1 -1
|
@@ -4,43 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
## Step 1 —
|
|
8
|
-
|
|
9
|
-
檢查當前分支的遠端是否有更新:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
git fetch origin
|
|
13
|
-
git status
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
如果本地已經是最新(沒有 behind commits),直接進入 Step 2。
|
|
17
|
-
|
|
18
|
-
如果遠端有更新(本地 behind),執行 pull:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
git pull
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
如果 pull 發生衝突:
|
|
25
|
-
|
|
26
|
-
1. 取消 merge:
|
|
27
|
-
```bash
|
|
28
|
-
git merge --abort
|
|
29
|
-
```
|
|
30
|
-
2. 告知使用者:「遠端有更新且與本地變更衝突,請先還原當前所有檔案的異動,還原完成後請回覆。」
|
|
31
|
-
3. 等待使用者回覆。
|
|
32
|
-
4. 使用者回覆後,重新執行 pull:
|
|
33
|
-
```bash
|
|
34
|
-
git pull
|
|
35
|
-
```
|
|
36
|
-
5. Pull 成功後,告知使用者:「遠端同步完成,請將剛才還原的異動重新加回,完成後請回覆。」
|
|
37
|
-
6. 等待使用者回覆確認已全部加回,再繼續後續流程。
|
|
38
|
-
|
|
39
|
-
出現錯誤則停止,詢問使用者要怎麼做。
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Step 2 — 檢查工作區狀態
|
|
7
|
+
## Step 1 — 檢查工作區狀態
|
|
44
8
|
|
|
45
9
|
```bash
|
|
46
10
|
git status
|
|
@@ -54,7 +18,7 @@ git status
|
|
|
54
18
|
|
|
55
19
|
---
|
|
56
20
|
|
|
57
|
-
## Step
|
|
21
|
+
## Step 2 — Stage 變更
|
|
58
22
|
|
|
59
23
|
將所有變更加入 staging area:
|
|
60
24
|
|
|
@@ -66,7 +30,7 @@ git add -A
|
|
|
66
30
|
|
|
67
31
|
---
|
|
68
32
|
|
|
69
|
-
## Step
|
|
33
|
+
## Step 3 — 選擇 Commit Message 方式
|
|
70
34
|
|
|
71
35
|
使用 `AskUserQuestion` 工具顯示選單,讓使用者從以下選項中選擇:
|
|
72
36
|
|
|
@@ -80,7 +44,7 @@ git add -A
|
|
|
80
44
|
|
|
81
45
|
---
|
|
82
46
|
|
|
83
|
-
## Step
|
|
47
|
+
## Step 4 — 生成 Commit Message
|
|
84
48
|
|
|
85
49
|
根據使用者在 Step 3 的選擇執行:
|
|
86
50
|
|
|
@@ -91,27 +55,7 @@ git add -A
|
|
|
91
55
|
- 格式:`type(scope): description`
|
|
92
56
|
- type:feat / fix / refactor / style / docs / chore / perf / test
|
|
93
57
|
- scope:根據變更的主要目錄或功能模組決定(可省略)
|
|
94
|
-
- description
|
|
95
|
-
|
|
96
|
-
當變更涉及多個不同類型或模組時,自行分類並以條列式呈現:
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
type(scope): 主要描述
|
|
100
|
-
|
|
101
|
-
- type(scope): 細項描述 1
|
|
102
|
-
- type(scope): 細項描述 2
|
|
103
|
-
- type(scope): 細項描述 3
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
例如:
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
feat(payment): 新增加密貨幣存款功能
|
|
110
|
-
|
|
111
|
-
- feat(deposit): 新增 USDT 存款方式
|
|
112
|
-
- fix(withdraw): 修正提款金額驗證邏輯
|
|
113
|
-
- style(modal): 調整存款彈窗樣式
|
|
114
|
-
```
|
|
58
|
+
- description:簡潔描述變更內容(英文)
|
|
115
59
|
|
|
116
60
|
如果是選項 2,將生成的 message 顯示給使用者,等待使用者確認或提供修改後的版本。
|
|
117
61
|
|
|
@@ -127,7 +71,7 @@ feat(payment): 新增加密貨幣存款功能
|
|
|
127
71
|
|
|
128
72
|
---
|
|
129
73
|
|
|
130
|
-
## Step
|
|
74
|
+
## Step 5 — 執行 Commit
|
|
131
75
|
|
|
132
76
|
使用確定的 commit message 執行 commit:
|
|
133
77
|
|
|
@@ -145,20 +89,20 @@ git commit -m "<title>" -m "<body>"
|
|
|
145
89
|
|
|
146
90
|
---
|
|
147
91
|
|
|
148
|
-
## Step
|
|
92
|
+
## Step 6 — 確認是否 Push
|
|
149
93
|
|
|
150
94
|
使用 `AskUserQuestion` 工具顯示選單,讓使用者從以下選項中選擇:
|
|
151
95
|
|
|
152
96
|
- **Push** — 立即 push 到遠端
|
|
153
|
-
- **
|
|
97
|
+
- **不 Push** — 只 commit,不 push
|
|
154
98
|
|
|
155
99
|
等待使用者選擇。
|
|
156
100
|
|
|
157
|
-
|
|
101
|
+
如果使用者選擇「不 Push」,跳過 push 直接進入 Step 8 完成回報。
|
|
158
102
|
|
|
159
|
-
|
|
103
|
+
---
|
|
160
104
|
|
|
161
|
-
|
|
105
|
+
## Step 7 — 執行 Push
|
|
162
106
|
|
|
163
107
|
將 commit push 到遠端:
|
|
164
108
|
|
|
@@ -176,10 +120,10 @@ git push --set-upstream origin <current_branch>
|
|
|
176
120
|
|
|
177
121
|
---
|
|
178
122
|
|
|
179
|
-
## Step
|
|
123
|
+
## Step 8 — 完成回報
|
|
180
124
|
|
|
181
125
|
顯示以下資訊:
|
|
182
126
|
|
|
183
127
|
- 分支名稱
|
|
184
128
|
- Commit message 內容
|
|
185
|
-
- Push
|
|
129
|
+
- Push 結果(成功/失敗)
|
package/.husky/post-checkout
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
# post-checkout
|
|
2
|
-
# checkout_type
|
|
1
|
+
# post-checkout receives: prev_HEAD new_HEAD checkout_type
|
|
2
|
+
# checkout_type: 1 = branch checkout, 0 = file checkout
|
|
3
3
|
CHECKOUT_TYPE=$3
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Only run on branch checkout, skip file checkout
|
|
6
6
|
[ "$CHECKOUT_TYPE" != "1" ] && exit 0
|
|
7
7
|
|
|
8
|
-
# 取得切換後的當前分支名稱
|
|
9
8
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
10
9
|
|
|
11
|
-
# 僅針對 dev、qa、master 這三個目標分支執行自動拉取
|
|
12
10
|
TARGET_BRANCHES="dev qa master"
|
|
13
11
|
match=0
|
|
14
12
|
for branch in $TARGET_BRANCHES; do
|
|
@@ -16,14 +14,12 @@ for branch in $TARGET_BRANCHES; do
|
|
|
16
14
|
done
|
|
17
15
|
|
|
18
16
|
if [ "$match" = "1" ]; then
|
|
19
|
-
# 檢查本地是否有尚未推送的 commit,有的話跳過自動拉取(避免覆蓋本地變更)
|
|
20
17
|
LOCAL_AHEAD=$(git rev-list --count origin/"$CURRENT_BRANCH"..HEAD 2>/dev/null || echo 0)
|
|
21
18
|
if [ "$LOCAL_AHEAD" -gt 0 ]; then
|
|
22
19
|
echo "You have $LOCAL_AHEAD unpushed commit(s) on '$CURRENT_BRANCH'. Skipping auto-pull."
|
|
23
20
|
exit 0
|
|
24
21
|
fi
|
|
25
22
|
|
|
26
|
-
# 自動從遠端拉取最新程式碼(使用 rebase 保持線性歷史)
|
|
27
23
|
echo "Auto pulling '$CURRENT_BRANCH' from remote..."
|
|
28
24
|
git pull --rebase origin "$CURRENT_BRANCH" || {
|
|
29
25
|
echo "Failed to pull '$CURRENT_BRANCH'. Please resolve manually."
|
package/.husky/pre-commit
CHANGED
package/.husky/pre-push
CHANGED
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
# 從 stdin 偵測是否為 force push(非 fast-forward)
|
|
2
|
-
# pre-push hook 會收到:<local_ref> <local_sha> <remote_ref> <remote_sha>
|
|
3
|
-
IS_FORCE=false
|
|
4
|
-
while read local_ref local_sha remote_ref remote_sha; do
|
|
5
|
-
# 跳過新建分支或刪除分支的情況(sha 全為 0)
|
|
6
|
-
[ "$remote_sha" = "0000000000000000000000000000000000000000" ] && continue
|
|
7
|
-
[ "$local_sha" = "0000000000000000000000000000000000000000" ] && continue
|
|
8
|
-
# 若遠端 sha 不是本地 sha 的祖先,代表是 force push
|
|
9
|
-
if ! git merge-base --is-ancestor "$remote_sha" "$local_sha" 2>/dev/null; then
|
|
10
|
-
IS_FORCE=true
|
|
11
|
-
break
|
|
12
|
-
fi
|
|
13
|
-
done
|
|
14
|
-
|
|
15
|
-
# 取得當前分支名稱
|
|
16
|
-
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
17
|
-
|
|
18
|
-
# 在 dev/qa 分支的 force push 跳過所有 pre-push hook(避免干擾強制推送)
|
|
19
|
-
if [ "$IS_FORCE" = true ] && { [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; }; then
|
|
20
|
-
echo "Force push detected on $BRANCH, skipping pre-push hooks."
|
|
21
|
-
exit 0
|
|
22
|
-
fi
|
|
23
|
-
|
|
24
|
-
# 清理不合規的 tag(本地 + 遠端)
|
|
25
1
|
sh scripts/clean-tags.sh
|
|
26
|
-
# 自動升版並發布(僅 dev/qa 分支會實際執行,$1 為遠端名稱)
|
|
27
2
|
sh scripts/auto-version.sh "$1"
|
package/CHANGELOG.md
CHANGED
|
@@ -2,21 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
### [1.1.427-
|
|
6
|
-
|
|
7
|
-
### Bug Fixes
|
|
8
|
-
|
|
9
|
-
- **withdraw:** 修正法幣提款計算錯誤時的狀態轉移 ([3a7eb16](https://github.com/jetthai/cuora-module/commit/3a7eb1644e4992ba70c7f7f2ae1452447a953d76))
|
|
10
|
-
|
|
11
|
-
### [1.1.427-hotfix](https://github.com/jetthai/cuora-module/compare/v1.1.427...v1.1.427-hotfix) (2026-04-14)
|
|
12
|
-
|
|
13
|
-
### Features
|
|
14
|
-
|
|
15
|
-
- **husky:** skip pre-push hooks on force push to dev/qa ([79e9df9](https://github.com/jetthai/cuora-module/commit/79e9df9bfd9335dca7d5aec590fa25d7580586ac))
|
|
16
|
-
|
|
17
|
-
### Bug Fixes
|
|
18
|
-
|
|
19
|
-
- **withdraw:** 修正加密貨幣提款計算錯誤時的狀態轉移 ([3acbe09](https://github.com/jetthai/cuora-module/commit/3acbe0985bf5d4a85ccd02390c5f99092829c820))
|
|
5
|
+
### [1.1.427-qa.0](https://github.com/jetthai/cuora-module/compare/v1.1.427...v1.1.427-qa.0) (2026-04-12)
|
|
20
6
|
|
|
21
7
|
### [1.1.427](https://github.com/jetthai/cuora-module/compare/v1.1.426...v1.1.427) (2026-04-07)
|
|
22
8
|
|
package/package.json
CHANGED
package/scripts/auto-version.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// dev/qa
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// Auto version bump for dev/qa branches
|
|
4
|
+
// Format: {master version}-{branch}.{number}
|
|
5
|
+
// Example: master=2.1.1, dev 5th push → 2.1.1-dev.5
|
|
6
6
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
7
|
+
// Called by auto-version.sh (pre-push hook)
|
|
8
|
+
// Outputs new version to stdout; silent exit if no change needed
|
|
9
9
|
|
|
10
10
|
import { execSync } from 'node:child_process'
|
|
11
11
|
import { readFileSync } from 'node:fs'
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// Only run on dev / qa branches
|
|
14
14
|
const branch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
|
|
15
15
|
|
|
16
16
|
if (branch !== 'dev' && branch !== 'qa') {
|
|
17
17
|
process.exit(0)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
//
|
|
20
|
+
// Get base version from origin/master, fallback to local master
|
|
21
21
|
let masterVersion
|
|
22
22
|
try {
|
|
23
23
|
masterVersion = JSON.parse(execSync('git show origin/master:package.json', { encoding: 'utf8' })).version
|
|
@@ -30,22 +30,21 @@ try {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// 讀取當前 package.json 版號,組合 prerelease 前綴
|
|
34
33
|
const currentVersion = JSON.parse(readFileSync('package.json', 'utf8')).version
|
|
35
34
|
const prefix = `${masterVersion}-${branch}.`
|
|
36
35
|
let nextNum = 0
|
|
37
36
|
|
|
38
|
-
//
|
|
39
|
-
//
|
|
37
|
+
// Derive next number from current version
|
|
38
|
+
// e.g. currentVersion="2.1.1-dev.4" → nextNum=5
|
|
40
39
|
if (currentVersion.startsWith(prefix)) {
|
|
41
40
|
const num = parseInt(currentVersion.slice(prefix.length), 10)
|
|
42
41
|
if (!isNaN(num)) nextNum = num + 1
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// → historyMax=4
|
|
44
|
+
// Scan git log for the highest number ever used with this prefix
|
|
45
|
+
// Prevents regression when merges overwrite currentVersion
|
|
46
|
+
// e.g. after merge currentVersion="2.0.9-dev.20", but history has "2.1.1-dev.4"
|
|
47
|
+
// → historyMax=4, nextNum=5 (instead of restarting from 0)
|
|
49
48
|
try {
|
|
50
49
|
const log = execSync(`git log ${branch} --pretty=%s --grep="^${masterVersion}-${branch}\\\\." -n 50`, {
|
|
51
50
|
encoding: 'utf8',
|
|
@@ -59,10 +58,9 @@ try {
|
|
|
59
58
|
|
|
60
59
|
const newVersion = `${prefix}${nextNum}`
|
|
61
60
|
|
|
62
|
-
//
|
|
61
|
+
// No change needed
|
|
63
62
|
if (currentVersion === newVersion) {
|
|
64
63
|
process.exit(0)
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
// 輸出新版號供 auto-version.sh 使用
|
|
68
66
|
console.log(newVersion)
|
package/scripts/auto-version.sh
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env sh
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Auto version bump on dev/qa branches
|
|
4
|
+
# Called from pre-push hook — receives remote name as $1
|
|
5
5
|
|
|
6
|
-
# 取得遠端名稱(未傳入則預設為 origin)
|
|
7
6
|
REMOTE=${1:-origin}
|
|
8
|
-
# 取得當前分支名稱
|
|
9
7
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
10
8
|
|
|
11
|
-
# 僅在 dev 或 qa 分支執行自動升版流程
|
|
12
9
|
if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
|
|
13
|
-
#
|
|
10
|
+
# Compute next prerelease version (scans git log to prevent regression)
|
|
14
11
|
NEXT_VERSION=$(node scripts/auto-version.js)
|
|
15
12
|
|
|
16
|
-
# 若版號無變化,跳過發布流程
|
|
17
13
|
if [ -z "$NEXT_VERSION" ]; then
|
|
18
14
|
echo "Version unchanged, skipping release."
|
|
19
15
|
exit 0
|
|
@@ -22,12 +18,12 @@ if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
|
|
|
22
18
|
echo "Branch: $BRANCH"
|
|
23
19
|
echo "Next version: $NEXT_VERSION"
|
|
24
20
|
|
|
25
|
-
#
|
|
21
|
+
# Bump version, update CHANGELOG, create commit + tag
|
|
26
22
|
npx standard-version --release-as "$NEXT_VERSION"
|
|
27
23
|
|
|
28
|
-
#
|
|
24
|
+
# Push + npm publish
|
|
29
25
|
node scripts/branch-auto-npm-publish.js "$REMOTE" "$BRANCH"
|
|
30
26
|
|
|
31
|
-
#
|
|
27
|
+
# Abort the original git push (scripts already pushed)
|
|
32
28
|
exit 1
|
|
33
29
|
fi
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
// 自動推送 commit + tag 並發布到 npm
|
|
2
|
-
// 由 auto-version.sh 呼叫,接收參數:remote(遠端名稱)、branch(分支名稱)
|
|
3
|
-
|
|
4
1
|
import { execSync } from 'node:child_process'
|
|
5
2
|
import { readFileSync } from 'node:fs'
|
|
6
3
|
|
|
7
|
-
// 取得遠端名稱與分支名稱(預設為 origin 和當前分支)
|
|
8
4
|
const remote = process.argv[2] || 'origin'
|
|
9
5
|
const branch = process.argv[3] || execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
|
|
10
6
|
|
|
11
|
-
// 讀取 package.json 中的版號(此時已被 standard-version 更新過)
|
|
12
7
|
const { version } = JSON.parse(readFileSync('package.json', 'utf8'))
|
|
13
8
|
|
|
14
9
|
console.log(`Branch: ${branch}`)
|
|
15
10
|
console.log(`Version: ${version}`)
|
|
16
11
|
|
|
17
|
-
//
|
|
12
|
+
// Pull remote changes before push (avoid rejection)
|
|
13
|
+
execSync(`git pull --rebase --no-verify ${remote} ${branch}`, { stdio: 'inherit' })
|
|
14
|
+
|
|
15
|
+
// Push commit and tags
|
|
18
16
|
execSync(`git push --no-verify --follow-tags ${remote} ${branch}`, { stdio: 'inherit' })
|
|
19
17
|
|
|
20
|
-
//
|
|
18
|
+
// Publish to npm with branch dist-tag
|
|
21
19
|
try {
|
|
22
20
|
execSync(`npm publish --tag ${branch}`, { stdio: 'inherit' })
|
|
23
21
|
console.log(`✅ npm publish succeeded: ${version} (tag: ${branch})`)
|
package/scripts/clean-tags.sh
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env sh
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Delete local and remote tags that do NOT match the compliant pattern
|
|
4
|
+
# Compliant pattern: v1.2.3 (e.g., v0.1.0, v1.12.123)
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
# 1.
|
|
8
|
-
# 2.
|
|
9
|
-
# 3.
|
|
6
|
+
# Deletion rules (any match triggers deletion):
|
|
7
|
+
# 1. Current branch is dev or qa
|
|
8
|
+
# 2. Tag's commit is not reachable from any branch
|
|
9
|
+
# 3. Tag's commit is already merged into master
|
|
10
10
|
PATTERN="^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
|
|
11
11
|
|
|
12
|
-
# 取得當前分支名稱
|
|
13
12
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
14
13
|
|
|
15
|
-
#
|
|
14
|
+
# Find the latest tag (by creation date) regardless of format
|
|
16
15
|
LATEST_TAG=$(git tag -l --sort=-creatordate | head -n 1)
|
|
17
16
|
|
|
18
|
-
#
|
|
17
|
+
# Collect non-compliant tags
|
|
19
18
|
TAGS=$(git tag -l | grep -vE "$PATTERN")
|
|
20
19
|
|
|
21
|
-
# 若沒有不合規的 tag,直接結束
|
|
22
20
|
if [ -z "$TAGS" ]; then
|
|
23
21
|
echo "No non-compliant tags found."
|
|
24
22
|
exit 0
|
|
@@ -26,9 +24,7 @@ fi
|
|
|
26
24
|
|
|
27
25
|
echo "Latest tag (preserved): $LATEST_TAG"
|
|
28
26
|
|
|
29
|
-
# 逐一檢查每個不合規的 tag
|
|
30
27
|
for TAG in $TAGS; do
|
|
31
|
-
# 最新的 tag 一律跳過,避免誤刪正在使用的版本
|
|
32
28
|
if [ "$TAG" = "$LATEST_TAG" ]; then
|
|
33
29
|
echo "Skipping tag $TAG (latest tag)"
|
|
34
30
|
continue
|
|
@@ -37,13 +33,13 @@ for TAG in $TAGS; do
|
|
|
37
33
|
SHOULD_DELETE=false
|
|
38
34
|
REASON=""
|
|
39
35
|
|
|
40
|
-
#
|
|
36
|
+
# Rule 1: Current branch is dev or qa
|
|
41
37
|
if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
|
|
42
38
|
SHOULD_DELETE=true
|
|
43
39
|
REASON="on $BRANCH branch"
|
|
44
40
|
fi
|
|
45
41
|
|
|
46
|
-
#
|
|
42
|
+
# Rule 2: Tag's commit is not reachable from any branch
|
|
47
43
|
if [ "$SHOULD_DELETE" = false ]; then
|
|
48
44
|
BRANCHES=$(git branch -a --contains "$TAG" 2>/dev/null)
|
|
49
45
|
if [ -z "$BRANCHES" ]; then
|
|
@@ -52,7 +48,7 @@ for TAG in $TAGS; do
|
|
|
52
48
|
fi
|
|
53
49
|
fi
|
|
54
50
|
|
|
55
|
-
#
|
|
51
|
+
# Rule 3: Tag's commit is already merged into master
|
|
56
52
|
if [ "$SHOULD_DELETE" = false ]; then
|
|
57
53
|
if git merge-base --is-ancestor "$TAG" master 2>/dev/null; then
|
|
58
54
|
SHOULD_DELETE=true
|
|
@@ -60,7 +56,6 @@ for TAG in $TAGS; do
|
|
|
60
56
|
fi
|
|
61
57
|
fi
|
|
62
58
|
|
|
63
|
-
# 執行刪除:先刪遠端再刪本地,遠端刪除失敗不中斷流程
|
|
64
59
|
if [ "$SHOULD_DELETE" = true ]; then
|
|
65
60
|
echo "Deleting tag $TAG ($REASON)"
|
|
66
61
|
git push origin --delete "$TAG" --no-verify 2>/dev/null || true
|