Skip to content

Commit

Permalink
Add git attr alias for coauthorship
Browse files Browse the repository at this point in the history
The path is optional, allowing one to borrow
authors from a busier repo.
  • Loading branch information
samhh committed Mar 7, 2024
1 parent 8ccab0e commit b54da65
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions home/vcs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
};

aliases = {
attr =
let attr = pkgs.writeShellScript "git-attr" ''
set -e
repo="''${1:-.}"
recent=$(cd "$repo" && git shortlog -sec --since=1.month | ${pkgs.sd}/bin/sd '^\s*[0-9]+\s*(.+)$' '$1')
prefix='Co-authored-by: '
# Beware a trailing \n coming from fzf.
msg=$(echo "$recent" | ${pkgs.fzf}/bin/fzf -m | sd '^(.+)' "$prefix\$1")
git commit --amend --only -m "$(git log --format=%B -n1)" -m "$msg"
'';
in "!${attr}";
br = "branch";
brd = "branch -D @{-1}";
df = "diff";
Expand Down

0 comments on commit b54da65

Please sign in to comment.