Merge pull request 'tea-create-pr + merge-after-ci: init' (#49) from DavHau-devshell into main
All checks were successful
build / test (push) Successful in 10s

This commit is contained in:
clan-bot 2023-07-28 13:13:13 +00:00
commit c39ee991fc
7 changed files with 111 additions and 0 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

View File

@ -0,0 +1,15 @@
{
perSystem =
{ pkgs
, self'
, ...
}: {
devShells.default = pkgs.mkShell {
packages = [
pkgs.tea
self'.packages.tea-create-pr
self'.packages.merge-after-ci
];
};
};
}

View File

@ -0,0 +1,28 @@
{
perSystem =
{ config
, pkgs
, self'
, ...
}:
let
name = builtins.baseNameOf ./.;
script = config.writers.writePureShellScriptBin
name
[
pkgs.bash
pkgs.coreutils
pkgs.git
pkgs.tea
pkgs.openssh
self'.packages.tea-create-pr
]
''
export EDITOR=${pkgs.vim}/bin/vim
bash ${./script.sh} "$@"
'';
in
{
packages.${name} = script;
};
}

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
remoteName="${1:-origin}"
targetBranch="${2:-main}"
shift && shift
tea-create-pr "$remoteName" "$targetBranch" --assignees clan-bot "$@"

View File

@ -0,0 +1,26 @@
{
perSystem =
{ config
, pkgs
, ...
}:
let
name = builtins.baseNameOf ./.;
script = config.writers.writePureShellScriptBin
name
[
pkgs.bash
pkgs.coreutils
pkgs.git
pkgs.tea
pkgs.openssh
]
''
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
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 "$remoteName" HEAD:refs/heads/"$tempRemoteBranch"
tea pr create \
--title "$firstLine" \
--description "$rest" \
--head "$tempRemoteBranch" \
--base "$targetBranch" \
"$@"

View File

@ -18,9 +18,12 @@
"aarch64-linux"
];
imports = [
./flake-parts/devShells
./flake-parts/formatting.nix
./flake-parts/merge-after-ci
./flake-parts/modules.nix
./flake-parts/packages.nix
./flake-parts/tea-create-pr
./flake-parts/writers
./templates/flake-module.nix
./templates/python-project/flake-module.nix