-
Notifications
You must be signed in to change notification settings - Fork 0
🐱 [just] v4.0 adds PR update recipes #44
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
c56a79b
b9d92fd
694a468
52292f0
c9ff482
85112e2
ac70467
1d15325
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 |
|---|---|---|
|
|
@@ -13,12 +13,11 @@ sync: | |
| git pull | ||
| git status --porcelain # stp | ||
|
|
||
| # PR create v3.9 | ||
| # PR create v4.0 | ||
| [group('Process')] | ||
| pr: _has_commits && pr_checks | ||
| #!/usr/bin/env bash | ||
| set -euxo pipefail # strict mode | ||
| set +x # leave tracing off... | ||
| set -euo pipefail # strict mode | ||
|
|
||
| # handle optional pre-pr hook (for things like hugo) | ||
| if [[ -e ".just/pr-hook.just" ]]; then | ||
|
|
@@ -122,6 +121,18 @@ _main_branch: | |
| exit 102 | ||
| fi | ||
|
|
||
| # error if not on a branch with a pull request | ||
| [group('sanity check')] | ||
| [no-cd] | ||
| _on_a_pull_request: _on_a_branch | ||
| #!/bin/bash | ||
| set -euo pipefail # strict mode | ||
|
|
||
| if \! gh pr view &>/dev/null; then | ||
| echo "No PR found for current branch" | ||
| exit 103 | ||
| fi | ||
|
|
||
| # print UTC date in ISO format | ||
| [group('Utility')] | ||
| [no-cd] | ||
|
|
@@ -135,7 +146,7 @@ release rel_version: | |
|
|
||
| # watch GHAs then check for Copilot suggestions | ||
| [group('Process')] | ||
| pr_checks: | ||
| pr_checks: _on_a_pull_request | ||
| #!/usr/bin/env bash | ||
|
|
||
| gh pr checks --watch -i 5 | ||
|
|
@@ -177,3 +188,132 @@ pr_checks: | |
| # did Claude comment? | ||
| echo -e "\n\n🟧🟠🔶🔸 Claude:" | ||
| gh pr view --json comments --jq '[.comments[] | select(.author.login == "claude")] | last | .body' | ||
|
|
||
| # update the Done section of PR description with current commits | ||
| [group('Process')] | ||
| pr_update: _on_a_pull_request | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail # strict mode | ||
|
|
||
| CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" | ||
|
|
||
| # get current PR body | ||
| bodyfile=$(mktemp /tmp/justfile.XXXXXX) | ||
| gh pr view --json body --jq '.body' > "$bodyfile" | ||
|
|
||
| # create new Done section | ||
| new_done_section=$(mktemp /tmp/justfile.XXXXXX) | ||
|
||
| { | ||
| echo "## Done" | ||
| echo "" | ||
| git cherry -v "{{ release_branch }}" "$CURRENT_BRANCH" | sed -e 's/^[+] [0-9a-f]* /- /' | ||
| echo "" | ||
| } > "$new_done_section" | ||
|
|
||
| # extract everything after Done section (preserve other sections) | ||
| other_sections=$(mktemp /tmp/justfile.XXXXXX) | ||
|
||
| awk '/^## Done/,/^## / {if (/^## / && !/^## Done/) {found=1}} found {print}' "$bodyfile" > "$other_sections" | ||
|
|
||
| # if no other sections found after Done, preserve everything after Done | ||
| if [ ! -s "$other_sections" ]; then | ||
| # look for content after the Done section's commit list | ||
| awk 'BEGIN {in_done=0; after_done=0; empty_count=0} | ||
| /^## Done/ {in_done=1; next} | ||
| in_done && /^$/ {empty_count++; if (empty_count >= 2) after_done=1; next} | ||
| in_done && /^- / {next} | ||
| after_done {print}' "$bodyfile" > "$other_sections" | ||
| fi | ||
|
|
||
| # combine new Done section with preserved sections | ||
| updated_body=$(mktemp /tmp/justfile.XXXXXX) | ||
|
||
| cat "$new_done_section" "$other_sections" > "$updated_body" | ||
|
|
||
| echo '' | ||
| cat "$updated_body" | ||
| echo '' | ||
|
|
||
| # update PR body | ||
| gh pr edit --body-file "$updated_body" | ||
|
|
||
| # cleanup | ||
| rm "$bodyfile" "$new_done_section" "$other_sections" "$updated_body" | ||
|
|
||
| # add or append to Verify section from stdin | ||
| [group('Process')] | ||
| pr_verify: _on_a_pull_request | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail # strict mode | ||
|
|
||
| # read stdin into a temp file | ||
| stdin_content=$(mktemp /tmp/justfile.XXXXXX) | ||
|
||
| cat > "$stdin_content" | ||
|
|
||
| # get current PR body | ||
| bodyfile=$(mktemp /tmp/justfile.XXXXXX) | ||
|
||
| gh pr view --json body --jq '.body' > "$bodyfile" | ||
|
|
||
| # get current datetime | ||
| DATETIME=$(date '+%Y-%m-%d %H:%M:%S %Z') | ||
|
|
||
| # check if Verify section exists | ||
| if grep -q '^## Verify' "$bodyfile"; then | ||
| # append to existing Verify section | ||
| updated_body=$(mktemp /tmp/justfile.XXXXXX) | ||
|
||
| awk -v datetime="$DATETIME" ' | ||
| /^## Verify/ { | ||
| in_verify=1 | ||
| next | ||
| } | ||
| /^## / && in_verify { | ||
| # found next section, insert content before it | ||
| print "" | ||
| print "### " datetime | ||
| print "" | ||
| print "```" | ||
| system("cat '"$stdin_content"'") | ||
| print "```" | ||
| print "" | ||
| in_verify=0 | ||
| } | ||
| { print } | ||
| END { | ||
| # if still in verify section at end, append content | ||
| if (in_verify) { | ||
| print "" | ||
| print "### " datetime | ||
| print "" | ||
| print "```" | ||
| system("cat '"$stdin_content"'") | ||
| print "```" | ||
| } | ||
| } | ||
| ' "$bodyfile" > "$updated_body" | ||
| else | ||
| # create new Verify section before Meta section | ||
| updated_body=$(mktemp /tmp/justfile.XXXXXX) | ||
|
||
| awk -v datetime="$DATETIME" ' | ||
| /^## Meta/ { | ||
| # insert Verify section before Meta | ||
| print "## Verify" | ||
| print "" | ||
| print "### " datetime | ||
| print "" | ||
| print "```" | ||
| system("cat '"$stdin_content"'") | ||
| print "```" | ||
| print "" | ||
| } | ||
| { print } | ||
| ' "$bodyfile" > "$updated_body" | ||
| fi | ||
|
|
||
| echo '' | ||
| cat "$updated_body" | ||
| echo '' | ||
|
|
||
| # update PR body | ||
| gh pr edit --body-file "$updated_body" | ||
|
|
||
| # cleanup | ||
| rm "$stdin_content" "$bodyfile" "$updated_body" | ||
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.
Using predictable temp file patterns in /tmp can create security vulnerabilities. Consider using
mktempwithout a template argument to create truly random temp files, or usemktemp -t justfile.XXXXXXfor safer temp file creation.