-
Notifications
You must be signed in to change notification settings - Fork 0
fix(tooling): multi-PR session title parsing and prefix recovery #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,26 +124,57 @@ trim_ws() { | |
| printf '%s' "$s" | ||
| } | ||
|
|
||
| strip_leading_emojis() { | ||
| local s="$1" | ||
| while true; do | ||
| case "$s" in | ||
| โ *) s="${s#โ }" ;; | ||
| ๐*) s="${s#๐}" ;; | ||
| โ ๏ธ*) s="${s#โ ๏ธ}" ;; | ||
| ๐*) s="${s#๐}" ;; | ||
| ๐ง*) s="${s#๐ง}" ;; | ||
| *) break ;; | ||
| esac | ||
| s="$(trim_ws "$s")" | ||
| done | ||
| printf '%s' "$s" | ||
| } | ||
|
|
||
| normalize_title_base() { | ||
| local s="$1" | ||
| s="$(trim_ws "$s")" | ||
| while [[ "$s" == *" "* ]]; do | ||
| s="${s// / }" | ||
| done | ||
| printf '%s' "$s" | ||
| } | ||
|
|
||
| title_base_from() { | ||
| local name="$1" pr="$2" base marker | ||
| for marker in "PR #${pr}:" "pr#${pr}:" "PR #${pr} " "pr#${pr} " "Peer #${pr}:" "peer #${pr}:"; do | ||
| name="$(strip_leading_emojis "$name")" | ||
| for marker in "PR #${pr}:" "pr#${pr}:" "PR #${pr} " "pr#${pr} " \ | ||
| "PR: ${pr}:" "PR: ${pr} " "PR:${pr}:" "PR:${pr} " \ | ||
| "Peer #${pr}:" "peer #${pr}:"; do | ||
| if [[ "$name" == *"$marker"* ]]; then | ||
| base="${name##*"$marker"}" | ||
| base="$(trim_ws "$base")" | ||
| [[ "$base" == [Pp]eer[[:space:]#]*#"${pr}"*:* ]] && base="${base#*:}" && base="$(trim_ws "$base")" | ||
| base="$(normalize_title_base "$(trim_ws "$base")")" | ||
| [[ "$base" == [Pp]eer[[:space:]#]*#"${pr}"*:* ]] && base="${base#*:}" && base="$(normalize_title_base "$(trim_ws "$base")")" | ||
| printf '%s' "$base" | ||
| return | ||
| fi | ||
| done | ||
| trim_ws "$name" | ||
| normalize_title_base "$(trim_ws "$name")" | ||
| } | ||
|
|
||
| title_base_multi_from() { | ||
| local name="$1" p1="$2" p2="$3" base marker | ||
| for marker in "PR #${p1}/#${p2}:" "pr#${p1}/${p2}:" "PR #${p1}/#${p2} " "pr#${p1}/${p2} "; do | ||
| name="$(strip_leading_emojis "$name")" | ||
| for marker in "PR #${p1}/#${p2}:" "pr#${p1}/${p2}:" "PR #${p1}/#${p2} " "pr#${p1}/${p2} " \ | ||
| "PR #${p1} #${p2}:" "pr#${p1} #${p2}:" \ | ||
| "PR #${p1}: #${p2}:" "pr#${p1}: #${p2}:"; do | ||
|
Comment on lines
+172
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For newly parsed space-separated titles like Useful? React with ๐ย / ๐. |
||
| if [[ "$name" == *"$marker"* ]]; then | ||
| base="${name##*"$marker"}" | ||
| trim_ws "$base" | ||
| normalize_title_base "$(trim_ws "$base")" | ||
| return | ||
| fi | ||
| done | ||
|
|
@@ -153,14 +184,20 @@ title_base_multi_from() { | |
| extract_pr_numbers() { | ||
| local name="$1" | ||
| local re_multi re_peer | ||
| re_multi='[Pp][Rr][#: ]*#?([0-9]{3,4})/([0-9]{3,4})' | ||
| re_multi='[Pp][Rr][[:space:]]*#([0-9]{3,4})/#([0-9]{3,4})' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For existing session titles using the previously supported slash form Useful? React with ๐ย / ๐. |
||
| re_peer='[Pp]eer[[:space:]#:]*#?([0-9]{3,4})' | ||
| if [[ "$name" =~ [Pp][Rr][[:space:]]*#?([0-9]{3,4}):[[:space:]]*#?([0-9]{3,4}) ]]; then | ||
| echo "${BASH_REMATCH[1]}"; echo "${BASH_REMATCH[2]}"; return | ||
| fi | ||
| if [[ "$name" =~ [Pp][Rr][[:space:]]*#?([0-9]{3,4})[[:space:]]+#?([0-9]{3,4}): ]]; then | ||
| echo "${BASH_REMATCH[1]}"; echo "${BASH_REMATCH[2]}"; return | ||
| fi | ||
| if [[ "$name" =~ $re_multi ]]; then | ||
| echo "${BASH_REMATCH[1]}"; echo "${BASH_REMATCH[2]}"; return | ||
| fi | ||
| if [[ "$name" =~ [Pp][Rr]:[[:space:]]*#?([0-9]{3,4}) ]]; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For malformed no-hash titles like Useful? React with ๐ย / ๐. |
||
| echo "${BASH_REMATCH[1]}"; return | ||
| fi | ||
| local first | ||
| first="$(printf '%s' "$name" | grep -oiE '[Pp][Rr][[:space:]]*#?[0-9]{3,4}' | head -1 | grep -oE '[0-9]{3,4}' || true)" | ||
| [[ -n "$first" ]] && { echo "$first"; return; } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For malformed titles that include the hash, such as
PR: #944: import picker, the new parser branch extracts944, but this marker list only stripsPR: 944/PR:944without the#. Since those titles are selected by the sweep via the#[0-9]filter, they get renamed toโฆPR #944: PR: #944: import pickerinstead of being repaired; include the hashedPR: #${pr}variants here.Useful? React with ๐ย / ๐.