├── README ├── flipcollaborator.js └── lswatchers.js /README: -------------------------------------------------------------------------------- 1 | Did you know that adding a Github user as a collaborator makes them 2 | watch the repository even if you remove her/him afterwards? Credits 3 | for discovering this go to http://github.com/dodo 4 | -------------------------------------------------------------------------------- /flipcollaborator.js: -------------------------------------------------------------------------------- 1 | var github = require('github'); 2 | var step = require('step'); 3 | 4 | var login = process.argv[2]; 5 | var apiToken = process.argv[3];; 6 | var user = process.argv[4]; 7 | var repo = process.argv[5]; 8 | var collaborators = process.argv.slice(6); 9 | if (!user || !repo || !user || !repo) { 10 | console.error("Usage: " + process.argv[0] + " " + process.argv[1] + " [collaborators...]"); 11 | process.exit(1); 12 | } 13 | 14 | var api = new github.GitHubApi(false, null, true); 15 | api.getRequest().setOption('http_port', 80); 16 | api.authenticateToken(login, apiToken); 17 | 18 | 19 | var repoApi = api.getRepoApi(); 20 | repoApi.addCollaborator = function(user, repo, collaborator, callback) { 21 | this.$api.post('repos/collaborators/' + user + '/' + repo + '/add/' + collaborator, 22 | {}, null, this.$createListener(callback, 'collaborators')); 23 | }; 24 | repoApi.rmCollaborator = function(user, repo, collaborator, callback) { 25 | this.$api.post('repos/collaborators/' + user + '/' + repo + '/remove/' + collaborator, 26 | {}, null, this.$createListener(callback, 'collaborators')); 27 | }; 28 | 29 | function takeNext() { 30 | if (collaborators.length < 1) { 31 | return; 32 | } else { 33 | var collaborator = collaborators.pop(); 34 | repoApi.addCollaborator(user, repo, collaborator, function(err) { 35 | console.log('+ ' + collaborator); 36 | repoApi.rmCollaborator(user, repo, collaborator, function(err) { 37 | console.log('- ' + collaborator); 38 | process.nextTick(takeNext); 39 | }); 40 | }); 41 | } 42 | } 43 | 44 | for(var i = 0; i < 4; i++) 45 | takeNext(); 46 | -------------------------------------------------------------------------------- /lswatchers.js: -------------------------------------------------------------------------------- 1 | var github = require('github'); 2 | 3 | var user = process.argv[2]; 4 | var repo = process.argv[3]; 5 | if (!user || !repo) { 6 | console.error("Usage: " + process.argv[0] + " " + process.argv[1] + " "); 7 | process.exit(1); 8 | } 9 | 10 | var api = new github.GitHubApi(false, null, true); 11 | var oldGetRequest = api.getRequest; 12 | api.getRequest = function() { 13 | var req = oldGetRequest.apply(this, arguments); 14 | req.configure({ http_port: 80 }); 15 | return req; 16 | }; 17 | api.getRepoApi().getRepoWatchers(user, repo, function(err, watchers) { 18 | if (err) { 19 | console.error(err); 20 | } else if (watchers) { 21 | console.info(watchers.join(' ')); 22 | } 23 | }); 24 | --------------------------------------------------------------------------------