From 7adbf27b250833d5fc3751d4d348037b24e30442 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 24 Oct 2024 18:21:22 +0200 Subject: refactor(modules/git): Migrate and parameterize --- modules/home.legacy/conf/default.nix | 1 - modules/home.legacy/conf/git/aliases.nix | 82 ----------------------- modules/home.legacy/conf/git/default.nix | 96 --------------------------- modules/home.legacy/conf/git/git_ignore.git | 4 -- modules/home.legacy/conf/git/git_template.git | 66 ------------------ 5 files changed, 249 deletions(-) delete mode 100644 modules/home.legacy/conf/git/aliases.nix delete mode 100644 modules/home.legacy/conf/git/default.nix delete mode 100644 modules/home.legacy/conf/git/git_ignore.git delete mode 100644 modules/home.legacy/conf/git/git_template.git (limited to 'modules/home.legacy') diff --git a/modules/home.legacy/conf/default.nix b/modules/home.legacy/conf/default.nix index 161c04a1..39ae1cd3 100644 --- a/modules/home.legacy/conf/default.nix +++ b/modules/home.legacy/conf/default.nix @@ -7,7 +7,6 @@ ./direnv ./firefox ./gammastep - ./git ./gpg ./gtk ./himalaya diff --git a/modules/home.legacy/conf/git/aliases.nix b/modules/home.legacy/conf/git/aliases.nix deleted file mode 100644 index 15bf613d..00000000 --- a/modules/home.legacy/conf/git/aliases.nix +++ /dev/null @@ -1,82 +0,0 @@ -{ - lib, - config, -}: { - cmr = "commit --file .git/COMMIT_EDITMSG --edit --verbose"; - - st = "status"; - sts = "status --short --branch"; - - ds = "diff --staged"; - di = "diff"; - rs = "restore --staged"; - - ## Logging: - ls = "log --max-count=10 --color --format=format:'%C(bold red)%h%C(reset) %C(dim bold blue)%s%C(reset) %C(dim white)[%aN] %C(bold red)<%G?>%C(reset)%C(auto)%d%C(reset)'"; - - # https://stackoverflow.com/a/61487052 - lg = "lg1"; - lg1 = "lg1-specific --all"; - lg2 = "lg2-specific --all"; - lg3 = "lg3-specific --all"; - - lg1-specific = "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 cyan) [%G?]%C(reset)%C(auto)%d%C(reset)'"; - - lg2-specific = "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(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'"; - - lg3-specific = "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 cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)\ - %C(bold red)(signature: %G? by %GS, trust: %GT)%C(reset)%n\ - '' %C(white)%s%C(reset)%n''\ - %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)\ - %C(bold white)- trailers: %(trailers) %C(reset)'"; - - # hard reset with commit before (use reflog to recover) - # git wipe [] - wipe = lib.strings.concatStringsSep " " [ - "!git" - "add" - "--all" - "&&" - "git" - "commit" - "--quiet" - "--message='WIPE-SAVEPOINT'" - "--no-gpg-sign" - "&&" - "git reset \${1:-HEAD~} --hard" - "&&" - "git clean -fd" - ]; - - branches = lib.strings.concatStringsSep " " [ - "!git" - "for-each-ref" - "--sort=-committerdate" - "--color=always" - "--format='${ - lib.strings.concatStringsSep "|" [ - "%(color:blue)%(authordate:relative)" - "%(color:red)%(authorname)" - "%(color:green)%(color:bold)%(refname:short)" - ] - }'" - "refs/remotes" - "|" - "column -ts'|' -o ' '" - ]; - - tags = "tag --list"; - - remotes = "remote --verbose"; - - day = "!git log --stat --since '1 day ago' --author $(git config user.email)"; - - unpush = "push --force-with-lease origin HEAD~1:${config.programs.git.extraConfig.init.defaultBranch}"; - - wip = "!git add . && git commit --amend && git push --force-with-lease"; -} diff --git a/modules/home.legacy/conf/git/default.nix b/modules/home.legacy/conf/git/default.nix deleted file mode 100644 index 6680c598..00000000 --- a/modules/home.legacy/conf/git/default.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ - lib, - config, - ... -}: let - gitIgnoreFile = ./git_ignore.git; - gitTemplateFile = ./git_template.git; -in { - programs.git = { - enable = true; - #package = pkgs.gitAndTools.gitFull; # TODO: for git send-email support - aliases = import ./aliases.nix {inherit lib config;}; - extraConfig = { - core = { - excludesFile = "${gitIgnoreFile}"; - }; - rebase = { - autoStash = true; - autoSquash = true; - }; - init = { - defaultBranch = "prime"; - }; - user = { - name = "Benedikt Peetz"; - email = "benedikt.peetz@b-peetz.de"; - # signingKey = "[is down below]"; - }; - help = { - autocorrect = 5; - }; - push = { - gpgSign = "if-asked"; - }; - commit = { - template = "${gitTemplateFile}"; - }; - diff = { - colorMoved = "default"; - # Usually leads to better results - algorithm = "patience"; - bin = { - textconv = "hexdump -v -C"; - }; - }; - # Makes it a bit more readable - blame = { - coloring = "repeatedLines"; - markIgnoredLines = true; - markUnblamables = true; - }; - merge = { - conflictstyle = "zdiff3"; - }; - url = { - "git@codeberg.org:" = { - insteadOf = "@cb:"; - }; - "https://codeberg.org/" = { - insteadOf = "cb://"; - }; - - "git@github.com:" = { - insteadOf = "@gh:"; - }; - "https://github.com/" = { - insteadOf = "gh://"; - }; - - "git@gitlab.com:" = { - insteadOf = "@gl:"; - }; - "https://gitlab.com/" = { - insteadOf = "gl://"; - }; - }; - }; - delta = { - enable = true; - options = { - decorations = { - commit-decoration-style = "bold yellow box ul"; - file-decoration-style = "none"; - file-style = "bold yellow ul"; - }; - keep-plus-minus-markers = true; - features = "decorations"; - whitespace-error-style = "22 reverse"; - }; - }; - signing = { - key = "8321ED3A8DB999A51F3BF80FF2682914EA42DE26"; - signByDefault = true; - }; - }; -} diff --git a/modules/home.legacy/conf/git/git_ignore.git b/modules/home.legacy/conf/git/git_ignore.git deleted file mode 100644 index 8f29815e..00000000 --- a/modules/home.legacy/conf/git/git_ignore.git +++ /dev/null @@ -1,4 +0,0 @@ -# default nvim Session file name -Session.vim - -# vim: ft=gitignore diff --git a/modules/home.legacy/conf/git/git_template.git b/modules/home.legacy/conf/git/git_template.git deleted file mode 100644 index 6af39119..00000000 --- a/modules/home.legacy/conf/git/git_template.git +++ /dev/null @@ -1,66 +0,0 @@ - -# Title: Summary, imperative, start upper case, don't end with a period -# If applied, this commit will - -# Body: Explain *what* and *why* (not *how*). - - -# BREAKING CHANGE: -# Fixes: # -# Refs: # -# Co-authored-by: - - - -# Convention Commits (https://www.conventionalcommits.org/en/v1.0.0/ or https://github.com/angular/angular/blob/85b4941be137a2fcdc664dc870e408dd72ad7de7/CONTRIBUTING.md#commit): -# feat: [Features] -> MINOR version bump -# A new feature -# -# fix: [Bug Fixes] -> PATCH version bump -# A bug fix -# -# append '!' after the type/scope: [Breaking Change] -> MAJOR version bump -# A breaking API change -# -# docs: [Documentation] -# Documentation only changes -# -# style: [Styles] -# Changes that do not affect the meaning of the code -# (white-space, formatting, missing semi-colons, etc) -# -# refactor: [Code Refactoring] -# A code change that neither fixes a bug nor adds a feature -# -# perf: [Performance Improvements] -> PATCH version bump -# A code change that improves performance -# -# test: [Tests] -# Adding missing tests or correcting existing tests -# -# build: [Builds] -> PATCH version bump -# Changes that affect the build system or external dependencies -# (example scopes: gulp, broccoli, npm) -# -# ci: [Continuous Integrations] -# Changes to our CI configuration files and scripts -# (example scopes: Travis, Circle, BrowserStack, SauceLabs) -# -# chore: [Chores] -# Other changes that don't modify src or test files -# -# reverts: [Reverts] -# Reverts a previous commit - -# How to Write a Git Commit Message: -# [https://chris.beams.io/posts/git-commit/] -> https://cbea.ms/git-commit/ -# -# 1. Separate subject from body with a blank line -# 2. Limit the subject line to 50 characters -# 3. Capitalize the subject line -# 4. Do not end the subject line with a period -# 5. Use the imperative mood in the subject line -# 6. Wrap the body at 72 characters -# 7. Use the body to explain *what* and *why* vs. *how* -# -# vim: ft=gitcommit -- cgit 1.4.1