mirror of
https://codeberg.org/muon/home.git
synced 2026-03-08 03:25:16 +00:00
Remove program
This commit is contained in:
parent
e4f6a5b267
commit
39b3b25396
1 changed files with 2 additions and 40 deletions
|
|
@ -3,48 +3,10 @@
|
|||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
gh-pr-review = pkgs.writeShellScriptBin "gh-pr-review" ''
|
||||
PR_NUMBER=$1
|
||||
if [ -z "$PR_NUMBER" ]; then
|
||||
echo "Usage: gh-pr-review <pr-number>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ORIGINAL_BRANCH=$(git branch --show-current)
|
||||
HAS_CHANGES=$(git status --porcelain)
|
||||
STASH_NAME="gh-pr-review-auto-stash-$(date +%s)"
|
||||
|
||||
if [ -n "$HAS_CHANGES" ]; then
|
||||
echo "Stashing local changes..."
|
||||
git stash push -m "$STASH_NAME"
|
||||
fi
|
||||
|
||||
echo "Checking out PR #$PR_NUMBER..."
|
||||
if gh pr checkout "$PR_NUMBER"; then
|
||||
nvim -c "Octo review"
|
||||
else
|
||||
echo "Failed to checkout PR #$PR_NUMBER"
|
||||
fi
|
||||
|
||||
echo "Restoring original branch: $ORIGINAL_BRANCH"
|
||||
git checkout "$ORIGINAL_BRANCH"
|
||||
|
||||
if [ -n "$HAS_CHANGES" ]; then
|
||||
# Find the stash index by message to be safe
|
||||
STASH_INDEX=$(git stash list | grep "$STASH_NAME" | cut -d: -f1 | head -n1)
|
||||
if [ -n "$STASH_INDEX" ]; then
|
||||
echo "Restoring stashed changes..."
|
||||
git stash pop "$STASH_INDEX"
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
in {
|
||||
}: {
|
||||
options.mods.terminal.gh.enable = lib.mkEnableOption "enables gh and gh-dash";
|
||||
|
||||
config = lib.mkIf config.mods.terminal.gh.enable {
|
||||
home.packages = [gh-pr-review];
|
||||
|
||||
programs.gh = {
|
||||
enable = true;
|
||||
extensions = [pkgs.gh-dash];
|
||||
|
|
@ -57,7 +19,7 @@ in {
|
|||
prs = [
|
||||
{
|
||||
key = "d";
|
||||
command = "gh-pr-review {{.PrNumber}}";
|
||||
command = "nvim -c 'Octo review {{.PrNumber}}'";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue