about summary refs log tree commit diff stats
path: root/modules/home.legacy/conf/git/aliases.nix
blob: 15bf613d2acf4dea789c305b6f82f7546e3c3eb5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
  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 [<commit>]
  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";
}