├── COPYING ├── README.md └── tcispy.py /COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tcispy 2 | 3 | Pull author and committer names and emails from Travis-CI. 4 | 5 | # Dependencies 6 | 7 | A personal access token is needed from GitHub to use the Travis-CI API, even for public repositories. Create a token by editing your profile -> Personal Access Tokens, and select the following scopes: 8 | 9 | * repo:status 10 | * repo_deployment 11 | * read:org 12 | * write:repo_hook 13 | * user:email 14 | 15 | The [travispy](https://github.com/menegazzo/travispy) module is used to interface with the Travis-CI API. Using virtual environments is suggested. 16 | 17 | ``` 18 | mkvirtualenv travispy # only needed if keeping your evironment sane 19 | pip install travispy 20 | ``` 21 | 22 | # Usage 23 | 24 | ``` 25 | python ./tcispy.py 26 | ``` 27 | 28 | An example run looks like: 29 | 30 | ``` 31 | python ./tcispy.py rapid7/nexpose-client d84dda6de6244eb5c30d3ef3eeda957d390a4ee7 32 | ``` 33 | -------------------------------------------------------------------------------- /tcispy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ----------------------------------------------------------- 3 | # tcispy.py 4 | # 5 | # Pull author and committer names and emails from travis-ci. 6 | # 7 | # Usage: 8 | # mkvirtualenv travispy 9 | # pip install travispy 10 | # python ./tcispy.py 11 | # 12 | # Example: 13 | # python ./tcispy.py rapid7/nexpose-client d84dda6de6244eb5c30d3ef3eeda957d390a4ee7 2>/dev/null 14 | # ----------------------------------------------------------- 15 | 16 | from sys import argv, exit 17 | from travispy import TravisPy 18 | 19 | 20 | def main(): 21 | 22 | # ----------------------------------------------------------- 23 | # quick sanity check for args 24 | # ----------------------------------------------------------- 25 | if len(argv) != 3: 26 | print 'Insufficient arguments.' 27 | print 'Usage: {} '.format(argv[0]) 28 | print 'Example: {} rapid7/nexpose-client d84dda6de6244eb5c30d3ef3eeda957d390a4ee7'.format(argv[0]) 29 | exit(1) 30 | 31 | 32 | # ----------------------------------------------------------- 33 | # generate a token on github with the following access: 34 | # repo:status 35 | # repo_deployment 36 | # read:org 37 | # write:repo_hook 38 | # user:email 39 | # 40 | # populate the github_token variable with the resulting token 41 | # ----------------------------------------------------------- 42 | target_repo = argv[1] 43 | github_token = argv[2] 44 | 45 | 46 | # ----------------------------------------------------------- 47 | # minimal client setup 48 | # ----------------------------------------------------------- 49 | t = TravisPy.github_auth(github_token) 50 | builds = t.builds(slug=target_repo) 51 | 52 | 53 | # ----------------------------------------------------------- 54 | # append users as a tuple (name, email). some users have 55 | # multiple email addresses, and we want everything 56 | # ----------------------------------------------------------- 57 | users = [] 58 | for b in builds: 59 | try: 60 | build = t.build(b.id) 61 | 62 | except AttributeError: 63 | pass 64 | 65 | users.append((build.commit.author_name, build.commit.author_email)) 66 | users.append((build.commit.committer_name, build.commit.committer_email)) 67 | 68 | 69 | # ----------------------------------------------------------- 70 | # trim the collection to unique tuples 71 | # ----------------------------------------------------------- 72 | unique = list(set(users)) 73 | 74 | 75 | # ----------------------------------------------------------- 76 | # aaaaaaaaaaaand dump 77 | # ----------------------------------------------------------- 78 | print 'Name,Email' 79 | for u in unique: 80 | print '{},{}'.format(u[0], u[1]) 81 | 82 | 83 | # ----------------------------------------------------------- 84 | # make it do the thing 85 | # ----------------------------------------------------------- 86 | if __name__ == '__main__': 87 | main() 88 | --------------------------------------------------------------------------------