Edits history of script submission #1516 for ' Update a commit application property (bitbucket)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a commit application property
     * Update an application property value stored against a commit.
     */
    export async function main(
      auth: Bitbucket,
      workspace: string,
      repo_slug: string,
      commit: string,
      app_key: string,
      property_name: string,
      body: { _attributes?: ("public" | "read_only")[]; [k: string]: unknown }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/properties/${app_key}/${property_name}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 374 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a commit application property
     * Update an application property value stored against a commit.
     */
    export async function main(
      auth: Bitbucket,
      workspace: string,
      repo_slug: string,
      commit: string,
      app_key: string,
      property_name: string,
      body: { _attributes?: ("public" | "read_only")[]; [k: string]: unknown }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/properties/${app_key}/${property_name}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 880 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a commit application property
     * Update an [application property](/cloud/bitbucket/application-properties/) value stored against a commit.
     */
    export async function main(
      auth: Bitbucket,
      workspace: string,
      repo_slug: string,
      commit: string,
      app_key: string,
      property_name: string,
      body: { _attributes?: ("public" | "read_only")[]; [k: string]: unknown }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/properties/${app_key}/${property_name}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 935 days ago