Skip to content

Instantly share code, notes, and snippets.

@roelds
Last active January 1, 2023 06:45
Show Gist options
  • Save roelds/20f60d405740af9fd78ffb1456d9b85f to your computer and use it in GitHub Desktop.
Save roelds/20f60d405740af9fd78ffb1456d9b85f to your computer and use it in GitHub Desktop.
forkware - fish shell script : local clone latest git repo for line changes via yaml
#!/usr/bin/fish
#v1.0
echo $argv
set src (yq '.therepo' forkware.yaml)
set host (yq '.hosted' forkware.yaml)
set rel (yq '.release' forkware.yaml)
set meth (yq '.method' forkware.yaml)
echo $src
switch $host
case github gh
set ghlatestver (wget -q -O- https://api.github.com/repos/$src/releases/latest | jq -r '.tag_name')
echo $ghlatestver
set rel $ghlatestver
# gh repo clone $src
git $meth --single-branch -b $rel https://$host.com/$src
case gitlab gl
set gllatestver (curl -s https://gitlab.com/$src/-/releases/permalink/latest | grep -m1 -Eo "releases/[^/]+\"" | awk 'BEGIN { FS="/" } {print $2}' | rev | cut -c2- | rev)
echo $gllatestver
set rel $gllatestver
git $meth --single-branch -b $rel https://$host.com/$src
case "*"
echo "unknown host"
exit
end
set fileslen (yq '.files | length' forkware.yaml)
set maxfiles (math $fileslen - 1)
for i in (seq 0 $maxfiles)
set filecmd .files[$i]
set curline (yq $filecmd.line forkware.yaml | tee file1.tmp)
set curact (yq $filecmd.doit forkware.yaml)
set curcode (yq $filecmd.code forkware.yaml | tee file2.tmp)
set curproj (echo $src | awk 'BEGIN { FS="/" } {print $2}')
set curfile (yq $filecmd.file forkware.yaml)
set curpath (string join '' $curproj "/" $curfile)
./litaf -$curact -f3=$curpath
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment