Skip to content

Instantly share code, notes, and snippets.

@reasonset
Last active April 20, 2021 14:44
Show Gist options
  • Save reasonset/12df69e12b765f01067fae2b8770bb7a to your computer and use it in GitHub Desktop.
Save reasonset/12df69e12b765f01067fae2b8770bb7a to your computer and use it in GitHub Desktop.
#!/bin/bash
function build_repoliststr {
ruby -ryaml -e 'print YAML.load(ARGF).map {|i| i.join(":::") }.join("%%%")' $HOME/.config/reasonset/workrepos.yaml
}
export repoliststr="$(build_repoliststr)"
function splitrepos {
echo $repoliststr | sed 's:%%%:\n:g'
}
export -f splitrepos
repolist=($(splitrepos))
function getchanges {
(
cd $(getpath $1)
echo -n "2:"
hg status | perl -pe 's/\n/\\n/'
)
}
export -f getchanges
function commit {
(
cd $(getpath $1)
declare commitmsg="$2"
if [[ -z $commitmsg ]]
then
commitmsg="Working snapshot from widget."
fi
echo -n "2:"
if hg commit -A -m "$commitmsg"
then
echo COMMITED.
fi
) | perl -pe 's/\n/\\n/'
}
export -f commit
function getpath {
declare -A repoaa
for i in $(splitrepos)
do
declare -a r=(${i/:::/ })
repoaa[${r[0]}]="${r[1]}"
done
echo ${repoaa[$1]}
}
export -f getpath
repos="$(for i in ${repolist[*]}
do
declare repoentry=(${i/:::/ })
(
cd ${repoentry[1]}
if [[ -n "$(hg status)" ]]
then
echo ${repoentry[0]}
fi
)
done | perl -pe 's/\n/!/' | sed 's/!$//' )"
if [[ -z $repos ]]
then
exit
fi
yad --width=1000 --height=500 --form --field='Repositories:CB' "$repos" --field="Changes:TXT" "" --field="CHECK:FBTN" '@bash -c "getchanges %1"' --field="Commit Message:CE" "" --field="COMMIT:FBTN" '@bash -c "commit %1 %4"' > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment