Skip to content

Commit

Permalink
Merge branch 'release/3.2.0' into new-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hudgston committed Feb 25, 2020
2 parents b905269 + 0d64a0b commit 16f67fc
Show file tree
Hide file tree
Showing 30 changed files with 539 additions and 204 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: python

python:
- "3.5"

install: "pip install -r requirements.txt"
- 3.5
install:
- pip install -e .
# command to run tests
script: nosetests -w ./tests/unit

script:
- pytest
notifications:
email: false
5 changes: 4 additions & 1 deletion cirrus.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = cirrus-cli
version = 3.1.2
version = 3.2.0
description = cirrus development and build git extensions
organization = cloudant
version_file = src/cirrus/__init__.py
Expand All @@ -12,6 +12,9 @@ master_branch = new-master
release_branch_prefix = release/
feature_branch_prefix = feature/

[github]
api_base = https://api.github.com

[commands]
cirrus = cirrus.delegate:main
hello = cirrus.hello:main
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
argparse==1.2.1
arrow==0.4.2
Fabric==2.4.0
GitPython==2.1.9
GitPython==3.1.0
pep8==1.5.7
pylint==1.3.0
pytest
requests==2.3.0
requests==2.22.0
PyChef==0.2.3
keyring==8.5.1
virtualenv
pluggage
dockerstache>=0.0.9
requests-toolbelt==0.6.2
tox
wheel
wheel
2 changes: 1 addition & 1 deletion src/cirrus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
__version__="3.1.2"
__version__="3.2.0"

10 changes: 6 additions & 4 deletions src/cirrus/cirrus_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import json
import getpass
import requests
from urllib.parse import urljoin

from argparse import ArgumentParser

from cirrus.configuration import load_setup_configuration, get_creds_plugin
from cirrus.configuration import load_setup_configuration, get_github_api_base
from cirrus.logger import get_logger

LOGGER = get_logger()
GITHUB_AUTH_URL = "https://api.github.com/authorizations"


def ask_question(question, default=None, valid=None):
Expand Down Expand Up @@ -67,13 +67,15 @@ def create_github_token():
requests for things like pull requests
"""
authz_url = urljoin(get_github_api_base(), '/authorizations')

oauth_note = "cirrus script"
user = ask_question(
'what is your github username?',
default=os.environ['USER']
)
passwd = getpass.getpass('what is your github password?')
resp = requests.get(GITHUB_AUTH_URL, auth=(user, passwd))
resp = requests.get(authz_url, auth=(user, passwd))
resp.raise_for_status()
apps = resp.json()
matched_app = None
Expand All @@ -87,7 +89,7 @@ def create_github_token():
# need to create a new token
LOGGER.info("Creating a new Token for github access...")
resp = requests.post(
GITHUB_AUTH_URL,
authz_url,
auth=(user, passwd),
data=json.dumps(
{"scopes": ["gist", "repo"], "note": oauth_note}
Expand Down
21 changes: 20 additions & 1 deletion src/cirrus/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
import os
from cirrus.gitconfig import load_gitconfig
from cirrus.environment import repo_directory
import subprocess
from cirrus.logger import get_logger
import configparser
import pluggage.registry
import subprocess

LOGGER = get_logger()


def get_creds_plugin(plugin_name):
Expand Down Expand Up @@ -337,3 +340,19 @@ def get_chef_auth():
'chef_client_user': chef['chef-client-user'],
'chef_client_keyfile': chef['chef-client-keyfile']
}


def get_github_api_base():
"""
Return the github.api_base URL, or https://api.github.ibm.com if not
configured.
"""
try:
url = load_configuration()['github']['api_base'].rstrip('/')
except KeyError:
url = 'https://api.github.ibm.com'
LOGGER.info(
"Failed to load api_base from github config section. "
"Using default: {}".format(url)
)
return url
Loading

0 comments on commit 16f67fc

Please sign in to comment.