1
0
Fork 0
mirror of https://github.com/Luzifer/github-masswatch.git synced 2024-12-22 19:11:17 +00:00

Bugfix: Unwatch was not working

This commit is contained in:
Knut Ahlers 2015-06-02 19:53:37 +02:00
parent cc710435cb
commit b27e1c9aaa
2 changed files with 25 additions and 15 deletions

View file

@ -17,6 +17,17 @@ This project is a small helper for mass-watching / unwatching in GitHub reposito
# bundle install # bundle install
[...] [...]
# ruby watch.rb help
Commands:
watch.rb help [COMMAND] # Describe available commands or one specific command
watch.rb list <regex> # lists all repos, useful to test your watch regex
watch.rb unwatch <regex> # unwatch all repos matching your regex
watch.rb watch <regex> # watch all repos matching your regex
watch.rb watched <regex> # show all watched repos, useful to test your unwatch regex
Options:
[--token=TOKEN]
# ruby watch.rb list --token=<mytoken> # ruby watch.rb list --token=<mytoken>
Luzifer/alarmclock Luzifer/alarmclock
Luzifer/alfred-fold Luzifer/alfred-fold
@ -25,14 +36,11 @@ Luzifer/AMZWishlist
Luzifer/awsenv Luzifer/awsenv
[...] [...]
# ruby watch.rb watch '^Luzifer/.*' --token=<mytoken> # ruby watch.rb list '^Luzifer/alfred-.*' --token=<mytoken>
Subscribing to Luzifer/blog.knut.me... Luzifer/alfred-fold
Subscribing to Luzifer/go-selfupdate... Luzifer/alfred-pwdgen
Subscribing to Luzifer/golang-builder...
Subscribing to Luzifer/habitrpg... # ruby watch.rb watch '^Luzifer/alfred-.*' --token=<mytoken>
Subscribing to Luzifer/homebrew... Subscribing to Luzifer/alfred-fold...
Subscribing to Luzifer/homebrew-tools... Subscribing to Luzifer/alfred-pwdgen...
Subscribing to Luzifer/license...
Subscribing to Luzifer/radiopi...
Subscribing to Luzifer/simpleproxy...
``` ```

View file

@ -26,7 +26,7 @@ class WatchCLI < Thor
get_repos().each do |repo| get_repos().each do |repo|
if !subscriptions.include?(repo.full_name) and /#{regex}/.match(repo.full_name) if !subscriptions.include?(repo.full_name) and /#{regex}/.match(repo.full_name)
puts "Subscribing to #{repo.full_name}..." puts "Subscribing to #{repo.full_name}..."
get_octokit().update_subscription(repo.full_name, {subscribed: true}) get_octokit().update_subscription(repo.full_name, {subscribed: true})
end end
end end
end end
@ -35,8 +35,10 @@ class WatchCLI < Thor
def unwatch(regex) def unwatch(regex)
subscriptions = get_subscriptions() subscriptions = get_subscriptions()
get_repos().each do |repo| get_repos().each do |repo|
puts "Unsubscribing from #{repo.full_name}..." if subscriptions.include?(repo.full_name) and /#{regex}/.match(repo.full_name)
get_octokit().update_subscription(repo.full_name, {subscribed: false}) if subscriptions.include?(repo.full_name) and /#{regex}/.match(repo.full_name) puts "Unsubscribing from #{repo.full_name}..."
get_octokit().delete_subscription(repo.full_name)
end
end end
end end
@ -53,9 +55,9 @@ class WatchCLI < Thor
def get_repos def get_repos
client = get_octokit client = get_octokit
repos = client.repositories(client.user.login) repos = client.repositories(client.user.login)
orgs = client.organizations() orgs = client.organizations()
orgs.each do |org| orgs.each do |org|
client.organization_repositories(org.login).each do |repo| client.organization_repositories(org.login).each do |repo|