mirror of
https://github.com/captainark/github2email.git
synced 2024-11-25 09:31:42 +01:00
first try at implementing delete from r2e when project unstarred
This commit is contained in:
parent
b5ec9eda3b
commit
0e2541de76
@ -4,6 +4,8 @@
|
||||
|
||||
Github2eMail is a bash script that parses the GitHub API for projects you've starred and adds them to your rss2email configuration.
|
||||
|
||||
The script will also delete projects it has added to your rss2email configuration if you're not starring them on GitHub anymore.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- [curl](https://github.com/curl/curl)
|
||||
@ -23,7 +25,3 @@ Run the script.
|
||||
You're done !
|
||||
|
||||
You can also run the script periodically from cron if you want.
|
||||
|
||||
## TODO
|
||||
|
||||
Remove projects that were added by the script and are no longer starred by the user on GitHub from rss2email configuration.
|
||||
|
@ -10,7 +10,7 @@ if [[ -z ${UserName} ]] || [[ $UserName == "changemeplease" ]]; then
|
||||
fi
|
||||
|
||||
GitHubApi="https://api.github.com/users/${UserName}/starred"
|
||||
LastPage="$(curl -I ${GitHubApi} | grep -Eo 'page=[[:digit:]]+' | tail -n1)"
|
||||
LastPage="$(curl -sI ${GitHubApi} | grep -Eo 'page=[[:digit:]]+' | tail -n1)"
|
||||
TempFile=$(mktemp -t github2email.sh.XXXXXXXXXX)
|
||||
|
||||
# Checking for dependencies
|
||||
@ -38,11 +38,22 @@ for Star in $(cat ${TempFile}); do
|
||||
# Only add a project to r2e config if it does not already exist
|
||||
IsDeclaredProject="$(r2e list | grep ${ProjectUrl})"
|
||||
if [[ -z ${IsDeclaredProject} ]]; then
|
||||
r2e add ${ProjectName} ${ProjectUrl}
|
||||
r2e add g2e_${ProjectName} ${ProjectUrl}
|
||||
# We only want to be informed of future releases
|
||||
r2e run --no-send ${ProjectName}
|
||||
r2e run --no-send g2e_${ProjectName}
|
||||
echo "Project ${ProjectName} has been added to rss2email configuration !"
|
||||
fi
|
||||
done
|
||||
|
||||
# Delete projects that were added to rss2email by this script but are no longer starred on GitHub
|
||||
AddedProjects="$(r2e list | grep g2e_ | grep -Eo "https://github.com/.*/releases.atom")"
|
||||
for Projects in ${AddedProjects}; do
|
||||
StillStaredProject="$(grep ${Projects} ${TempFile})"
|
||||
if [[ -z $StillStaredProject ]]; then
|
||||
ProjectToRemove=${StillStaredProject%,*}
|
||||
r2e delete ${ProjectToRemove}
|
||||
echo "Project ${ProjectName} has been removed from rss2email configuration !"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -f ${TempFile} ]] && rm ${TempFile}
|
||||
|
Loading…
Reference in New Issue
Block a user