Compare commits
No commits in common. "35e75ec9ad234b0593b3791ddb2d5650fa676590" and "61a22b96cd8b91864187d921724122f7d39b60cc" have entirely different histories.
35e75ec9ad
...
61a22b96cd
|
@ -223,11 +223,7 @@
|
||||||
"specialArgs"
|
"specialArgs"
|
||||||
]));
|
]));
|
||||||
in {
|
in {
|
||||||
dosei = nixSys "dosei" {
|
dosei = nixSys "dosei" { };
|
||||||
modules = [{
|
|
||||||
home-manager.users.h7x4.home.uid = 1001;
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
kasei = nixSys "kasei" { };
|
kasei = nixSys "kasei" { };
|
||||||
europa = nixSys "europa" { };
|
europa = nixSys "europa" { };
|
||||||
tsuki = nixSys "tsuki" {
|
tsuki = nixSys "tsuki" {
|
||||||
|
|
|
@ -33,7 +33,6 @@ in {
|
||||||
|
|
||||||
./modules/colors.nix
|
./modules/colors.nix
|
||||||
./modules/shellAliases.nix
|
./modules/shellAliases.nix
|
||||||
./modules/uidGid.nix
|
|
||||||
] ++ optionals graphics [
|
] ++ optionals graphics [
|
||||||
./config/gtk.nix
|
./config/gtk.nix
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{ lib, ... }:
|
|
||||||
{
|
|
||||||
options.home = {
|
|
||||||
uid = lib.mkOption {
|
|
||||||
default = 1000;
|
|
||||||
type = lib.types.ints.between 0 60000;
|
|
||||||
};
|
|
||||||
gid = lib.mkOption {
|
|
||||||
default = 1000;
|
|
||||||
type = lib.types.ints.between 0 60000;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,7 +1,9 @@
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.programs.atuin;
|
cfg = config.programs.atuin;
|
||||||
xdg_runtime_dir = "/run/user/${toString config.home.uid}";
|
|
||||||
|
# TODO: retrieve this in a more dynamic and correct manner
|
||||||
|
xdg_runtime_dir = "/run/user/1000";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
programs.atuin = {
|
programs.atuin = {
|
||||||
|
|
|
@ -48,70 +48,15 @@ in
|
||||||
aliases = {
|
aliases = {
|
||||||
aliases = "!git config --get-regexp alias | sed -re 's/alias\\.(\\S*)\\s(.*)$/\\1 = \\2/g'";
|
aliases = "!git config --get-regexp alias | sed -re 's/alias\\.(\\S*)\\s(.*)$/\\1 = \\2/g'";
|
||||||
delete-merged = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d";
|
delete-merged = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d";
|
||||||
|
graph = "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all";
|
||||||
|
graphv = "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all";
|
||||||
forcepush = "push --force-with-lease --force-if-includes";
|
forcepush = "push --force-with-lease --force-if-includes";
|
||||||
authors = "shortlog --summary --numbered --email";
|
authors = "shortlog --summary --numbered --email";
|
||||||
si = "switch-interactive";
|
si = "switch-interactive";
|
||||||
ff = "fixup-fixup";
|
|
||||||
rf = "rebase-fixups";
|
|
||||||
pp = "post-pr";
|
|
||||||
subs = "submodule update --init --recursive";
|
subs = "submodule update --init --recursive";
|
||||||
rebase-author = "rebase -i -x \"git commit --amend --reset-author -CHEAD\"";
|
rebase-author = "rebase -i -x \"git commit --amend --reset-author -CHEAD\"";
|
||||||
git = "!git";
|
git = "!git";
|
||||||
} // (let
|
};
|
||||||
c = c: s: "%C(${c})${s}%C(reset)";
|
|
||||||
in {
|
|
||||||
graph = let
|
|
||||||
fmt = lib.concatStringsSep "" [
|
|
||||||
" - "
|
|
||||||
(c "bold blue" "%h")
|
|
||||||
" - "
|
|
||||||
(c "bold green" "(%ar)")
|
|
||||||
" "
|
|
||||||
(c "white" "> %s")
|
|
||||||
" "
|
|
||||||
(c "dim white" "- %an")
|
|
||||||
(c "bold yellow" "%d")
|
|
||||||
];
|
|
||||||
in "log --graph --abbrev-commit --decorate --format=format:'${fmt}' --all";
|
|
||||||
|
|
||||||
graphv = let
|
|
||||||
fmt = lib.concatStringsSep "" [
|
|
||||||
(c "bold blue" "%h")
|
|
||||||
" - "
|
|
||||||
(c "bold cyan" "%aD")
|
|
||||||
" "
|
|
||||||
(c "bold green" "(%ar)")
|
|
||||||
(c "bold yellow" "%d")
|
|
||||||
"%n"
|
|
||||||
" "
|
|
||||||
(c "white" "%s")
|
|
||||||
" "
|
|
||||||
(c "dim white" "- %an")
|
|
||||||
];
|
|
||||||
in "log --graph --abbrev-commit --decorate --format=format:'${fmt}' --all";
|
|
||||||
|
|
||||||
l = let
|
|
||||||
fmt = lib.concatStringsSep "%n" (map (x: if builtins.isList x then lib.concatStringsSep " " x else x) [
|
|
||||||
[ (c "bold yellow" "%H") (c "auto" "%d") ]
|
|
||||||
[ (c "bold white" "Author:") (c "bold cyan" "%aN <%aE>") (c "bold green" "(%ah)") ]
|
|
||||||
[ (c "bold white" "Committer:") (c "bold cyan" "%cN <%cE>") (c "bold green" "(%ah)") ]
|
|
||||||
[ (c "bold white" "GPG: (%G?)") (c "bold magenta" "%GF") "-" (c "bold cyan" "%GS") (c "bold blue" "(%GT) ") ]
|
|
||||||
""
|
|
||||||
(c "bold white" "# %s")
|
|
||||||
"%+b"
|
|
||||||
(c "dim yellow" "%+N")
|
|
||||||
]);
|
|
||||||
# sedExpressions = let
|
|
||||||
# colorExpr = "\\x1B\\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]";
|
|
||||||
# colorEndExpr = "\\x1B\\[m";
|
|
||||||
# colored = x: "${colorExpr}${x}${colorEndExpr}";
|
|
||||||
# in lib.concatMapStringsSep " " (x: "-e '${x}'") [
|
|
||||||
# "s|${colored "GPG: \\(N\\)"} ${colored "F3CDA86CC55A9F10D7A069819F2F7D8250F35146"} - ${colored "h7x4 <h7x4@nani.wtf>"} ${colored "\\(ultimate\\)"}|GPG: h7x4|"
|
|
||||||
# "s|${colored "GPG: \\(N\\)"} ${colored ""} - ${colored ""} ${colored "\\(undefined\\)"}||"
|
|
||||||
# ];
|
|
||||||
in "log --decorate --format=tformat:'${fmt}'";
|
|
||||||
# in "!git log --color=always --format=format:'${fmt}' | sed -E ${sedExpressions} | $PAGER";
|
|
||||||
});
|
|
||||||
|
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
core = {
|
core = {
|
||||||
|
@ -325,16 +270,6 @@ in
|
||||||
(builtins.replaceStrings ["hours" "tcommit"] ["minutes" "tmcommit"])
|
(builtins.replaceStrings ["hours" "tcommit"] ["minutes" "tmcommit"])
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "git-fixup-fixup";
|
|
||||||
runtimeInputs = with pkgs; [ cfg.package ];
|
|
||||||
text = lib.fileContents ./scripts/git-fixup-fixup.sh;
|
|
||||||
})
|
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "git-rebase-fixups";
|
|
||||||
runtimeInputs = with pkgs; [ cfg.package gnused ];
|
|
||||||
text = lib.fileContents ./scripts/git-rebase-fixups.sh;
|
|
||||||
})
|
|
||||||
(pkgs.writeShellApplication {
|
(pkgs.writeShellApplication {
|
||||||
name = "git-switch-interactive";
|
name = "git-switch-interactive";
|
||||||
runtimeInputs = with pkgs; [ cfg.package fzf gnused coreutils ];
|
runtimeInputs = with pkgs; [ cfg.package fzf gnused coreutils ];
|
||||||
|
@ -343,21 +278,6 @@ in
|
||||||
"SC2001" # (style): See if you can use ${variable//search/replace} instead. (sed invocation)
|
"SC2001" # (style): See if you can use ${variable//search/replace} instead. (sed invocation)
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
((pkgs.writers.writePython3Bin "git-post-pr" {
|
|
||||||
libraries = with pkgs.python3Packages; [
|
|
||||||
tkinter
|
|
||||||
];
|
|
||||||
flakeIgnore = [
|
|
||||||
"E501" # I like long lines grr
|
|
||||||
];
|
|
||||||
} (lib.fileContents ./scripts/git-post-pr.py)).overrideAttrs (_: {
|
|
||||||
postFixup = ''
|
|
||||||
wrapProgram $out/bin/git-post-pr \
|
|
||||||
--prefix PATH : ${lib.makeBinPath [
|
|
||||||
pkgs.github-cli
|
|
||||||
]}
|
|
||||||
'';
|
|
||||||
}))
|
|
||||||
|
|
||||||
pkgs.git-absorb
|
pkgs.git-absorb
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
if [ -n "${1:-}" ]; then
|
|
||||||
TARGET_COMMIT="$1"
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
TARGET_COMMIT="HEAD"
|
|
||||||
fi
|
|
||||||
|
|
||||||
COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s' "$TARGET_COMMIT")
|
|
||||||
|
|
||||||
if [[ $COMMIT_MESSAGE =~ ^fixup!* ]]; then
|
|
||||||
git commit -m "$COMMIT_MESSAGE" "$@"
|
|
||||||
else
|
|
||||||
git commit --fixup "$TARGET_COMMIT" "$@"
|
|
||||||
fi
|
|
|
@ -1,130 +0,0 @@
|
||||||
import argparse
|
|
||||||
import json
|
|
||||||
import subprocess
|
|
||||||
import tkinter
|
|
||||||
|
|
||||||
# TODO: add support for gitea, and maybe other git hosting options.
|
|
||||||
|
|
||||||
|
|
||||||
def parse_args() -> argparse.Namespace:
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
prog="post-pr",
|
|
||||||
description="Post links to PRs",
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument("-n", "--no-clipboard", action="store_true", help="do not copy the message to the clipboard")
|
|
||||||
|
|
||||||
pr_id = parser.add_mutually_exclusive_group()
|
|
||||||
pr_id.add_argument("-c", "--current-branch", action="store_true", help="generate post for the PR for the current branch")
|
|
||||||
pr_id.add_argument("-l", "--latest", action="store_true", help="generate post for the latest PR for the current user")
|
|
||||||
pr_id.add_argument("pr_id", nargs="?", default=None, help="generate post for the PR with the given ID")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
if not any([args.current_branch, args.latest, args.pr_id,]):
|
|
||||||
args.current_branch = True
|
|
||||||
|
|
||||||
return args
|
|
||||||
|
|
||||||
|
|
||||||
def _gh(args: list[str]) -> str:
|
|
||||||
try:
|
|
||||||
return subprocess.check_output(["gh"] + args).decode("utf8")
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
raise RuntimeError(f"GitHub CLI command failed: 'gh {' '.join(args)}'") from e
|
|
||||||
|
|
||||||
|
|
||||||
def _gh_retcode(args: list[str]) -> int:
|
|
||||||
return subprocess.run(["gh"] + args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_gh_installed():
|
|
||||||
try:
|
|
||||||
if _gh_retcode(["--version"]) != 0:
|
|
||||||
raise RuntimeError("GitHub CLI (gh) is not installed, please install it")
|
|
||||||
except FileNotFoundError:
|
|
||||||
raise RuntimeError("GitHub CLI (gh) is not installed, please install it")
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_gh_authenticated():
|
|
||||||
if _gh_retcode(["auth", "status"]) != 0:
|
|
||||||
raise RuntimeError("Failed to authenticate with GitHub, please run 'gh auth login'")
|
|
||||||
|
|
||||||
|
|
||||||
GH_PR_JSON_FIELDS = ",".join([
|
|
||||||
"additions",
|
|
||||||
"deletions",
|
|
||||||
"state",
|
|
||||||
"title",
|
|
||||||
"url",
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_pr_data(current_branch: bool, latest: bool, pr_id: str | None) -> dict[str, any]:
|
|
||||||
if pr_id:
|
|
||||||
pr_data = _gh(["pr", "view", pr_id, "--json", GH_PR_JSON_FIELDS])
|
|
||||||
pr_data = json.loads(pr_data)
|
|
||||||
|
|
||||||
elif latest:
|
|
||||||
pr_list = _gh(["pr", "list", "--author", "@me", "--limit", "1", "--json", GH_PR_JSON_FIELDS])
|
|
||||||
pr_list = json.loads(pr_list)
|
|
||||||
|
|
||||||
if len(pr_list) == 0:
|
|
||||||
raise RuntimeError("Failed to find PR, are you sure you have any open PRs?")
|
|
||||||
|
|
||||||
pr_data = pr_list[0]
|
|
||||||
|
|
||||||
elif current_branch:
|
|
||||||
pr_data = _gh(["pr", "view", "--json", GH_PR_JSON_FIELDS])
|
|
||||||
pr_data = json.loads(pr_data)
|
|
||||||
|
|
||||||
return pr_data
|
|
||||||
|
|
||||||
|
|
||||||
def format_message(pr_data: dict[str, any]) -> str:
|
|
||||||
additions = pr_data["additions"]
|
|
||||||
deletions = pr_data["deletions"]
|
|
||||||
|
|
||||||
title = pr_data["title"]
|
|
||||||
pr_url = pr_data["url"]
|
|
||||||
pr_state = pr_data["state"]
|
|
||||||
|
|
||||||
state_html = f"({pr_state.lower()}) " if pr_state != "OPEN" else ""
|
|
||||||
additions_html = f"+{additions}" if additions > 0 else str(additions)
|
|
||||||
deletions_html = f"-{deletions}" if deletions > 0 else str(deletions)
|
|
||||||
|
|
||||||
return f"""{state_html}{pr_url} {title} [diff: {additions_html}/{deletions_html}]"""
|
|
||||||
|
|
||||||
|
|
||||||
def copy_to_clipboard(message: str):
|
|
||||||
r = tkinter.Tk()
|
|
||||||
r.withdraw()
|
|
||||||
r.clipboard_clear()
|
|
||||||
r.clipboard_append(message)
|
|
||||||
r.update()
|
|
||||||
r.destroy()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
args = parse_args()
|
|
||||||
|
|
||||||
ensure_gh_installed()
|
|
||||||
ensure_gh_authenticated()
|
|
||||||
|
|
||||||
pr_data = fetch_pr_data(args.current_branch, args.latest, args.pr_id)
|
|
||||||
message = format_message(pr_data)
|
|
||||||
|
|
||||||
print("Message:\n")
|
|
||||||
print(f" {message}\n")
|
|
||||||
|
|
||||||
if not args.no_clipboard:
|
|
||||||
copy_to_clipboard(message)
|
|
||||||
print("Copied to clipboard")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
try:
|
|
||||||
main()
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error: {e}")
|
|
||||||
exit(1)
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
if [ -n "${1:-}" ]; then
|
|
||||||
TARGET_BRANCH="$1"
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
TARGET_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
|
|
||||||
fi
|
|
||||||
|
|
||||||
FORK_POINT=$(git merge-base --fork-point "$TARGET_BRANCH")
|
|
||||||
|
|
||||||
git rebase "$FORK_POINT" --autosquash "$@"
|
|
Loading…
Reference in New Issue