コード例 #1
0
def set_repo_default_branch(spec, branch):
    request_data = {'id': f'refs/heads/{branch}'}
    return spec, call(
        f'/rest/api/1.0/projects/{spec[0]}/repos/{spec[1]}/branches/default',
        request_data,
        only_response_code=True,
        method='PUT',
    )
コード例 #2
0
 def f(spec):
     project, repo = spec
     try:
         commits = call(f'/rest/api/1.0/projects/{project}'
                        f'/repos/{repo}/commits?limit=1&until={branch}')
         author_timestamp = commits['values'][0]['authorTimestamp']
     except HTTPError:
         # Does not have branch
         author_timestamp = None
     return spec, to_date(author_timestamp) if author_timestamp else None
コード例 #3
0
def set_single_status(build_url, build_state):
    repo, status = build_state
    state = STATUS_SUCCESSFUL if status == Build.SUCCESS else STATUS_FAILED
    commit_id = [b.head for b in repo.branches
                 if b.name == repo.setup_branch][0]
    request_data = {'state': state, 'key': commit_id, 'url': build_url}
    return repo, commit_id, state, build_url, call(
        f'/rest/build-status/1.0/commits/{commit_id}',
        request_data,
        'POST',
        only_response_code=True)
コード例 #4
0
def get_web_hooks(spec):
    return call(get_uri(spec))
コード例 #5
0
def create_web_hook(spec, hook):
    return call(get_uri(spec),
                only_response_code=True,
                method='POST',
                request_data=hook)
コード例 #6
0
def delete_web_hook(spec, hook_id):
    return call(f'{get_uri(spec)}/{hook_id}',
                only_response_code=True,
                method='DELETE')
コード例 #7
0
ファイル: get_repos.py プロジェクト: mattiasl/scripts
def get_repos_page(project, limit, start):
    response = call(f'/rest/api/1.0/projects/{project}'
                    f'/repos?limit={limit}&start={start}')
    return response['size'], response['values'], response[
        'isLastPage'], response.get('nextPageStart', -1)
コード例 #8
0
def get_repo_default_branch(spec):
    return spec, call(
        f'/rest/api/1.0/projects/{spec[0]}/repos/{spec[1]}/branches/default')
コード例 #9
0
ファイル: get_branches.py プロジェクト: mattiasl/scripts
def get_branch_page(spec, branch, limit, start):
    response = call(
        f'/rest/api/1.0/projects/{spec[0]}/repos/{spec[1]}'
        f'/branches?filterText={branch}&limit={limit}&start={start}')
    return response['size'], response['values'], response[
        'isLastPage'], response.get('nextPageStart', -1)
コード例 #10
0
def delete_repo(spec):
    return spec, call(
        f'/rest/api/1.0/projects/{spec[0]}/repos/{spec[1]}',
        method="DELETE",
    )
コード例 #11
0
def enable_repo_web_hook(spec, url):
    uri = f'/rest/api/1.0/projects/{spec[0]}/repos/{spec[1]}' + \
          '/settings/hooks/com.atlassian.stash.plugin.stash-web-post-' + \
          'receive-hooks-plugin:postReceiveHook/enabled'
    request_data = {'hook-url-0': url}
    return spec, call(uri, request_data, 'PUT')
コード例 #12
0
def get_tags_page(spec, tag, limit, start, order_by='MODIFICATION'):
    response = call(
        f'/rest/api/1.0/projects/{spec[0]}/repos/{spec[1]}/tags?'
        f'filterText={tag}&limit={limit}&start={start}&orderBy={order_by}')
    return response['size'], response['values'], response[
        'isLastPage'], response.get('nextPageStart', -1)
コード例 #13
0
def create_repo(project, repo):
    uri = f'/rest/api/1.0/projects/{project}/repos'
    # request_data = f'{{"name":"{repo}","scmId":"git","forkable":true}}'
    request_data = {'name': repo, 'scmId': 'git', 'forkable': True}
    return call(uri, request_data, 'POST')
コード例 #14
0
ファイル: fork_repos.py プロジェクト: mattiasl/scripts
def fork_repo(spec, fork_project):
    uri = f'/rest/api/1.0/projects/{spec[0]}/repos/{spec[1]}'
    request_data = {'slug': spec[1], 'project': {'key': fork_project}}
    return spec, call(uri, request_data, 'POST')