move flake-parts into pkgs or toplevel

This commit is contained in:
lassulus
2023-08-03 17:01:26 +02:00
parent 5ac5e32214
commit b8fd28af2f
11 changed files with 10 additions and 152 deletions

View File

@@ -0,0 +1,26 @@
{
perSystem =
{ pkgs
, ...
}:
let
name = builtins.baseNameOf ./.;
script = pkgs.writeShellApplication {
inherit name;
runtimeInputs = [
pkgs.bash
pkgs.coreutils
pkgs.git
pkgs.tea
pkgs.openssh
];
text = ''
export EDITOR=${pkgs.vim}/bin/vim
bash ${./script.sh} "$@"
'';
};
in
{
packages.${name} = script;
};
}

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
remoteName="${1:-origin}"
targetBranch="${2:-main}"
shift && shift
TMPDIR="$(mktemp -d)"
currentBranch="$(git rev-parse --abbrev-ref HEAD)"
user="$(tea login list -o simple | cut -d" " -f4)"
tempRemoteBranch="$user-$currentBranch"
git log --reverse --pretty="format:%s%n%n%b%n%n" "$remoteName/$targetBranch..HEAD" > "$TMPDIR"/commit-msg
$EDITOR "$TMPDIR"/commit-msg
COMMIT_MSG=$(cat "$TMPDIR"/commit-msg)
firstLine=$(echo "$COMMIT_MSG" | head -n1)
rest=$(echo "$COMMIT_MSG" | tail -n+2)
if [[ "$firstLine" == "$rest" ]]; then
rest=""
fi
git push --force -u "$remoteName" HEAD:refs/heads/"$tempRemoteBranch"
tea pr create \
--title "$firstLine" \
--description "$rest" \
--head "$tempRemoteBranch" \
--base "$targetBranch" \
"$@"