blueprint-shared-templates 0.6.0 → 0.6.2

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.
@@ -22,6 +22,19 @@ AUDIT_LOG="$TASK_DIR/external-ops.log"
22
22
  CONFIG="release-please-config.json"
23
23
  MANIFEST=".release-please-manifest.json"
24
24
 
25
+ # config_dirs_with <marker file> → "<path>\t<component>" per package of release-please-config.json whose directory
26
+ # (path relative to the repository root) holds that file; the component is the unit name. Prints nothing without the
27
+ # config. The facts and docs steps use it to find a single-layer package wherever it sits, so the config stays the one
28
+ # list of units and no directory name is hard-coded.
29
+ config_dirs_with() {
30
+ [[ -f "$REPO_ROOT/$CONFIG" ]] || return 0
31
+ local p c
32
+ while IFS=$'\t' read -r p c; do
33
+ [[ "$p" != "." && -f "$REPO_ROOT/$p/$1" ]] && printf '%s\t%s\n' "$p" "$c"
34
+ done < <(jq -r '.packages | to_entries[] | [.key, (.value.component // (.key | split("/") | last))] | @tsv' "$REPO_ROOT/$CONFIG")
35
+ return 0
36
+ }
37
+
25
38
  log() { printf '%s\n' "→ $*"; }
26
39
  info() { printf '%s\n' " $*"; }
