Completed
Push — init ( d7a185...725ed7 )
by Michael
07:47
created

index_repository()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
1
import os
2
import click
0 ignored issues
show
Configuration introduced by
The import click could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
3
from ..models import GitRepository
4
5
6
7
def _echo(message, **kwargs):
8
    click.echo(click.style(
9
        message,
10
        **kwargs
11
    ))
12
13
14
def info(message):
15
    _echo(
16
        message,
17
        fg='green',
18
        bold=True
19
    )
20
21
22
def note(message):
23
    _echo(
24
        message,
25
        fg='blue',
26
        bold=True
27
    )
28
29
30
def init():
31
    """
32
    Detects, prompts and initialises the project.
33
    """
34
    info('Indexing repository...')
35
    repository = GitRepository()
36
37
    info('Looking for github auth token in the environment...')
38
    auth_token = os.environ.get('GITHUB_AUTH_TOKEN')
39
40
    if not auth_token:
41
        info('No auth token found, asking for it...')
42
        note('You need a GitHub token for changes to create a release.')
43
        click.pause('Press [enter] to launch the GitHub "New personal access '
44
                    'token" page, to create a token for changes.')
45
        click.launch('https://github.com/settings/tokens/new')
46
        auth_token = click.prompt('Enter your changes token')
47
        repository.auth_token = auth_token
48
49
    info('Fetching pull requests...')
50
51
    return repository
52