Branch

A Branch represents a branch in a version control Repository.

Note

Forward slash characters in :repository_id must be encoded with %2F

Attributes

id

A name of the branch, e.g. master.

  • Type: string

uuid

A universally unique identifier.

  • Type: string

commit

The latest commit in the branch

  • Type: string

protected

An indicator of whether the branch is protected or not. Protected branches cannot be deleted, cannot be pushed with force, and only Project Admin can push to them. Currently branches can be protected only within Git repositories.

  • Type: boolean

Operations

GET /projects/:project_id/repositories/:repository_id/branches

Returns the branches in a repository, with optional limit and offset, as a metadata-results object.

Example Request

curl -X GET \
  -H "Accept: application/vnd.hth.v1" \
  -H "Authorization: hth.company_key='$COMPANY_KEY',account_key='$ACCOUNT_KEY'" \
  https://helixteamhub.cloud/api/projects/luotsi/repositories/chef/branches

Example Response

{
  "metadata": {
    "more_results": false,
    "next_offset": 3,
    "count": 3
  },
  "results": [
    {
      "api_status": 200,
      "api_timestamp": "2016-03-18T14:33:33Z",
      "id": "develop",
      "uuid": "46943352-03c3-42f8-807f-e378e98e878c-develop",
      "commit": "ad527b07d4618bad64368ad507d0d193c4387d99",
      "protected": false,
      "repository": {
        "id": "chef",
        "uuid": "46943352-03c3-42f8-807f-e378e98e878c"
      }
    },
    {
      "api_status": 200,
      "api_timestamp": "2016-03-18T14:33:33Z",
      "id": "master",
      "uuid": "46943352-03c3-42f8-807f-e378e98e878c-master",
      "commit": "eadca9ff750e9e504f94e72b702423c399641098",
      "protected": true,
      "repository": {
        "id": "chef",
        "uuid": "46943352-03c3-42f8-807f-e378e98e878c"
      }
    },
    {
      "api_status": 200,
      "api_timestamp": "2016-03-18T14:33:33Z",
      "id": "production",
      "uuid": "46943352-03c3-42f8-807f-e378e98e878c-production",
      "commit": "063f8954ef1a8d997fde9eee93651914ea6b1e75",
      "protected": true,
      "repository": {
        "id": "chef",
        "uuid": "46943352-03c3-42f8-807f-e378e98e878c"
      }
    }
  ]
}

GET /projects/:project_id/repositories/:repository_id/branches/:id

Returns a specific branch.

Example Request

curl -X GET \
  -H "Accept: application/vnd.hth.v1" \
  -H "Authorization: hth.company_key='$COMPANY_KEY',account_key='$ACCOUNT_KEY'" \
  https://helixteamhub.cloud/api/projects/luotsi/repositories/chef/branches/master

Example Response

{
  "api_status": 200,
  "api_timestamp": "2016-03-18T14:35:57Z",
  "id": "master",
  "uuid": "46943352-03c3-42f8-807f-e378e98e878c-master",
  "commit": "eadca9ff750e9e504f94e72b702423c399641098",
  "protected": true,
  "repository": {
    "id": "chef",
    "uuid": "46943352-03c3-42f8-807f-e378e98e878c"
  }
}

POST /projects/:project_id/repositories/:repository_id/branches

Creates a new branch to the company and returns the created branch object.

Example Request

curl -X POST \
  -H "Accept: application/vnd.hth.v1" \
  -H "Authorization: hth.company_key='$COMPANY_KEY',account_key='$ACCOUNT_KEY'" \
  -H "Content-Type: application/json" \
  -d '{ "id": "production", "commit": "063f8954ef1a8d997fde9eee93651914ea6b1e75", "protected": true }' \
  https://helixteamhub.cloud/api/projects/luotsi/repositories/chef/branches

Example Response

{
  "api_status": 201,
  "api_timestamp": "2016-03-18T14:30:50Z",
  "id": "production",
  "uuid": "46943352-03c3-42f8-807f-e378e98e878c-production",
  "commit": "063f8954ef1a8d997fde9eee93651914ea6b1e75",
  "protected": true,
  "repository": {
    "id": "chef",
    "uuid": "46943352-03c3-42f8-807f-e378e98e878c"
  }
}

PUT /projects/:project_id/repositories/:repository_id/branches/:id

Updates the branch protection attribute. Only Project Admins are allowed to change branch protection.

Example Request

curl -X PUT \
  -H "Content-Type: application/json" \
  -H "Accept: application/vnd.hth.v1" \
  -H "Authorization: hth.company_key='$COMPANY_KEY',account_key='$ACCOUNT_KEY'" \
  -d '{ "protected": false }'
  https://helixteamhub.cloud/api/projects/luotsi/repositories/chef/branches/production

Example Response

{
  "api_status": 200,
  "api_timestamp": "2016-03-18T15:53:05Z",
  "id": "production",
  "uuid": "46943352-03c3-42f8-807f-e378e98e878c-production",
  "commit": "063f8954ef1a8d997fde9eee93651914ea6b1e75",
  "protected": false,
  "repository": {
    "id": "chef",
    "uuid": "46943352-03c3-42f8-807f-e378e98e878c"
  }
}

DELETE /projects/:project_id/repositories/:repository_id/branches/:id

Deletes a branch. Returns the deleted branch.

Example Request

curl -X DELETE \
  -H "Accept: application/vnd.hth.v1" \
  -H "Authorization: hth.company_key='$COMPANY_KEY',account_key='$ACCOUNT_KEY'" \
  https://helixteamhub.cloud/api/projects/luotsi/repositories/chef/branches/production

Example Response

{
  "api_status": 200,
  "api_timestamp": "2016-03-18T15:53:36Z",
  "id": "production",
  "uuid": "46943352-03c3-42f8-807f-e378e98e878c-production",
  "commit": "063f8954ef1a8d997fde9eee93651914ea6b1e75",
  "protected": false,
  "repository": {
    "id": "chef",
    "uuid": "46943352-03c3-42f8-807f-e378e98e878c"
  }
}