From a08ba48396f1e40de20a5d966e26d6bfc97a3f53 Mon Sep 17 00:00:00 2001 From: joelazar Date: Mon, 20 Jul 2026 14:33:06 +0200 Subject: [PATCH] :recycle: append linear links before description edit - Extract append_linear_links() function for appending logic - Move appending to before editing so links are included in customized description - Add linear_appended flag to track if links were already appended --- private_dot_local/bin/executable_pr-create | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/private_dot_local/bin/executable_pr-create b/private_dot_local/bin/executable_pr-create index 07f1cdb1..9d9bd7f6 100644 --- a/private_dot_local/bin/executable_pr-create +++ b/private_dot_local/bin/executable_pr-create @@ -311,12 +311,14 @@ if [[ ${#linear_links[@]} -eq 0 && $assume_yes -eq 0 ]]; then done fi -if [[ -n "$body_file" && ${#linear_links[@]} -gt 0 ]]; then +linear_appended=0 +append_linear_links() { { printf '\n\n' printf '%s\n' "${linear_links[@]}" - } >>"$body_file" -fi + } >>"$1" + linear_appended=1 +} edit_norm=$(normalize_yn "$edit_desc") [[ -z "$edit_norm" ]] && edit_norm=$(prompt_menu "Open PR description in \$EDITOR before creating PR?" "No" "Yes") @@ -325,9 +327,17 @@ if [[ "$edit_norm" == "Yes" ]]; then body_file=$(new_md_tempfile) temp_files+=("$body_file") fi + # Append Linear links before editing so they are part of the description the + # user customizes (and are not lost when a fresh body file is edited). + [[ ${#linear_links[@]} -gt 0 ]] && append_linear_links "$body_file" edit_pr_description "$body_file" fi +# Append Linear links if we have a body file and haven't done so already. +if [[ $linear_appended -eq 0 && -n "$body_file" && ${#linear_links[@]} -gt 0 ]]; then + append_linear_links "$body_file" +fi + args=(pr create --assignee @me --title "$title" --fill) [[ -n "$body_file" ]] && args+=(--body-file "$body_file") -- 2.51.2