Get Repo Branch

Script gitlab

by paulwekhophi ยท 6/6/2022

  • Submitted by lplit Deno
    Created 1333 days ago
    1
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    2
    /*
    3
    @param: {wmill.Resource<"gitlab">} glab - Resource containing Gitlab Auth API Key
    4
    Example:
    5
    {
    6
      auth: gitlab_api_key,
    7
      baseUrl: "https://www.gitlab.com"
    8
    }
    9
    */
    10
    export async function main(
    11
      glab: wmill.Resource<"gitlab">,
    12
      projectId: string,
    13
      branchName: string
    14
    ) {
    15
      const url = `${glab.baseUrl}/api/v4/projects/${projectId}/repository/branches/${branchName}`;
    16
      const issue = await fetch(`${url}`, {
    17
        headers: {
    18
          "Authorization": `Bearer: ${glab.token}`,
    19
          "Content-Type": "application/json",
    20
        }
    21
      });
    22
      return await issue.json();
    23
    }
    24