0a0a01a56fb50ec81631df370357362eeddbe6e3 — Drew DeVault 3 months ago 7aa971b 0.13.1
Use internal authorization for builds.sr.ht submit
M dispatchsrht/builds.py => dispatchsrht/builds.py +4 -7
@@ 44,8 44,7 @@ def decrypt_notify_payload(payload):
def submit_build(
        build_tag: str,
        manifests: Iterable[Tuple[str, Manifest]],
        oauth_token: str,
        username: str,
        note: str=None,
        secrets: bool=False,
        preparing: Callable[[str], Any]=None,

@@ 56,7 55,7 @@ def submit_build(

    @build_tag:      Build tag for this set of manifests, usually a repo name
    @manifests:      List of build manifests to submit and their names
    @oauth_token:    The user's builds.sr.ht-authorized OAuth token
    @user:           The dispatch.sr.ht user record submitting the build
    @note:           Note to add to build submission, e.g. commit message
    @secrets:        Whether to enable secrets for this build
    @preparing:      A callable called when each manifest is being prepared

@@ 77,14 76,12 @@ def submit_build(
            "tags": [build_tag] + ([name] if name else []),
            "note": note,
            "secrets": secrets,
        }, headers={
            "Authorization": "token " + oauth_token,
        }, headers=get_authorization(user))
        if resp.status_code != 200:
            return resp.text
        build_id = resp.json()["id"]
        build_url = "{}/~{}/job/{}".format(
                _builds_sr_ht, username, build_id)
                _builds_sr_ht, user.username, build_id)
        build_urls.append((name, build_url))
        if submitted:
            submitted(name, build_id)

M dispatchsrht/tasks/github/common.py => dispatchsrht/tasks/github/common.py +1 -2
@@ 199,8 199,7 @@ def submit_github_build(hook, repo, commit, base=None,

    urls = submit_build(repo.name, manifests,
            hook.user.oauth_token, hook.user.username,
            note=note, secrets=secrets,
            hook.user, note=note, secrets=secrets,
            submitted=update_submitted(base_commit, auth.user.username))
    if isinstance(urls, str):

M dispatchsrht/tasks/gitlab/common.py => dispatchsrht/tasks/gitlab/common.py +1 -2
@@ 213,8 213,7 @@ def submit_gitlab_build(auth, hook, project, commit,

    return submit_build(project.attributes['name'], manifests,
            hook.user.oauth_token, hook.user.username,
            note=note, secrets=hook.secrets,
            hook.user, note=note, secrets=hook.secrets,
            submitted=update_submitted(commit, auth.user.username))