27
40
  warn() { printf '%s\n' "! $*" >&2; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blueprint-shared-templates",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Templates shared by several products, published on its own",
5
5
  "license": "MIT",
6
6
  "author": "Carlos Space",
@@ -2,7 +2,10 @@
2
2
  # fact-kit check on every facts package, one after the other: the aggregate at facts/, the spec, one
3
3
  # component package per unit, every other aggregate package under facts/ (a shared package published on its
4
4
  # own, facts_roots) with the component packages it lists, and every single-layer package published on its own
5
- # (a facts/*/ with no "aggregate" key). Only the packages' own files are read, never the release-please config. A component package's fact-kit.config.json lists the unit's
5
+ # (a facts/*/ with no "aggregate" key), then every single-layer package that release-please-config.json lists outside
6
+ # facts/ (a unit directory holding a fact-kit.config.json without an "aggregate" key, such as demos/_facts), the same
7
+ # fourth case facts_components pins. Without it such a package is checked only by the workspace `check` script,
8
+ # with no --train, so its pinned rows read as since-ahead on a release branch. A component package's fact-kit.config.json lists the unit's
6
9
  # directory in implDirs, so an implementation that imports the aggregate fails with impl-imports-facts.
7
10
  # Builds the packages first, because some rules read the built indexes.
8
11
  #
@@ -27,6 +30,9 @@ pkgs=("$REPO_ROOT/facts" "$REPO_ROOT"/facts/*/)
27
30
  while IFS= read -r root; do
28
31
  [[ "$root" == "$REPO_ROOT/facts" ]] || pkgs+=("$root"/*/)
29
32
  done < <(facts_roots)
33
+ while IFS=$'\t' read -r p _; do
34
+ jq -e 'has("aggregate")' "$REPO_ROOT/$p/fact-kit.config.json" >/dev/null 2>&1 || pkgs+=("$REPO_ROOT/$p")
35
+ done < <(config_dirs_with fact-kit.config.json)
30
36
  declare -A seen=()
31
37
  for pkg in "${pkgs[@]}"; do
32
38
  pkg="${pkg%/}"
@@ -11,6 +11,9 @@
11
11
  # docs/<package>/ a shared document package published on its own (docs/<RepoName>-shared-docs): a directory
12
12
  # with its own package.json, found by the unit name, which is the name of that package
13
13
  # without its scope. Pinned like a component layer, to the version of its own unit.
14
+ # <path> a package that release-please-config.json lists at any path and whose own directory holds a
15
+ # clarify-kit.config.json (demos/_docs): found by its component, which is the unit name. Looked
16
+ # up last (never docs/ itself), so the two layers above keep their directories.
14
17
  # Anything else under docs/ is not pinned by the scripts. Only the packages' own files are read and nothing
15
18
  # outside docs/.
16
19
  #
@@ -48,7 +51,8 @@ docs_pin_product() {
48
51
 
49
52
  # docs_unit_dir <unit> → the directory under the repository root that holds the documents of a unit, printed
50
53
  # when there is one: docs/<package> whose package.json carries the unit as its name (without scope), else the
51
- # component layer docs/<unit>.
54
+ # component layer docs/<unit>, else the package that release-please-config.json lists under that component with a
55
+ # clarify-kit.config.json of its own.
52
56
  docs_unit_dir() {
53
57
  has_docs || return 1
54
58
  local f n
@@ -58,6 +62,10 @@ docs_unit_dir() {
58
62
  if [[ "${n##*/}" == "$1" ]]; then f="${f%/package.json}"; printf '%s\n' "${f#"$REPO_ROOT"/}"; return 0; fi
59
63
  done
60
64
  [[ -d "$REPO_ROOT/docs/$1" ]] && { printf '%s\n' "docs/$1"; return 0; }
65
+ local p c
66
+ while IFS=$'\t' read -r p c; do
67
+ [[ "$c" == "$1" && "$p" != docs ]] && { printf '%s\n' "$p"; return 0; }
68
+ done < <(config_dirs_with clarify-kit.config.json)
61
69
  return 1
62
70
  }
63
71
 
@@ -42,18 +42,24 @@ facts_package_dir() {
42
42
  # case is a facts/*/ whose fact-kit.config.json has no "aggregate" key and whose package.json is not private: it
43
43
  # has nothing to aggregate and is published on its own, so it is itself the component and its directory name is
44
44
  # the unit. A private facts/*/ without an "aggregate" key is a component that an aggregate lists, never a unit.
45
+ # A fourth case is found through release-please-config.json (config_dirs_with): a package whose own directory holds a
46
+ # fact-kit.config.json without an "aggregate" key, wherever it sits (demos/_facts), is a single-layer package like the
47
+ # third case, and its unit is the component the config gives it. A directory already listed above is not listed twice.
45
48
  # The unit is what a release unit is called, and the callers keep the rows of the units they were given. The built "describes" is not read here: it follows
46
49
  # the version file of the unit's directory, which is still 0.0.0 until the unit's first Release PR is merged (then
47
50
  # "describes" is {}), so a unit's first release would find no component package and its "next" rows would stay unpinned. The aggregate itself never appears.
48
51
  # Builds each package first, so a caller can read the built indexes afterwards.
49
52
  facts_components() {
50
53
  has_facts || return 0
51
- local root pkg dir out unit cfg
54
+ local root pkg dir out unit cfg p c
55
+ local -A seen=()
52
56
  while IFS= read -r root; do
57
+ seen[$root]=1
53
58
  unit=""; [[ "$root" == "$REPO_ROOT/facts" ]] || unit="${root##*/}"
54
59
  while IFS= read -r pkg; do
55
60
  dir="$(facts_package_dir "$pkg" "$root")" || { warn "${root#"$REPO_ROOT"/}/fact-kit.config.json 的 aggregate 列了 ${pkg},但 ${root#"$REPO_ROOT"/}/ 底下找不到這個套件"; continue; }
56
61
  out="$(fact_kit build --cwd "$dir" 2>&1)" || { printf '%s\n' "$out" >&2; die "建置 ${dir#"$REPO_ROOT"/} 失敗(facts 的依賴裝了嗎?先在倉庫根目錄執行 pnpm install)"; }
62
+ seen[$dir]=1
57
63
  printf '%s\t%s\n' "$dir" "${unit:-${dir##*/}}"
58
64
  done < <(jq -r '.aggregate // {} | to_entries[] | .value' "$root/fact-kit.config.json")
59
65
  done < <(facts_roots)
@@ -64,11 +70,60 @@ facts_components() {
64
70
  [[ -f "$dir/package.json" ]] || continue
65
71
  [[ "$(jq -r '.private // false' "$dir/package.json")" == "true" ]] && continue
66
72
  out="$(fact_kit build --cwd "$dir" 2>&1)" || { printf '%s\n' "$out" >&2; die "建置 ${dir#"$REPO_ROOT"/} 失敗(facts 的依賴裝了嗎?先在倉庫根目錄執行 pnpm install)"; }
73
+ seen[$dir]=1
67
74
  printf '%s\t%s\n' "$dir" "${dir##*/}"
68
75
  done
76
+ while IFS=$'\t' read -r p c; do
77
+ dir="$REPO_ROOT/$p"
78
+ [[ -z "${seen[$dir]:-}" ]] || continue
79
+ jq -e 'has("aggregate")' "$dir/fact-kit.config.json" >/dev/null 2>&1 && continue
80
+ [[ -f "$dir/package.json" ]] || continue
81
+ out="$(fact_kit build --cwd "$dir" 2>&1)" || { printf '%s\n' "$out" >&2; die "建置 ${dir#"$REPO_ROOT"/} 失敗(facts 的依賴裝了嗎?先在倉庫根目錄執行 pnpm install)"; }
82
+ seen[$dir]=1
83
+ printf '%s\t%s\n' "$dir" "$c"
84
+ done < <(config_dirs_with fact-kit.config.json)
85
+ return 0
86
+ }
87
+
88
+ # facts_package_dirs → every component package directory, one per line: a facts/*/ or a directory under another aggregate
89
+ # (facts_roots) that has a package.json and a fact-kit.config.json or a facts/ directory, or a directory
90
+ # release-please-config.json lists with a fact-kit.config.json. A directory whose fact-kit.config.json has an "aggregate" key
91
+ # is an aggregate, not a component. Unlike facts_components it lists a package whatever its directory is called, so a
92
+ # caller can find the packages that no unit name reaches.
93
+ facts_package_dirs() {
94
+ has_facts || return 0
95
+ local root p c d
96
+ local -A seen=()
97
+ while IFS= read -r d; do
98
+ [[ -n "$d" && -z "${seen[$d]:-}" ]] || continue
99
+ seen[$d]=1
100
+ [[ -f "$d/package.json" && ( -f "$d/fact-kit.config.json" || -d "$d/facts" ) ]] || continue
101
+ jq -e 'has("aggregate")' "$d/fact-kit.config.json" >/dev/null 2>&1 && continue
102
+ printf '%s\n' "$d"
103
+ done < <(
104
+ while IFS= read -r root; do
105
+ for d in "$root"/*/; do [[ -d "$d" ]] && printf '%s\n' "${d%/}"; done
106
+ done < <(facts_roots)
107
+ while IFS=$'\t' read -r p c; do printf '%s\n' "$REPO_ROOT/$p"; done < <(config_dirs_with fact-kit.config.json)
108
+ )
69
109
  return 0
70
110
  }
71
111
 
112
+ # facts_component_of <package dir> → the component each built index of the package describes, the way fact-kit check reads it
113
+ # for --train (componentOf): the one key of "describes", else the package name without its scope, "-facts" and publish target
114
+ # suffix. This does not follow the version file: on a unit's first release "describes" is {} and the package name still
115
+ # gives the unit. An index that describes several components gives nothing. Build the package first.
116
+ facts_component_of() {
117
+ local f
118
+ for f in "$1"/dist/*/index.json; do
119
+ [[ -f "$f" ]] || continue
120
+ jq -r '(.describes // {} | keys) as $k
121
+ | if ($k | length) == 1 then $k[0]
122
+ elif ($k | length) > 1 or (.package | type) != "string" then empty
123
+ else .package | sub("^@[^/]+/"; "") | sub("-facts(\\.[a-z0-9]+)?$"; "") end' "$f"
124
+ done | sort -u
125
+ }
126
+
72
127
  # facts_pin <unit> <version>: turn the "next" rows of the unit's component packages into <version>.
73
128
  # Prints nothing; the caller looks at git status.
74
129
  facts_pin() {
@@ -96,24 +151,36 @@ facts_locate_problems() {
96
151
  done < <(sed -nE 's/^[a-z-]+: ([^ :]+): .*/\1/p' <<<"$2")
97
152
  }
98
153
 
99
- # facts_train_check <unit>=<version>... → runs `fact-kit check --train` for the component packages that
100
- # describe those units. Prints the problems (each with its <file>:<line>) and returns 1 on any. A
101
- # repository without facts, or no component package for the units, passes.
154
+ # facts_train_check <unit>=<version>... → runs `fact-kit check --train` for the component packages of those units: the ones
155
+ # facts_components gives the unit, and every other package whose facts describe it (facts_component_of). The second kind was
156
+ # not pinned, because the pin only reaches the first kind, so a "next" row left in it fails the check with its <file>:<line>
157
+ # instead of shipping; the script prints which package that is. Prints the problems (each with its <file>:<line>) and returns 1
158
+ # on any. A repository without facts, or no package that describes the units, passes.
102
159
  facts_train_check() {
103
160
  has_facts || { info "⊘ 沒有 facts/,略過 fact-kit check"; return 0; }
104
161
  local pair unit dir u failed=0 out
105
- local -a train=() dirs=()
106
- local -A seen=()
162
+ local -a train=() dirs=() others=()
163
+ local -A seen=() in_train=()
107
164
  local comps; comps="$(facts_components)"
108
165
  for pair in "$@"; do
109
166
  unit="${pair%%=*}"
167
+ in_train[$unit]=1
168
+ train+=(--train "$pair")
110
169
  while IFS=$'\t' read -r dir u; do
111
170
  [[ "$u" == "$unit" ]] || continue
112
- train+=(--train "$pair")
113
171
  [[ -n "${seen[$dir]:-}" ]] || { seen[$dir]=1; dirs+=("$dir"); }
114
172
  done <<<"$comps"
115
173
  done
116
- (( ${#dirs[@]} )) || { info "⊘ 這次的單元沒有對應的 component 套件,略過 fact-kit check"; return 0; }
174
+ while IFS= read -r dir; do [[ -z "${seen[$dir]:-}" ]] && others+=("$dir"); done < <(facts_package_dirs)
175
+ for dir in "${others[@]+"${others[@]}"}"; do
176
+ out="$(fact_kit build --cwd "$dir" 2>&1)" || { printf '%s\n' "$out" >&2; die "建置 ${dir#"$REPO_ROOT"/} 失敗(facts 的依賴裝了嗎?先在倉庫根目錄執行 pnpm install)"; }
177
+ while IFS= read -r u; do
178
+ [[ -n "$u" && -n "${in_train[$u]:-}" ]] || continue
179
+ warn "${dir#"$REPO_ROOT"/} 的 facts 描述 ${u},但釘版對不到它(釘版只認目錄名稱或 release-please-config.json 給的單元名),它的 next 不會被釘,留著的 next 會讓下面的 check 失敗"
180
+ [[ -n "${seen[$dir]:-}" ]] || { seen[$dir]=1; dirs+=("$dir"); }
181
+ done < <(facts_component_of "$dir")
182
+ done
183
+ (( ${#dirs[@]} )) || { info "⊘ 沒有描述這次單元的 component 套件,略過 fact-kit check"; return 0; }
117
184
  for dir in "${dirs[@]}"; do
118
185
  if out="$(fact_kit check --cwd "$dir" "${train[@]}" 2>&1)"; then
119
186
  info "✓ fact-kit check ${dir#"$REPO_ROOT"/}(${train[*]})"
@@ -289,7 +289,8 @@ RELEASE_PIN_RESULT="" RELEASE_PIN_REASON=""
289
289
  # shellcheck disable=SC2034 # RELEASE_PIN_RESULT is read by pin-release-pr.sh and merge-release-pr.sh, which source this file
290
290
  release_pin_open_pr() {
291
291
  local branch="$1" line="$2" n head_ref pr_sha base out row pair u v comps
292
- local -a specs=() pr_units=() pinned=() docs_pinned=()
292
+ local -a specs=() pr_units=() pinned=() docs_pinned=() fact_paths=(facts) doc_paths=(docs)
293
+ local dir c d
293
294
  RELEASE_PIN_RESULT="" RELEASE_PIN_REASON=""
294
295
  n="$(release_pr_open_number "$branch")"
295
296
  if [[ -z "$n" ]]; then
@@ -336,9 +337,11 @@ release_pin_open_pr() {
336
337
  [[ -n "${comp_units[$u]:-}" ]] || continue
337
338
  facts_pin "$u" "$v"
338
339
  pinned+=("$u@$v")
340
+ # a package outside facts/ (listed in the release-please config) is committed too
341
+ while IFS=$'\t' read -r dir c; do [[ "$c" == "$u" ]] && fact_paths+=("${dir#"$REPO_ROOT"/}"); done <<<"$comps"
339
342
  done
340
- if [[ -n "$(git status --porcelain -- facts)" ]]; then
341
- git add -- facts
343
+ if [[ -n "$(git status --porcelain -- "${fact_paths[@]}")" ]]; then
344
+ git add -- "${fact_paths[@]}"
342
345
  run git commit -q -m "chore(facts): 釘 next 為 ${pinned[*]}" \
343
346
  -m "合併 Release PR #${n} 之前,把這次要發的單元的 next 釘成 PR 的版號。釘在發布分支,不放 Release PR 分支,因為 release-please 重算時會強制改寫它。"
344
347
  else
@@ -350,12 +353,13 @@ release_pin_open_pr() {
350
353
  if has_docs; then
351
354
  for pair in "${pr_units[@]}"; do
352
355
  u="${pair% *}" v="${pair#* }"
353
- docs_unit_dir "$u" >/dev/null || continue
356
+ d="$(docs_unit_dir "$u")" || continue
354
357
  docs_pin_unit "$u" "$v"
358
+ doc_paths+=("$d")
355
359
  docs_pinned+=("$u@$v")
356
360
  done
357
- if [[ -n "$(git status --porcelain -- docs)" ]]; then
358
- git add -- docs
361
+ if [[ -n "$(git status --porcelain -- "${doc_paths[@]}")" ]]; then
362
+ git add -- "${doc_paths[@]}"
359
363
  run git commit -q -m "chore(docs): 釘 next 為 ${docs_pinned[*]}" \
360
364
  -m "合併 Release PR #${n} 之前,把這次要發的單元的文件 next 釘成 PR 的版號。釘在發布分支,不放 Release PR 分支,因為 release-please 重算時會強制改寫它。"
361
365
  else
@@ -1124,8 +1124,38 @@ Release-Train-Stage: $target"
1124
1124
  # - PyPI:uv_build 只打包模組目錄,不會收進它。換成會收整個目錄的後端(例如 hatchling)時,
1125
1125
  # sdist 要排除它。
1126
1126
  # 核對方式:cargo package --list、npm pack --dry-run、解開 uv build 的產物,都不該出現 .release-marker。
1127
+ # train_bring_commit <branch> <sha>: cherry-pick <sha> from main onto the release branch that is checked out, for a unit whose
1128
+ # directory the base of the train does not have (cut-release.sh). The files the train manages stay as the branch has them
1129
+ # (RELEASE_REBUILD_PATHS and the manifest: the opening commit wrote the scoped config, the merged manifest and main's
1130
+ # tooling, and a cherry-pick must not undo that), whether the pick conflicts there or merges cleanly. Any other conflict
1131
+ # stops the script with the files listed; the branch is not pushed yet, so the person resolves it or starts over. The
1132
+ # commit keeps the author and message of <sha>, with git's "(cherry picked from commit ...)" line.
1133
+ train_bring_commit() {
1134
+ local branch="$1" c="$2" pre f out
1135
+ local -a managed=() left=()
1136
+ pre="$(git rev-parse HEAD)"
1137
+ out="$(git cherry-pick --no-commit "$c" 2>&1)" || true
1138
+ mapfile -t managed < <(git diff --name-only "$pre" -- "${RELEASE_REBUILD_PATHS[@]}" "$MANIFEST"; git diff --name-only --diff-filter=U -- "${RELEASE_REBUILD_PATHS[@]}" "$MANIFEST")
1139
+ for f in "${managed[@]+"${managed[@]}"}"; do
1140
+ [[ -n "$f" ]] || continue
1141
+ if git cat-file -e "$pre:$f" 2>/dev/null; then git checkout -q "$pre" -- "$f"; else git rm -q -f --ignore-unmatch -- "$f"; fi
1142
+ done
1143
+ mapfile -t left < <(git diff --name-only --diff-filter=U)
1144
+ if (( ${#left[@]} )); then
1145
+ printf '%s\n' "$out" >&2
1146
+ die "cherry-pick ${c:0:7} 到 ${branch} 時,這些檔衝突:${left[*]}。${branch} 還沒推送:解完衝突後 git add 並 git commit -C ${c:0:7},再推送 ${branch};或 git cherry-pick --abort、切回原本的分支、刪掉本機的 ${branch} 後重開"
1147
+ fi
1148
+ git commit -q --allow-empty --author="$(git log -1 --format='%an <%ae>' "$c")" --date="$(git log -1 --format=%aI "$c")" \
1149
+ --cleanup=whitespace -F - <<<"$(git log -1 --format=%B "$c")
1150
+
1151
+ (cherry picked from commit $c)"
1152
+ git cherry-pick --quit 2>/dev/null || true
1153
+ }
1154
+
1127
1155
  release_as_commit() { # release_as_commit <branch> <unit> <path> <version>
1128
1156
  local branch="$1" u="$2" p="$3" v="$4"
1157
+ # a unit that boarded a train rebuilt from a tag older than the unit has no directory on the branch yet
1158
+ mkdir -p "$p"
1129
1159
  {
1130
1160
  printf '%s\n' "$v"
1131
1161
  printf '%s\n' "#"
@@ -209,9 +209,15 @@ if all_independent && [[ -n "$(aggregate_unit)" ]]; then
209
209
  fi
210
210
  # A unit the line has not reached yet is deferred: it stays out of the config, so release-please does not
211
211
  # release it, and advance-release.sh brings it in when the line gets to its first stage.
212
+ # The path of each unit is resolved here, in the tree the script started in, and kept: a train rebuilt from a product tag
213
+ # switches to that tag below, and a unit that has never shipped may have no directory there yet.
212
214
  declare -a paths active=() deferred=()
215
+ declare -A path_of=()
213
216
  for u in "${units[@]}"; do
214
- if [[ -n "${stage_of[$u]}" ]]; then active+=("$u"); paths+=("$(unit_path "$u")"); else deferred+=("$u"); fi
217
+ if [[ -n "${stage_of[$u]}" ]]; then
218
+ p="$(unit_path "$u")" || die "${u} 在 $(current_branch) 上找不到目錄($CONFIG 或 apps/、packages/、libs/)"
219
+ active+=("$u"); paths+=("$p"); path_of[$u]="$p"
220
+ else deferred+=("$u"); fi
215
221
  done
216
222
  stage="$line_stage"
217
223
 
@@ -244,8 +250,16 @@ stagemap="{}"
244
250
  for u in "${deferred[@]:-}"; do
245
251
  [[ -n "$u" ]] && info "${u}:發布線還沒到它的第一個階段($(policy_unit_stages "$u" | head -1)),先不發,推進到那個階段才入版"
246
252
  done
253
+ # A unit whose directory the base does not have (a train rebuilt from a tag older than the unit) still boards: its config
254
+ # entry comes from main, and the commits of main that touch its directory are cherry-picked onto the branch after the
255
+ # opening commit (train_bring_commit), so release-please has the directory and the commits to release it from.
256
+ declare -a absent=()
247
257
  for u in "${active[@]}"; do
248
- p="$(unit_path "$u")"; ust="${stage_of[$u]}"
258
+ p="${path_of[$u]}"; ust="${stage_of[$u]}"
259
+ if ! git cat-file -e "${base}^{commit}:$p" 2>/dev/null; then
260
+ absent+=("$u")
261
+ info "${u}:起點 ${base} 沒有 ${p},照 main 的設定入版,開線後把 main 上改到 ${p} 的 commit cherry-pick 進 ${branch}"
262
+ fi
249
263
  stagemap="$(jq -c --arg p "$p" --arg s "$ust" '. + {($p): $s}' <<<"$stagemap")"
250
264
  initial="$(stage_initial_version "$(unit_base_version "$p" "$line")" "$ust")"
251
265
  case "$(policy_unit_kind "$u")" in
@@ -320,6 +334,26 @@ Release-Plan: $plan
320
334
  Release-Train-Units: ${units[*]}
321
335
  Release-Train-Stage: $stage"
322
336
 
337
+ # Bring the directories the base does not have: every commit of main since the base that touches one of those units,
338
+ # oldest first, each once. A commit also brings what else it changed (its facts, the lock file); the files the train
339
+ # manages stay as the opening commit wrote them.
340
+ declare -a picks=() picked=()
341
+ for u in "${absent[@]+"${absent[@]}"}"; do
342
+ p="${path_of[$u]}"
343
+ mapfile -t picks < <(git log --reverse --format=%H "${base}..origin/main" -- "$p")
344
+ if (( ${#picks[@]} == 0 )); then
345
+ warn "${u}:main 上找不到 ${base} 之後改到 ${p} 的 commit。${branch} 帶入這個目錄之前,release-please 不會發它"
346
+ continue
347
+ fi
348
+ for c in "${picks[@]}"; do
349
+ in_array "$c" "${picked[@]+"${picked[@]}"}" && continue
350
+ picked+=("$c")
351
+ if (( DRY_RUN )); then info "[dry-run] ${u}:會 cherry-pick $(git log -1 --format='%h %s' "$c")"; continue; fi
352
+ train_bring_commit "$branch" "$c"
353
+ info "${u}:已 cherry-pick $(git log -1 --format='%h %s' "$c")"
354
+ done
355
+ done
356
+
323
357
  # release-please's python and rust strategies start a unit that has no release at 0.1.0 and never read
324
358
  # initial-version, so the first version of those units is pinned by Release-As commits on top of the opening commit.
325
359
  if (( DRY_RUN )); then