Skip to content

Commit

Permalink
Merge pull request #14 from Frederick888/crlf into master
Browse files Browse the repository at this point in the history
* crlf:
  fix: Use CRLF
  • Loading branch information
Frederick888 committed Aug 15, 2024
2 parents c0bbb6a + a15970d commit 0dcbd0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- [`jq`](https://github.com/stedolan/jq)
- [`bat`](https://github.com/sharkdp/bat)
- Command UNIX CLI utilities such as `tr`, `grep`, `sed`, etc.

# Usage

Expand Down
10 changes: 7 additions & 3 deletions gh-ph
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,24 @@ function pager() {
esac
}

function unix2dos() {
tr -d $'\r' | sed 's/$/\r/'
}

PR_DETAILS="$(set -eo pipefail; gh pr view "$GH_PH_PULL_REQUEST_ID" --json baseRefName,body)"
PR_BASE="$(set -eo pipefail; jq -r '.baseRefName' <<<"$PR_DETAILS")"
PR_BODY="$(set -eo pipefail; jq -r '.body' <<<"$PR_DETAILS")"

inject_history "$PR_BASE" <<<"$PR_BODY" | pager
inject_history "$PR_BASE" <<<"$PR_BODY" | unix2dos | pager

if read -r -n1 -p 'Update pull request body? [y/n] '; then
printf '\n'
if [[ "$REPLY" == 'y' ]]; then
inject_history "$PR_BASE" <<<"$PR_BODY" | gh pr edit "$GH_PH_PULL_REQUEST_ID" --body-file -
inject_history "$PR_BASE" <<<"$PR_BODY" | unix2dos | gh pr edit "$GH_PH_PULL_REQUEST_ID" --body-file -
else
printf 'Aborted\n'
fi
elif is_vim; then
printf '\nVim detected\n'
inject_history "$PR_BASE" <<<"$PR_BODY" | gh pr edit "$GH_PH_PULL_REQUEST_ID" --body-file -
inject_history "$PR_BASE" <<<"$PR_BODY" | unix2dos | gh pr edit "$GH_PH_PULL_REQUEST_ID" --body-file -
fi

0 comments on commit 0dcbd0d

Please sign in to comment.