Skip to content

Commit

Permalink
Merge pull request #171 from slaclab/gh_token
Browse files Browse the repository at this point in the history
Allow user to store github token in their environment
  • Loading branch information
ruck314 authored Mar 9, 2020
2 parents 5f3c4bd + 5b6c1f9 commit a2f3e2f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
17 changes: 12 additions & 5 deletions releaseGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,19 @@ def pushRelease(cfg, relName, relData, ver, tagAttach, prev):

print("\nLogging into github....\n")

if args.token is None:
print("Enter your github token. If you do no have one you can generate it here:");
print(" https://github.com/settings/tokens");
token = input("\nGithub token: ");
else:
if args.token is not None:
print("Using github token from command line arg.")
token = args.token
else:
token = os.environ.get('GITHUB_TOKEN')

if token is None:
print("Enter your github token. If you do no have one you can generate it here:");
print(" https://github.com/settings/tokens");
print("You may set it in your environment as GITHUB_TOKEN")
token = input("\nGithub token: ");
else:
print("Using github token from user's environment.")

gh = github.Github(token)
remRepo = gh.get_repo(f'slaclab/{project}')
Expand Down
13 changes: 12 additions & 1 deletion releaseNotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def getReleaseNotes(locRepo, remRepo, tagRange, noSort=False):
import pyperclip
from getpass import getpass
import re
import os

import git # https://gitpython.readthedocs.io/en/stable/tutorial.html
from github import Github # https://pygithub.readthedocs.io/en/latest/introduction.html
Expand Down Expand Up @@ -174,7 +175,17 @@ def getReleaseNotes(locRepo, remRepo, tagRange, noSort=False):
project = re.compile(r'slaclab/(?P<name>.*?).git').search(url).group('name')

# Connect to the Git server
token = input("Enter your github token: ")
token = os.environ.get('GITHUB_TOKEN')

if token is None:
print("Enter your github token. If you do no have one you can generate it here:");
print(" https://github.com/settings/tokens");
print("You may set it in your environment as GITHUB_TOKEN")
token = input("\nGithub token: ");

else:
print("Using github token from user's environment.")

github = Github(token)

# Get the repo information
Expand Down

0 comments on commit a2f3e2f

Please sign in to comment.