summaryrefslogtreecommitdiff
path: root/archive
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-12-04 12:03:05 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-12-04 12:09:51 -0700
commite697d4e1d9fc93a9d3a9d92780bd7be5a2e7a102 (patch)
treee5b8d91fa2038bbdf90515148c2f66c8fe81d083 /archive
parent209333313923a9ccafb3ddd3705e14365bf98ca3 (diff)
downloaddotfiles-e697d4e1d9fc93a9d3a9d92780bd7be5a2e7a102.tar.gz
stop setting up 'dgit fetch' post_checkout actions
These actions never or almost never get run because we're writing them to the machine-specific ~/.mrconfig. For them to be run, we'd have to nuke the repos and then clone them again using 'mr co', which I never or almost never do for repos registered in ~/.mrconfig.
Diffstat (limited to 'archive')
-rw-r--r--archive/lib-src/mr/dgit92
1 files changed, 92 insertions, 0 deletions
diff --git a/archive/lib-src/mr/dgit b/archive/lib-src/mr/dgit
new file mode 100644
index 00000000..6a26d065
--- /dev/null
+++ b/archive/lib-src/mr/dgit
@@ -0,0 +1,92 @@
+# A module for working with dgit(1) repositories
+#
+# Copyright (C) 2017, 2020 Sean Whitton
+#
+# Maintainer: Sean Whitton <spwhitton@spwhitton.name>
+
+# DEFINITION
+#
+# A dgit repository is a git repository containing special remote refs
+# of the form `remotes/dgit/dgit/*` and possibly also branches of the
+# form `dgit/*`. See dgit(7) for more details.
+#
+# USAGE
+#
+# To make mr use this file, add a line like this inside the [DEFAULT]
+# section of your ~/.mrconfig:
+#
+# include = cat /usr/share/mr/dgit
+#
+# With this module active,
+#
+# `mr update` will:
+#
+# (1) if the current branch is named `dgit/SUITE`, call `dgit pull`.
+#
+# (2) use `dgit fetch` to update all remotes/dgit/dgit/*` refs.
+#
+# `mr register` will add a post_checkout hook that calls `dgit fetch`.
+#
+# DESIGN
+#
+# A dgit repository may have been obtained with `dgit clone`, or `git
+# clone` followed by `dgit fetch`. It is not possible for us to
+# determine which of these methods was used after the fact.
+#
+# For this reason, we do not define dgit_register and dgit_test so as
+# to generate .mrconfig lines like
+#
+# [foo]
+# checkout = dgit clone foo
+#
+# because that would fail to fetch branches not published to
+# dgit-repos, such as branches published to alioth.debian.org.
+#
+# Instead, we extend git_update and git_register to obtain updates
+# from dgit-repos.
+
+# we obtain the source package name from git and pass it to dgit with
+# the latter's -p option, because the currently checked out branch may
+# not contain debian/control, which would cause dgit fetch without -p
+# to fail
+lib =
+ set_source () {
+ if [ -z "$source" ]; then
+ source=$(git cat-file blob dgit/dgit/$1:debian/control \
+ | awk -F': ' '$1 ~ /Source/ { print $2 }')
+ fi
+ }
+
+# We can't use git_update_append because mr's built-in default `git
+# pull` will often fail on a `dgit/SUITE` branch. After a `dgit
+# clone`, (i) `dgit/SUITE` has no upstream tracking branch, and (ii)
+# the 'origin' remote might not exist on the remote end (it depends on
+# whether the package has ever been uploaded with `dgit push`)
+git_update =
+ current_branch="$(git rev-parse --abbrev-ref HEAD)"
+ if [ "$(echo $current_branch | cut -s -d/ -f1)" = "dgit" ]; then
+ # (1) above
+ dgit pull
+ else
+ # mr's built-in git_update
+ git pull "$@"
+ fi
+ # (2) above
+ for suite in $(git show-ref | grep refs/remotes/dgit/dgit | cut -d/ -f5 ); do
+ # skip if we just called `dgit pull` on this suite
+ if ! [ "$current_branch" = "dgit/$suite" ]; then
+ set_source $suite
+ dgit -p$source fetch $suite
+ fi
+ done
+
+git_register_append =
+ lines="cd '$MR_REPO'"
+ for suite in $(git show-ref | grep refs/remotes/dgit/dgit | cut -d/ -f5 ); do
+ set_source $suite
+ echo "Registering dgit suite: $suite in $MR_CONFIG"
+ lines="$lines; dgit -p$source fetch $suite"
+ done
+ if ! [ "$lines" = "cd '$MR_REPO'" ]; then
+ mr -c "$MR_CONFIG" config "`pwd`" post_checkout="$lines"
+ fi