blob: 1ee11eb8ef8c7d28acaafc1fd853b6e91ab91b9a (
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
|
#! /bin/sh
# NAME
# push - Push master to all your repositores
#
# SYNOPSIS
# push
#
# ENVIRONMENT VARIABLES
# LOGNAME Specifies who you are.
#
# STOCKHOLM Specifies where stockholm can be found.
# (Default: ~/stockholm)
#
set -efu
STOCKHOLM=${STOCKHOLM-$HOME/stockholm}
my_hosts() {
make -s -C "$STOCKHOLM" system=$HOSTNAME eval expr='
with config.krebs.lib;
let my-name = maybeEnv "LOGNAME" (abort "LOGNAME not set"); in
toJSON (attrNames (filterAttrs (_: host: host.owner.name == my-name)
config.krebs.hosts))
' \
| jq -r .
}
all_push_hosts() {
git remote -v \
| sed -n '
s/^\(\S\+\)\s\+git@\([^:]\+\):\(\S\+\) (push)$/{"key":"\1","value":{"host":"\2","repo":"\3"}}/p
' \
| jq -s from_entries
}
my_push_hosts() {
my_hosts \
| jq -r --argjson all_push_hosts "$(all_push_hosts)" \
'map(. as $host | select( $all_push_hosts | has($host)))[]'
}
my_push_hosts \
| parallel -j0 --no-notice --line-buffer --tag-string {} git push {} master
|