ljsadlkjdsalkj

This commit is contained in:
2025-06-07 19:08:12 +02:00
parent c1df5793ac
commit 0298eadb9e

View File

@@ -638,7 +638,7 @@ pr $number=`just _a_pr`:
# TODO: gitignore ./checkout-upstream-branch.sh
printf "git checkout --autostash %q\n" "$(git rev-parse --abbrev-ref HEAD)" > checkout-upstream-branch.sh
(set -x;
$GIT checkout -b pr-"$number"-rebased-"$remote"-"$branch" ||:
$GIT checkout -b pr-"$number"-rebased-"$remote"-"$branch-{{ epoch }}" ||:
$GIT pull --rebase "$remote" "$branch" || $GIT rebase --abort
) || echo >&2 "retcode: $?" ||:
}
@@ -650,18 +650,19 @@ pr $number=`just _a_pr`:
(set -x; gh pr checkout "$number" --force)
[[ -z "$upstream_branch" ]] || do_rebase "$upstream_branch"
fi
elif test -d prs/pr-"$number"-*; then
# TODO: remove this backward compat
cd prs/pr-"$number"-*
else
upstream_branch=$( just _a_upstream_release_branch "Rebase?" "" )
(cd master;
$GIT worktree prune
(set -x; $GIT worktree add -b just-nixpkgs-pr-"$number"-tmp ../prs/pr-"$number")
# (set -x; $GIT worktree add -b just-nixpkgs-pr-"$number"-tmp ../prs/pr-"$number")
declare pull_json
pull_json="$(gh api repos/NixOS/nixpkgs/pulls/382957)"
git fetch upstream "$(jq <<<"$pull_json" '.base.ref' -r)"
(set -x; $GIT worktree add ../prs/pr-"$number" "$(jq <<<"$pull_json" '.base.sha' -r)")
)
cd prs/pr-"$number"
(set -x; gh pr checkout "$number")
git branch -D just-nixpkgs-pr-"$number"-tmp
# git branch -D just-nixpkgs-pr-"$number"-tmp
[[ -z "$upstream_branch" ]] || do_rebase "$upstream_branch"
fi
exec just _enter_interactive_shell
@@ -716,7 +717,7 @@ remote-branch $remote_ref=`just _a_remote_branch origin | cut -d/ -f2-`:
cd "$(just _new_worktree "$@")"; exec just _enter_interactive_shell
@_a_wt_type:
gum choose feat fix init bump doc migrate
gum choose feat fix init bump doc migrate drop tmp
@_a_wt_name:
gum input --placeholder="Branch name?"
@@ -737,6 +738,7 @@ _mk_worktree $name $dir $base="upstream/master" $onto="":
#!/usr/bin/env -S bash -euo pipefail -x
[[ -n "$name" ]]
[[ -n "$dir" ]]
[[ -n "$base" ]]
remote="$(cut -d/ -f1 <<<"$base")"
branch="$(cut -d/ -f2- <<<"$base")"
cd master
@@ -749,6 +751,21 @@ _mk_worktree $name $dir $base="upstream/master" $onto="":
$GIT pull --rebase "$remote" "$branch"
[[ -z "$onto" ]] || just rebase-onto HEAD "$onto"
cherry-pick-commits-into-new-worktree *commits:
#!/usr/bin/env -S bash -euo pipefail
declare -a commits=("$@")
[[ "${#commits[@]}" -gt 0 ]] || readarray -td $'\n' commits <<<"$( cd "$invokedir"; just _some_commits )"
[[ "${#commits[@]}" -gt 0 ]]
proposed_name="$(
git -C "$invokedir" show --oneline --no-patch "${commits[0]}" |
cut -d' ' -f2- | cut -d: -f1 | rev | cut -d. -f1 | rev
)"
cd "$(
just _new_worktree "$(just _a_wt_type)" "$(gum input --placeholder="Branch name?" --value="$proposed_name")"
)"
git cherry-pick "${commits[@]}"
exec just _enter_interactive_shell
pop-commits-to-new-worktree $commits=`cd "$invokedir"; just _some_commits`:
#!/usr/bin/env -S bash -euo pipefail
test -n "$commits" || { echo >&2 "no commits were selected!"; false;}
@@ -1114,18 +1131,19 @@ format-files-touched-by-commit *commits:
# === internal helpers ===
[no-cd]
mk-packages-json $fname="packages.json" $rootdir=`cd "$invokedir"; git rev-parse --show-toplevel` $outpaths=`gum confirm "Eval outpaths?" --default=no && echo true || echo false`:
mk-packages-json $fname="packages.json" $rootdir=`cd "$invokedir"; git rev-parse --show-toplevel` $outpaths=`just _gum_bool "Eval outpaths?" --default=no` $system=`just _a_system` $allow_aliases=`just _gum_bool --default=no "Allow aliases?"`:
#!/usr/bin/env -S bash -euo pipefail
extra_args=()
if [[ -n "$outpaths" && "$outpaths" != false ]]; then
extra_args+=(--drv-path --out-path)
fi
# keeping this in ram requires 220mb extra memory
# TODO: use a tmpdir instead?
packages_json="$(
set -x
time nix-env </dev/null \
--extra-experimental-features no-url-literals \
--option system "$(just _this_system)" \
--option system "$system" \
-f "$rootdir" \
-qaP \
--json \
@@ -1133,14 +1151,14 @@ mk-packages-json $fname="packages.json" $rootdir=`cd "$invokedir"; git rev-parse
"${extra_args[@]}" \
--show-trace \
--no-allow-import-from-derivation \
--arg config '{ allowAliases = false; }' \
--arg config "{ allowAliases = $allow_aliases; }" \
| sd -F "\"$(realpath "$rootdir")/" "\""
)"
cat <<<"$packages_json" >"$fname"
_packages_json:
#!/usr/bin/env -S bash -euo pipefail
echo| { # don't swallow stdin, TODO: can i do this with exec?
{
if [[ ! -s packages.json ||
$(( "$epoch" - "$(stat -c %Y packages.json )" )) -gt $(( 60*60*24*7 ))
]]; then
@@ -1151,9 +1169,9 @@ _packages_json:
false
fi
git -C upstream/master/ pull upstream master --rebase --autostash 1>&2
just mk-packages-json "packages.json" "./upstream/master" false
just mk-packages-json "packages.json" "./upstream/master" false "$(just _this_system)" false
fi
}
} </dev/null # don't swallow stdin, TODO: can I do this with exec?
@_this_commit:
cd "$invokedir"; $GIT log -n1 --pretty='format:%H'
@@ -1330,15 +1348,21 @@ _some_prs:
cd master; $GIT fetch "$remote"
cd master; $GIT for-each-ref --sort=committerdate refs/remotes --format='%(committerdate:short) %(refname:short)' | sort -r | grep " $remote/" | gum filter --height=15 --no-sort | cut -d' ' -f2-
[no-exit-message]
_gum_bool *args:
gum confirm "$@" && echo true || echo false
[no-cd]
[no-exit-message]
_enter_interactive_shell *_:
#!/usr/bin/env -S bash -euo pipefail
# report new working dir to terminal so that tab are spawned relative
# based on ghostty:src/shell-integration/bash/ghostty.bash
if [[ -n "$GHOSTTY_RESOURCES_DIR" ]]; then
_ghostty_last_reported_cwd="$PWD"
builtin printf "\e]7;kitty-shell-cwd://%s%s\a" "$HOSTNAME" "$PWD"
if [[ -t 0 && -z "${SSH_CLIENT:-}" && -z "${SSH_TTY:-}" ]]; then
# report new working dir to terminal so that tab are spawned relative
# based on ghostty:src/shell-integration/bash/ghostty.bash
if [[ -n "$GHOSTTY_RESOURCES_DIR" ]]; then
_ghostty_last_reported_cwd="$PWD"
builtin printf "\e]7;kitty-shell-cwd://%s%s\a" "$HOSTNAME" "$PWD"
fi
fi
# TODO: -l ?
exec "$SHELL" "$@"