Created
December 31, 2015 21:21
-
-
Save pimentel/3e276ac6fbf6e72692d7 to your computer and use it in GitHub Desktop.
Remove yourself as a collaborator from many github repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var GithubApi = require("github"); | |
// you can install the required module using `npm install github` | |
var user = "myUsername"; | |
var password = "myPassword"; | |
function filterRepos(item) { | |
var lowerName = item.full_name.toLowerCase(); | |
return item.owner.login !== 'berkeley-stat243' && | |
item.owner.login !== user && | |
lowerName.search(/243/) !== -1; | |
} | |
// customize the code above (the filter function as well as username/password) | |
var github = new GithubApi({ | |
version: "3.0.0", | |
debug: true, | |
protocol: "https" | |
}); | |
var loginResult = github.authenticate({ | |
type: "basic", | |
username: user, | |
password: password | |
}); | |
var repos = github.repos.getAll({ | |
// type: "private", | |
per_page: 100 | |
}, | |
function(error, data) { | |
if (error) { | |
console.error('error: ', error); | |
return; | |
} | |
var newData = data.filter(filterRepos); | |
console.log("found ", newData.length, " results"); | |
newData.forEach(function(item) { | |
console.log('Removing "', user, '" as a collaborator from ', item.full_name); | |
github.repos.removeCollaborator({ | |
user: item.owner.login, | |
repo: item.name, | |
collabuser: user | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment