summary refs log tree commit diff
path: root/pkgs/shells/zsh/oh-my-zsh/update.sh
blob: 0146cac8496ca369d6c258c37d2b3fd4603c6861 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts jq

set -eu -o pipefail

oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion oh-my-zsh" | tr -d '"')"
latestSha="$(curl -L -s https://api.github.com/repos/ohmyzsh/ohmyzsh/commits\?sha\=master\&since\=${oldVersion} | jq -r '.[0].sha')"
url="$(nix-instantiate --eval -E "with import ./. {}; oh-my-zsh.src.url" | tr -d '"')"

if [ ! "null" = "${latestSha}" ]; then
  latestDate="$(curl -L -s https://api.github.com/repos/ohmyzsh/ohmyzsh/commits/${latestSha} | jq '.commit.author.date' | sed 's|"\(.*\)T.*|\1|g')"
  update-source-version oh-my-zsh "${latestSha}" --version-key=rev
  update-source-version oh-my-zsh "${latestDate}" --ignore-same-hash
  nixpkgs="$(git rev-parse --show-toplevel)"
  default_nix="$nixpkgs/pkgs/shells/zsh/oh-my-zsh/default.nix"
  git add "${default_nix}"
  git commit -m "oh-my-zsh: ${oldVersion} -> ${latestDate}"
else
  echo "oh-my-zsh is already up-to-date"
fi