From 9ddc82b507991d7c2202aea685a0d6bcd28a0b47 Mon Sep 17 00:00:00 2001 From: clerie Date: Thu, 11 Jul 2024 13:18:45 +0200 Subject: [PATCH 1/2] pkgs/git-checkout-github-pr: Add script to checkout GitHub PRs in repos --- flake.nix | 1 + pkgs/git-checkout-github-pr/default.nix | 9 ++++ .../git-checkout-github-pr.sh | 44 +++++++++++++++++++ pkgs/overlay.nix | 1 + 4 files changed, 55 insertions(+) create mode 100644 pkgs/git-checkout-github-pr/default.nix create mode 100755 pkgs/git-checkout-github-pr/git-checkout-github-pr.sh diff --git a/flake.nix b/flake.nix index 9b9e1c4..5e0dc12 100644 --- a/flake.nix +++ b/flake.nix @@ -114,6 +114,7 @@ clerie-sops-config clerie-sops-edit chromium-incognito + git-checkout-github-pr iot-data nix-remove-result-links nixfiles-auto-install diff --git a/pkgs/git-checkout-github-pr/default.nix b/pkgs/git-checkout-github-pr/default.nix new file mode 100644 index 0000000..9be9a40 --- /dev/null +++ b/pkgs/git-checkout-github-pr/default.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: + +pkgs.writeShellApplication { + name = "git-checkout-github-pr"; + text = builtins.readFile ./git-checkout-github-pr.sh; + runtimeInputs = with pkgs; [ + git + ]; +} diff --git a/pkgs/git-checkout-github-pr/git-checkout-github-pr.sh b/pkgs/git-checkout-github-pr/git-checkout-github-pr.sh new file mode 100755 index 0000000..b182ab7 --- /dev/null +++ b/pkgs/git-checkout-github-pr/git-checkout-github-pr.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -euo pipefail + +ID="" +REMOTE="origin" +LOCAL_BRANCH="" + +while [[ $# -gt 0 ]]; do + case $1 in + --remote) + REMOTE="$2" + shift + shift + ;; + --local-branch) + LOCAL_BRANCH="$2" + shift + shift + ;; + *) + if [[ -z "${ID}" ]]; then + ID="$1" + shift + else + echo "Unknown option $1" + exit 1 + fi + ;; + esac +done + +if [[ -z "${ID}" ]]; then + echo "Specify GitHub PR number" + exit 1 +fi + +if [[ -z "${LOCAL_BRANCH}" ]]; then + LOCAL_BRANCH="pr/${ID}" +fi + +git fetch "${REMOTE}" "pull/${ID}/head:${LOCAL_BRANCH}" + +git switch "${LOCAL_BRANCH}" diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix index 97c7fdf..1ccd9c7 100644 --- a/pkgs/overlay.nix +++ b/pkgs/overlay.nix @@ -7,6 +7,7 @@ final: prev: { clerie-sops-edit = final.callPackage ./clerie-sops/clerie-sops-edit.nix {}; clerie-update-nixfiles = final.callPackage ./clerie-update-nixfiles/clerie-update-nixfiles.nix {}; chromium-incognito = final.callPackage ./chromium-incognito {}; + git-checkout-github-pr = final.callPackage ./git-checkout-github-pr {}; iot-data = final.python3.pkgs.callPackage ./iot-data {}; nix-remove-result-links = final.callPackage ./nix-remove-result-links {}; nixfiles-auto-install = final.callPackage ./nixfiles/nixfiles-auto-install.nix {}; From 5d799f933042ad8cc9acda671e1de6c0946cb896 Mon Sep 17 00:00:00 2001 From: Flake Update Bot Date: Fri, 12 Jul 2024 03:04:39 +0200 Subject: [PATCH 2/2] Update nixpkgs 2024-07-12-01-03 --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 58bceda..0b763b4 100644 --- a/flake.lock +++ b/flake.lock @@ -268,11 +268,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1719848872, - "narHash": "sha256-H3+EC5cYuq+gQW8y0lSrrDZfH71LB4DAf+TDFyvwCNA=", + "lastModified": 1720542800, + "narHash": "sha256-ZgnNHuKV6h2+fQ5LuqnUaqZey1Lqqt5dTUAiAnqH0QQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "00d80d13810dbfea8ab4ed1009b09100cca86ba8", + "rev": "feb2849fdeb70028c70d73b848214b00d324a497", "type": "github" }, "original": {