summaryrefslogtreecommitdiff
path: root/.mrconfig.in
blob: cf2cd17ec70eca22044dfee6150dec24e157ed3c (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
# -*- mode: conf -*-

[DEFAULT]

# --- global settings

# avoid hangs due to SSH connection sharing
jobs = 1

# custom actions to be configured repository-by-repository, that do
# nothing by default
git_sync = :
git_rebase = :
git_autoci = :

# avoid pushing non-matching branches, while trying to avoid errors
# from trying to push to read-only remotes
git_push = git push-all

# find dirty working directories, i.e., uncommitted changes, untracked
# files and stashes
git_isclean = git is-clean

git_clean = git clean -xdff

# --- Plugin for dgit repos

# actually shipped with upstream mr, but use an include command that
# will always work
include = cat ~/src/dotfiles/lib-src/mr/dgit

# --- git-svn

# include = [ -e "/usr/share/mr/git-svn" ] && cat /usr/share/mr/git-svn

# --- Sensible pulls

# Redefine git_update to avoid an unconditional `git pull`, which can
# result in unwanted merge commits all over $HOME (this has to come
# after we include the dgit lib, which also redefines git_update)
git_update = git pull-safe

# --- Adam Spiers' plugin for managing dotfile symlinks with mr

# actually shipped with upstream mr, but use an include command that
# will always work
include =
    # stow is not available on Windows
    if [ -e "$HOME/src/dotfiles/lib-src/mr/stow" ] \
         && ! [ "$(perl -e 'print $^O')" = "msys" ]; then
        cat "$HOME/src/dotfiles/lib-src/mr/stow"
    fi

# --- joeyh's code for specifying what machine we're on for repo skip
# --- tests, plus my code for detecting Git-on-Windows

lib =
    win32() {
        test "$(perl -e 'print $^O')" = "msys"
    }
    #
    if win32; then
       hostname=$(hostname)
    else
       hostname=$(hostname -s)
    fi
    #
    whoami="$(whoami)"
    # cut off the machine name on Windows
    win32 && whoami=${whoami##*\\}
    #
    on() {
        for host in $@; do
            if [ "${host%@*}" != "${host#*@}" ]; then
                if [ "$whoami" != "${host%@*}" ]; then
                    continue
                fi
                host="${host#*@}"
            fi
            if [ "$hostname" = "$host" ]; then
                return 0
            fi
        done
        return 1
    }
    workstation() {
        on swhitton@zephyr spwhitton@hephaestus spwhitton@melete
    }
    mine() {
        workstation || on spwhitton@athena
    }
    # tucson() {
    #     on artemis shortgeese athena hephaestus iris melete
    # }

# --- run a command on athena in a sane environment

# lib =
#     athena_cmd () {
#         # here we rely on the fact that ssh already passes argument
#         # through `/bin/sh -c' (note use of single-quotes in this
#         # function)
#         ssh athena 'cd $HOME/'"$1"' && . $HOME/.shenv && '"$2"
#     }

# --- standard procedures

lib =
    homedir_mkdirs() {
        (
            cd $HOME
            mkdir -p \
                .ssh \
                tmp \
                src \
                lib \
                mnt \
                # lib/athena \
                # lib/backup \
                local/mutt \
                # local/anacron/spool \
                local/src \
                local/bin \
                local/big \
                local/lib \
                local/log \
                local/pub \
                local/tmp \
                local/auth \
		local/info
            chmod 700 local/auth
            # [ -L "src/build-area" ] || ln -s -T /tmp/debuild src/build-area
            [ -e "Downloads" ] || ln -s tmp Downloads
            # clean up after additions to .stow-local-ignore
            find bin lib -type l 2>/dev/null | while read -r link; do
                if readlink "$link" | grep --quiet "^[../]*/.STOW/"; then
                    rm "$link"
                fi
            done
            # cleanup some old dirs if they're empty
            find \
                bin \
                lib/aid \
		lib/backup \
                lib/perl5 \
                lib/hooks \
                lib/athena \
		lib/bins \
		lib/img \
		lib/mr \
		lib/src \
                local/anacron/spool \
                -type d -empty -delete 2>/dev/null ||:
        )
    }
    # specify files that should automatically be adopted because
    # programs convert them from symlinks to regular files.  Arguments
    # to this function should be paths relative to the stow target
    # (usually $HOME)
    always_adopt () {
        for f in $@; do
            if ! [ -L "$STOW_TARGET/$f" ]; then
                # ignore errors; if it doesn't work, the user will
                # have to fix up manually
                mv 2>/dev/null "$STOW_TARGET/$f" "$MR_REPO/$f" || true
            fi
        done
    }
    # export plain text Org agenda in post_ hooks of ~/doc repo (not currently used)
    export_org_agenda () {
        if on athena; then
            emacs --batch -l ~/.emacs.d/init.el -eval '(org-batch-agenda "a")' 2>/dev/null \
                >~/local/priv/agenda.txt
        else
            emacs --batch -l ~/.emacs.d/init.el -eval '(org-batch-agenda "a")' 2>/dev/null \
                | ssh athena "cat >/home/spwhitton/local/priv/agenda.txt"
        fi
    }

# --- primary dotfiles repository

# TODO we need to unstow before switching branches, and stow
# afterwards, or else do some sort of automatic cleanup of dangling
# symlinks before a restow, so a broken situation is easy to fix?
# Also see kill-broken-stowed-symlink() in .bashrc.
#
# Note that the scan is expensive.  So actually we probably don't want
# the cleanup to happen automatically.  Also, it should exclude
# lib/annex, src/*/ (but not src/) because I don't stow files into
# those dirs.
#
# Maybe just run it as part of sysmaint
#
# Hmm.  Situation is not as bad as I thought.  stow manages to clean
# up quite a few of the symlinks.  So running it as part of sysmaint
# seems like a sufficient fix

[src/dotfiles]
checkout = git clone https://git.spwhitton.name/dotfiles.git dotfiles
stowable = true
# we have a script to update master, and all other branches should
# only be checked out and committed to on a single host
update = git dotfiles-update-master
push = git push origin master
# use `git dotfiles-rebase` instead
# rebase =
#     # usual rebasing pattern.  Per dotfiles repo policy (excluding
#     # win32 case), the branch being rebased will always be rebaseable
#     # on master, since it is only checked out and committed to on this
#     # host
#     branch="$(git rev-parse --abbrev-ref HEAD)"
#     hostname="$(hostname -s)"
#     if [ "$branch" = "win32" -o "$branch" = "$hostname" -o "$branch" = "develacc-$hostname" ]; then
#         git rebase master
#     fi
fixups =
    # Use a rebase workflow as I'm the only committer
    git config pull.rebase true
    # Pushing and pulling are always done explicitly
    for head in $(git for-each-ref --format='%(refname)' refs/heads/); do
        branch=$(echo "$head" | cut -d/ -f3)
        git branch --unset-upstream "$branch" 2>/dev/null || true
    done
    git config push.default nothing
    # this is just for M-x magit-status
    git config remote.pushDefault origin
    #
    if win32; then
        ( cd ~/src/dotfiles/bin && cmd "/C win32setup.bat" )
    else
        $HOME/src/dotfiles/bin/normalise-mrconfig
        #
        homedir_mkdirs
        chmod -Rf u+rwX,go= $HOME/local/auth/* || true
    fi
    # eventually move the following two lines from fixups to post_checkout
    install-git-hooks dotfiles
    git config user.signingkey 8DC2487E51ABDD90B5C4753F0F56D0553B6D411B
    # eventually drop this
    rm -f .git/hooks/post-checkout{,_01gpgsign}

# clean-ups so that initial stow will be successful
pre_stow =
    homedir_mkdirs
    $HOME/src/dotfiles/bin/unskel
    # these will often end up created, e.g. by insinuate-dotfiles script
    rm -f $HOME/.gnupg/{gpg.conf,gpg-agent.conf,dirmngr.conf,.gpg-v21-migrated}

# this file frequently gets desymlinked
pre_unstow_append = always_adopt .config/mimeapps.list
pre_restow_append = always_adopt .config/mimeapps.list
pre_stow_append = always_adopt .config/mimeapps.list
pre_update_append = always_adopt .config/mimeapps.list

# --- private dotfiles repositories

[lib/priv]
checkout = git clone athenag:libpriv.git priv
update = git annex sync --content cloud origin
push = git annex sync --content cloud origin
stowable = true
skip = lazy

post_checkout =
    cd priv
    git annex init
    git annex enableremote cloud
    git annex group . backup

fixups =
    chmod 600 .passwddb.pet \
          .gnupg/*.kbx \
          .gnupg/private-keys-v1.d/*.key \
          .ssh/id_*

    git config push.default nothing
    git config remote.origin.gcrypt-publish-participants true
    git config remote.origin.gcrypt-participants 0x0F56D0553B6D411B
    git config annex.startupscan false
    git config annex.autocommit true # needed for `git annex sync`
    git config remote.origin.annex-ignore true
    git config unpushed-tags.ignore true

    git config annex.gitaddtoannex false # see README
    git config annex.addunlocked true    # see README

    git config mrrepo.review-unused false

autoci =
        git annex add .passwddb.pet .labbook.gpg .gnupg/pubring.kbx
        git commit -a -m \
            "auto passwddb, pubring and labbook commit on $(hostname -s)" || true
pre_update = mr autoci

# since dotfiles repo also stows into ~/.gnupg, and athpriv repo stows
# into ~/.duply, make the dirs first
pre_stow = homedir_mkdirs
post_stow = load-trustdb

[src/athpriv]
checkout = git clone demeterp:athpriv athpriv
stowable = true
skip = ! mine

# since priv repo also stows into ~/.duply, make the dir first
pre_stow = homedir_mkdirs

# r2e always desymlinks this file
pre_stow_append = always_adopt .config/rss2email.cfg
pre_unstow_append = always_adopt .config/rss2email.cfg
pre_restow_append = always_adopt .config/rss2email.cfg
pre_update_append = always_adopt .config/rss2email.cfg

# --- hosts configuration

[src/propellor]
checkout = git clone demeter:propellor propellor --branch spw3conf
post_checkout =
    cd propellor
    # get new release tags for merging into 'spw3conf' and 'debian' branches
    git remote add -f upstream https://git.joeyh.name/git/propellor.git
    # This hook sets up .dir-locals.el to make it easier to follow
    # Propellor's coding style.  We have to use a hook because
    # .dir-locals.el and the cabal sandbox must be nuked when working
    # with dgit on the 'debian' branch
    install-git-hooks propellor
    echo ".dir-locals.el" >>.git/info/exclude
fixups =
    # check that the link isn't already in place before making the link
    # because otherwise we get an infinite loop of links that breaks propellor
    [ -L ~/.propellor ] || ln -sf ~/src/propellor ~/.propellor
    # my preferences when using propellor for configuring my own machines
    git config propellor.spin-branch spw3conf
    git config propellor.forbid-dirty-spin true
    git config --local sendemail.to "Joey Hess <propellor@joeyh.name>"

skip = ! workstation

# --- personal website source

[src/wiki]
checkout = git clone demeter:wiki
skip = ! mine

# --- misc. source repos with special config (e.g. installation of git
# --- hooks)

[src/dgit]
checkout = git clone salsa:dgit-team/dgit
post_checkout =
    cd dgit
    git remote add -f demeter demeter:dgit
    dgit setup-new-tree
    install-git-hooks dgit
skip = lazy

# [src/ublock-origin]
# checkout = git clone 'https://anonscm.debian.org/git/pkg-mozext/ublock-origin.git' 'ublock-origin'
# # beta, rc and alpha tags get deleted by upstream so there will very
# # often be unpushed tags
# push = git push-all --no-tags
# skip = lazy

[src/grml-live]
checkout = git clone demeter:grml-live -b spw/std
post_checkout =
    cd grml-live
    git remote add -f upstream github:grml/grml-live
fixups = git config commit.gpgsign true
skip = lazy

[src/mailscripts]
checkout = git clone 'demeter:mailscripts' 'mailscripts'
post_checkout =
    cd mailscripts
    install-git-hooks mailscripts
    git config branch.buster-bpo.signOffOptional true
    dgit fetch buster-backports; dgit fetch sid
skip = ! workstation

[src/p5-Git-Annex]
checkout = git clone demeter:p5-Git-Annex p5-Git-Annex
post_checkout =
    cd p5-Git-Annex
    install-git-hooks p5-Git-Annex
    git remote add -f salsa salsa:perl-team/modules/packages/libgit-annex-perl
    git branch --track debian salsa/master
    git config branch.debian.signOffOptional true
    git config branch.buster-bpo.signOffOptional true
skip = lazy

[src/p5-API-GitForge]
checkout = git clone demeter:p5-API-GitForge p5-API-GitForge
post_checkout =
    cd p5-API-GitForge
    install-git-hooks p5-API-GitForge
    git remote add -f salsa salsa:perl-team/modules/packages/libapi-gitforge-perl
    git branch --track debian salsa/master
    git config branch.debian.signOffOptional true
skip = lazy

[src/org-d20]
checkout = git clone 'demeter:org-d20' 'org-d20'
post_checkout =
    cd org-d20
    install-git-hooks org-d20
skip = lazy

[src/haskell-tab-indent]
checkout = git clone 'demeter:haskell-tab-indent' 'haskell-tab-indent'
post_checkout =
    cd haskell-tab-indent
    install-git-hooks haskell-tab-indent
skip = lazy

[src/git-remote-gcrypt]
checkout = git clone 'demeter:git-remote-gcrypt' 'git-remote-gcrypt'
post_checkout =
    cd git-remote-gcrypt
    install-git-hooks git-remote-gcrypt
skip = ! workstation

[src/pandoc-citeproc-preamble]
checkout = git clone 'demeter:pandoc-citeproc-preamble' 'pandoc-citeproc-preamble'
post_checkout =
    cd pandoc-citeproc-preamble
    install-git-hooks pandoc-citeproc-preamble
skip = lazy

# 'master' branch: just for installing changes to upstream master
#
# 'melete' branch:
#
#     Rebased onto sv.gnu.org's master branch.  It has
#
#       - patch(es) to integrate these development builds with my Debian
#         workstation setup, just enough that I can use these builds day-to-day;
#         these assume a sufficiently recent emacs-snapshot package from demeter
#         is installed, to provide /usr/share/emacs-snapshot/site-lisp/elpa
#
#       - bug fixes, reversions etc., (cleaned up versions of) which have not
#         yet made it onto sv.gnu.org's master, but which are required for my
#         own usage
#
#       - WIP patches of my own -- this branch is used for my own development
#         work, at least where that doesn't require long-lived feature branches.
#
#     A key advantage of using these development builds is that references to
#     files in *Help* buffers will be to ~/src/emacs, not to somewhere owned by
#     root.  The branch is named after my laptop at the time I first set it up.
#
# 'athena/unstable' branch:
#
#     Merges from sv.gnu.org's master branch only.  .deb packages produced from
#     this branch are available from <http://silentflame.com/debian>.  There are
#     two purposes:
#
#       - providing byte-compiled Lisp /usr/share/emacs-snapshot/site-lisp/elpa
#         to builds from the 'melete' branch
#
#       - direct use on machines other than my development laptop where I want
#         something more current than the stable release of Emacs but not with
#         my current WIP.
#
#     Updated only when new fixes, features or reversions on sv.gnu.org's
#     master branch are wanted on machines other than my development laptop.
#     To do that, first 'melete' is updated using 'mr pull', and then I run
#     that build for a day or so.  Then update this branch using
#     debian/merge-snapshot script, which uses the commit onto which 'melete'
#     was rebased.  Use 'dgit sbuild' to get something to test, and then use
#     'rebuild-for-athena unstable' to build, tag and upload.
#
#     It is important to test local installability of the new .deb, probably
#     in develacc or a sid chroot, before running release-to-athena, because
#     running the rebased 'melete' branch doesn't detect any byte compilation
#     issues against my current selection of elpa-* packages. After installing
#     the new .deb, also test '/opt/emacs-snapshot/bin/emacs --debug-init'.
#
# 'athena/CODENAME-bpo' branch:
#
#     Backported from athena/unstable.  Automatically updated by
#     rebuild-for-athena when updating athena/unstable as described above.
#
# See also bin/emacsclient wrapper script in dotfiles.git.
[src/emacs]
checkout = git clone https://git.savannah.gnu.org/git/emacs.git emacs
post_clean = ./autogen.sh autoconf
post_checkout =
    cd emacs
    git remote add -f demeter demeter:emacs
    git checkout -b melete demeter/melete
    ./autogen.sh all
    git worktree add -b athena/unstable "$HOME/src/emacs-snapshot" demeter/athena/unstable
fixups =
    git rev-parse melete@{upstream} >/dev/null 2>&1 \
        && git branch --unset-upstream melete
    git config branch.master.rebase true
    git config branch.melete.rebase true
    git config branch.melete.pushRemote demeter
    git config --replace-all remote.demeter.push ":" "^:$"
    git config --replace-all remote.demeter.push "+melete:melete" "^\+melete:melete$"
# We don't have the melete branch's upstream set to origin/master to avoid
# accidental attempts to push to upstream master by typing "P u" in magit
# (push.default cannot help here).  So for convenient updates of melete to its
# upstream, we have this definition.  "pull" not "update" because we want to
# update from upstream master deliberately, not as part of automated updates.
pull = git checkout melete && git pull --rebase --autostash origin master && git push -f demeter melete
skip = ! workstation

[src/elpa]
checkout = git clone https://git.savannah.gnu.org/git/emacs/elpa.git elpa
post_checkout = cd elpa && make setup
skip = lazy

[src/nongnu-elpa]
checkout = git clone https://git.savannah.gnu.org/git/emacs/nongnu.git nongnu-elpa
post_checkout = cd elpa && make
skip = lazy

[src/org-mode]
checkout = git clone https://git.savannah.gnu.org/git/emacs/org-mode.git org-mode
skip = lazy

[src/cl/consfigurator]
checkout = git clone 'demeter:consfigurator' 'consfigurator'
post_checkout =
    cd consfigurator
    install-git-hooks consfigurator
skip = lazy

[src/notmuch]
checkout = git clone 'https://git.notmuchmail.org/git/notmuch' 'notmuch'
fixups = git config --local sendemail.to notmuch@notmuchmail.org
skip = lazy

[src/linux]
checkout = git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux
skip = lazy

[src/sbcl]
checkout = git -c fetch.fsckobjects=false clone https://git.code.sf.net/p/sbcl/sbcl
skip = lazy

# --- radicale collections

[lib/radicale]
checkout = git clone demeterp:radicale radicale
skip = ! on spwhitton@athena

# could use /usr/share/mr/git-annex helper to simplify the following
# configuration of annexes (overriding its update definition to avoid
# --content) but probably not flexible enough for all that's going on
# in the below

# --- primary git annex

[lib/annex]
checkout = git clone athenag:annex.git annex
post_checkout =
    cd annex
    git annex init
    git annex enableremote athena rsyncurl=athena:local/rsync/annex
skip = ! workstation

update = git annex sync --no-content origin
# disabled because required yubikey
# sync = git annex sync --no-content origin
push = git annex sync --content origin athena
fixups =
    git config push.default matching
    git config remote.origin.gcrypt-publish-participants true
    git config remote.origin.gcrypt-participants 0x0F56D0553B6D411B
    # git config gcrypt.publish-participants true
    # git config gcrypt.participants 0x0F56D0553B6D411B
    git config annex.startupscan false
    git config annex.autocommit true # needed for `git annex sync`
    git config remote.origin.annex-ignore true
    git config unpushed-tags.ignore true

[annex]
checkout = git clone athenag:annex19.git annex
update = git annex sync --no-content origin
push = git annex sync --content cloud origin
skip = lazy

post_checkout =
    cd annex
    git annex init
    git annex enableremote cloud

fixups =
    git config push.default nothing
    git config remote.origin.gcrypt-publish-participants true
    git config remote.origin.gcrypt-participants 0x0F56D0553B6D411B
    git config annex.startupscan false
    git config annex.autocommit true # needed for `git annex sync`
    git config remote.origin.annex-ignore true
    git config unpushed-tags.ignore true

# --- personal website big files annex

[lib/wikiannex]
checkout = git clone demeter:wikiannex.git
post_checkout =
    cd wikiannex
    git annex init
    git config remote.origin.annex-ignore false
    # ^ the git-annex-init sets this wrong

    # if workstation; then
    #     git remote add bkupsd /media/${USER}/bkupsd/git/demeter/wikiannex.git
    #     git remote add m3 /media/${USER}/m3/git/demeter/wikiannex.git
    # fi
update = git annex sync --no-content
push = git annex sync --content
skip = lazy
fixups =
    git config unpushed-tags.ignore true
    if [ "$(hostname -s)" = "demeter" ]; then
        git annex adjust --hide-missing --unlock
    fi

# --- git annex for university stuff

[lib/dionysus]
checkout = git clone demeterp:dionysus
post_checkout =
    cd dionysus
    git annex init
    on athena || git remote add athena athenah:lib/dionysus
status = git annex status
update = git annex sync --no-content
push = git annex sync --content
#sync = sync-for-dionysus
sync = git annex sync --content

# origin remote is just for keeping a backup copy of metadata.  athena
# remote, in $HOME on athena, contains a copy of content.  At present,
# origin remote only updated by sysmaint script (run weekly)
fixups =
    git config push.default matching
    git config annex.startupscan false
    git config annex.autocommit true # needed for ga sync
    git config annex.addunlocked true # for simplicity with existing workflows
    git config remote.origin.annex-ignore true
    git config mrrepo.review-unused false
    git config unpushed-tags.ignore true

skip = lazy

# --- git annex for podcasts

[lib/podcasts]
checkout = git clone demeterp:podcasts
post_checkout =
    cd podcasts
    git annex init
update = ./update-and-sync
push = git annex --no-content sync
# origin remote is just for keeping a backup copy of metadata.  We don't sync
# annexed content between repos at all, just run update-and-sync and download
# episodes as want to listen to them.  For archival, for podcasts for which
# that's wanted, annex-to-annex the files into ~/annex instead of 'git rm'.
fixups =
    git config push.default matching
    git config annex.startupscan false
    git config annex.autocommit true # needed for ga sync
    git config remote.origin.annex-ignore true
    git config annex.genmetadata true
skip = lazy

# --- git annex for use with rtorrent

# [lib/rt]
# checkout = git clone athenag:rt.git rt
# post_checkout =
#     cd rt
#     git annex init
#     if [ -d "$(hostname -s)" ]; then
#         mkdir -p $HOME/local/rt
#         cd $HOME/local/rt
#         touch .duplicity-ignore
#         mkdir -p session incomplete
#         if ! [ -e "complete" ]; then
#             ln -s $HOME/lib/rt/complete complete
#         fi
#         if ! [ -e "watch" ]; then
#             ln -s $HOME/lib/rt/$(hostname -s) watch
#         fi
#     fi
# status = git annex status --fast
# update = git annex sync --no-content origin
# push = git annex sync --no-content origin
# autoci = (git annex add . && git commit -m "auto commit on $(hostname -s)") || true
# fixups =
#     git config push.default matching
#     # git config gcrypt.publish-participants true
#     git config remote.origin.gcrypt-publish-participants true
#     git config remote.origin.gcrypt-participants 0x0F56D0553B6D411B
#     git config annex.startupscan false
#     git config annex.autocommit true # needed for `git annex sync`
#     git config remote.origin.annex-ignore true
#     git config unpushed-tags.ignore true

# skip = lazy
# pre_update = mr autoci

# --- git annex for athena's apt repository

[lib/athena-apt]
checkout = git clone demeter:athena-apt athena-apt
post_checkout =
    cd athena-apt
    git annex init --version=7
    git annex enableremote demeter rsyncurl=demeter:/srv/www/debian
    git annex get .
skip = lazy

update = git annex sync --no-content
push =
    git annex add
    git annex unlock db
    git annex sync --content demeter
    git annex sync origin
    ssh demeter find /srv/www/debian -type f -exec chmod 644 '{}' +
    ssh demeter find /srv/www/debian -type d -exec chmod 755 '{}' +
fixups =
    git config push.default matching
    git config annex.startupscan false
    git config annex.autocommit true # needed for `git annex sync`
    git config remote.origin.annex-ignore true
    git config annex.thin true
    git config annex.addunlocked true
    git config mrrepo.review-unused false
    git config remote.demeter.annex-tracking-branch master
    git config unpushed-tags.ignore true

# The git-diff-files(1) call in ~/bin/git-is-clean fails in v7
# git-annex repos with unlocked empty files, which this repo often
# has: empty Packages files.  So can't use that script in this repo
isclean =
    output="$(git annex status)"
    test -z "$output" || ( echo $output && exit 1 )

[lib/realloc]
checkout = git clone demeterp:realloc realloc
skip = ! mine

[lib/nmbug-spw]
checkout = nmbug-spw clone demeterp:nmbug-spw
update = nmbug-spw pull
push = nmbug-spw push
sync = mr autoci; nmbug-spw pull && nmbug-spw push
status =
    nmbug-spw status | grep -v "^U\s" || true
    # `nmbug status` does not catch committed but unpushed changes
    git --no-pager log --branches \
        --not --remotes \
        --simplify-by-decoration --decorate --oneline
log = nmbug-spw log
commit = nmbug-spw commit
# Should be safe to commit a small number of local changes.  We're
# trying to avoid:
#   - wiping out git because db contains no spw:: tags (`nmbug
#     checkout` needed)
#   - doing any committing when there are known remote changes.
#
# TODO (Script to) periodically drop old spw::killed tags from repo.  This
# should speed up nmbug-spw runs on athena.  Might need to adjust autoci,
# however, as dropping the tags might mean there are less than 500 tags left,
# in which case the current check would not protect us from wiping out git
# when `nmbug checkout` is needed.
autoci =
    nmbug-spw status | perl -ne'/^[AD][ad]?\s/ and $i++ > 500 and exit 1' \
              && nmbug-spw commit
skip = ! [ -e "$HOME/local/auth/fmailsyncpass" ]

# --- my personal documents.  Override my global update command back
# --- to the myrepos default so that git automatically pulls and
# --- merges.  Skipped on non-local hosts

[doc]
checkout = git clone demeterp:doc doc
update = git pull --no-edit "$@"
skip = ! mine

# set file modification times to last commit for deft.el
# (commented out because no longer using deft)
#fixups = git-utime

# before pulling, automatically commit in the same way that my cron job does
pre_update = win32 || doccheckin
# ... and let me do it manually
autoci = doccheckin || true

# quick syncs
sync = doccheckin && git pull --no-edit && git push

# --- static websites on web host boxes

[public_html]
clone = git clone https://git.spwhitton.name/sageweb public_html
skip = ! on spwhitton@sage

[html]
clone = git clone https://git.spwhitton.name/sdfweb html
skip = ! [ "$(domainname)" = "SDF" ]

# --- my offline e-mail (& machine's postfix queue)

[.fmail]
checkout =
    mkdir ~/.fmail
    movemymail
sync = movemymail
update = movemymail
push = movemymail
status = :
clean = :
commit = :
record = :
fetch = :
diff = :
log = :
grep = :
autoci = :
isclean = :
skip = ! [ -e "$HOME/local/auth/fmailsyncpass" ]

# this is slower than other repos for which sync is defined, so have
# it go last
order = 12