Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .git-ps/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[pull]
show_list_post_pull = true

[request_review]
verify_isolation = true

[integrate]
verify_isolation = true
prompt_for_reassurance = true
pull_after_integrate = false

[fetch]
show_upstream_patches_after_fetch = true

[branch]
verify_isolation = true
push_to_remote = false

[list]
add_extra_patch_info = true
extra_patch_info_length = 10
reverse_order = false
alternate_patch_series_colors = true
# patch_background.color # default No Color so have commented out
patch_background.alternate_color.RGB = [58, 58, 58]
patch_foreground.color.RGB = [248, 153, 95]
#patch_foreground.alternate_color # default No Color so have commented out
patch_index.color.RGB = [237, 199, 99]
# patch_index.alternate_color # default No Color so have commented out
patch_sha.color.RGB = [157, 208, 108]
# patch_sha.alternate_color # default No Color so have commented out
# patch_summary.color # default No Color so have commented out
# patch_summary.alternate_color # default No Color so have commented out
patch_extra_info.color.RGB = [109, 202, 231]
# patch_extra_info.alternate_color # default No Color so have commented out
5 changes: 5 additions & 0 deletions .git-ps/hooks/integrate_post_push
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

set -eum

echo "$(basename $0) called"
17 changes: 17 additions & 0 deletions .git-ps/hooks/integrate_verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env sh

set -eum

echo "$(date --utc +%FT%T.%3NZ) starting"

: "${SOURCE_BRANCH:=${1:-}}"
: "${TARGET_BRANCH:=${2:-}}"
: "${REMOTE_NAME:=${3:-$(git remote)}}"
: "${REMOTE_URL:=${4:-$(git remote get-url "${REMOTE_NAME}")}}"

: "${SOURCE_BRANCH:?must be set direcly or via \$1}"
: "${TARGET_BRANCH:?must be set direcly or via \$2}"
: "${REMOTE_NAME:?must be set direcly or via \$3}"
: "${REMOTE_URL:?must be set direcly or via \$4}"

gh pr --repo "${REMOTE_URL}" checks "${SOURCE_BRANCH}"
5 changes: 5 additions & 0 deletions .git-ps/hooks/isolate_post_checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

set -eum

editorconfig-checker
5 changes: 5 additions & 0 deletions .git-ps/hooks/isolate_post_cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

set -eum

echo "$(basename $0) called"
38 changes: 38 additions & 0 deletions .git-ps/hooks/list_additional_information
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env sh

set -eum

exec 2>>.git-ps/logs/list_additional_information.log

echo >&2 "$(date --utc +%FT%T.%3NZ) $(basename "$0") $*"

: "${PATCH_INDEX:=${1:-}}"
: "${PATCH_STATUS:=${2:-}}"
: "${PATCH_COMMIT:=${3:-}}"
: "${PATCH_TITLE:=${4:-}}"

: "${PATCH_INDEX:?must be set direcly or via \$1}"
: "${PATCH_STATUS:?must be set direcly or via \$2}"
: "${PATCH_COMMIT:?must be set direcly or via \$3}"
: "${PATCH_TITLE:?must be set direcly or via \$4}"

echo >&2 "$(date --utc +%FT%T.%3NZ) pwd: ${PWD}"
echo >&2 "$(date --utc +%FT%T.%3NZ) index: ${PATCH_INDEX}"
echo >&2 "$(date --utc +%FT%T.%3NZ) status: ${PATCH_STATUS}"
echo >&2 "$(date --utc +%FT%T.%3NZ) commit: ${PATCH_COMMIT}"
echo >&2 "$(date --utc +%FT%T.%3NZ) title: ${PATCH_TITLE}"

SLUG=$(echo "${PATCH_TITLE}" | tr ' ' '_' | tr ':' '_')

echo >&2 "$(date --utc +%FT%T.%3NZ) slug: ${SLUG}"

# TODO add head:<branch_name> to search

# shellcheck disable=SC2016
gh pr list \
--search "head:ps/rr/${SLUG}" \
--limit 1 \
--json state,comments,reviews \
--template \
'{{range .}}{{printf "%.1s" .state}} {{len .comments}} {{range .reviews}}{{if eq .state "APPROVED"}}${{end}}{{end}}{{end}}' \
;
37 changes: 37 additions & 0 deletions .git-ps/hooks/request_review_post_sync
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env sh

set -eum

echo "$(date --utc +%FT%T.%3NZ) starting"

: "${SOURCE_BRANCH:=${1:-}}"
: "${TARGET_BRANCH:=${2:-}}"
: "${REMOTE_NAME:=${3:-$(git remote)}}"
: "${REMOTE_URL:=${4:-$(git remote get-url "${REMOTE_NAME}")}}"

: "${SOURCE_BRANCH:?must be set direcly or via \$1}"
: "${TARGET_BRANCH:?must be set direcly or via \$2}"
: "${REMOTE_NAME:?must be set direcly or via \$3}"
: "${REMOTE_URL:?must be set direcly or via \$4}"

: "${TITLE:=$(git log "${SOURCE_BRANCH}^..${SOURCE_BRANCH}" --pretty=format:%s)}"
: "${DESCRIPTION:=$(git log "${SOURCE_BRANCH}^..${SOURCE_BRANCH}" --pretty=format:%b)}"

if CLOSED=$(gh pr view \
--repo "${REMOTE_URL}" \
--json closed \
--jq '.closed' \
"${SOURCE_BRANCH}" \
2>/dev/null) && [ "${CLOSED}" != "true" ]; then
echo "An open PR was found for the branch, so exiting to prevent duplicate PR creation."
exit 0
fi

gh pr create \
--draft \
--title "${TITLE}" \
--body "${DESCRIPTION}" \
--base "${TARGET_BRANCH}" \
--head "${SOURCE_BRANCH}" \
--repo "${REMOTE_URL}" \
;
Empty file added .git-ps/logs/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git-ps/logs/*.log
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
in mkShell {
packages = [
pkgs.editorconfig-checker
pkgs.git-ps-rs
pkgs.unstable.git-ps-rs
] ++ lib.optionals (builtins.getEnv "CI" != "") [ # CI-only
] ++ lib.optionals (builtins.getEnv "CI" == "") [ # local-only
];
Expand Down