home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c45d54e555f2c9eb185b4aa053b299c10b36a370
parent d34e4c7b04ba5504badb2f4646f9cac55c3dde8b
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Tue, 26 May 2020 09:00:03 +0200

hack: add univ to update niv…

… in style

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Ahack/univ.sh | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+), 0 deletions(-)

diff --git a/hack/univ.sh b/hack/univ.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# univ: update niv (and generate a nice commit) + +set -euo pipefail + +SOURCES=nix/sources.json + +error() { + echo "::error::$*" + exit 1 +} + +update() { + local dep=$1 + echo "checking for update: $dep" >&2 + owner=$(jq -r ".\"$dep\".owner" < ${SOURCES}) + repo=$(jq -r ".\"$dep\".repo" < ${SOURCES}) + old_rev=$(jq -r ".\"$dep\".rev" < ${SOURCES}) + dep_url=$(jq -r ".\"$dep\".url // empty" < "${SOURCES}" | { grep github.com || true; }) + [[ -n $dep_url ]] && is_github="yes" || is_github="" + niv update $dep 1>&2 + new_rev=$(jq -r ".\"$dep\".rev" < ${SOURCES}) + if [[ $old_rev == $new_rev ]]; then + echo "… no updates" >&2 + return + fi + echo "$dep: ${old_rev} to ${new_rev}" + if [[ -z $is_github ]]; then + echo "$dep not using github.com, no changelog" + else + merges_filter="" + hub api "/repos/$owner/$repo/compare/${old_rev}...${new_rev}" \ + | jq -r '.commits[] '"$merges_filter"' | "* [`\(.sha[0:8])`](\(.html_url)) \(.commit.message | split("\n") | first)"' \ + | sed "s~\(#[0-9]\+\)~$owner/$repo\1~g" + fi +} + +main() { + message=$(mktemp) + commit_msg=$(mktemp) + for dep in $(jq -r 'keys[]' < ${SOURCES}); do + update $dep >> $message + echo "" >> $message + done + echo $message $commit_msg + content=$(cat $message | tr -d '\n') + if [[ -z "$content" ]]; then + echo "No updates, do nothing" + exit 0 + fi + echo "nix: niv update(s)" > $commit_msg + echo "" >> $commit_msg + cat $message >> $commit_msg + git add nix + git commit -F $commit_msg +} + +main $@