Edits history of script submission #1574 for ' Update the branching model config for a project (bitbucket)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update the branching model config for a project
     * Update the branching model configuration for a project.
     */
    export async function main(
      auth: Bitbucket,
      project_key: string,
      workspace: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}/branching-model/settings`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 375 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update the branching model config for a project
     * Update the branching model configuration for a project.
     */
    export async function main(
      auth: Bitbucket,
      project_key: string,
      workspace: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}/branching-model/settings`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 935 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update the branching model config for a project
     * Update the branching model configuration for a project.
    
    The `development` branch can be configured to a specific branch or to
    track the main branch. Any branch name can be supplied, but will only
    successfully be applied to a repository via inheritance if that branch
    exists for that repository. Only the passed properties will be updated. The
    properties not passed will be left unchanged. A request without a
    `development` property will leave the development branch unchanged.
    
    The `production` branch can be a specific branch, the main
    branch or disabled. Any branch name can be supplied, but will only
    successfully be applied to a repository via inheritance if that branch
    exists for that repository. The `enabled` property can be used to enable (`true`)
    or disable (`false`) it. Only the passed properties will be updated. The
    properties not passed will be left unchanged. A request without a
    `production` property will leave the production branch unchanged.
    
    The `branch_types` property contains the branch types to be updated.
    Only the branch types passed will be updated. All updates will be
    rejected if it would leave the branching model in an invalid state.
    For branch types this means that:
    
    1. The prefixes for all enabled branch types are valid. For example,
       it is not possible to use '*' inside a Git prefix.
    2. A prefix of an enabled branch type must not be a prefix of another
       enabled branch type. This is to ensure that a branch can be easily
       classified by its prefix unambiguously.
    
    It is possible to store an invalid prefix if that branch type would be
    left disabled. Only the passed properties will be updated. The
    properties not passed will be left unchanged. Each branch type must
    have a `kind` property to identify it.
     */
    export async function main(
      auth: Bitbucket,
      project_key: string,
      workspace: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}/branching-model/settings`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 935 days ago