Skip to content

Fix the wrong HTTP response status code for duplicate packages #27480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 10, 2023
Merged
48 changes: 24 additions & 24 deletions docs/content/usage/packages/alpine.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ menu:
sidebar_position: 4
identifier: "alpine"
---

# Alpine Package Registry

Publish [Alpine](https://pkgs.alpinelinux.org/) packages for your user or organization.
Expand All @@ -30,11 +29,11 @@ To register the Alpine registry add the url to the list of known apk sources (`/
https://gitea.example.com/api/packages/{owner}/alpine/<branch>/<repository>
```

| Placeholder | Description |
| ------------ | ----------- |
| Placeholder | Description |
| -------------- | -------------------------- |
| `owner` | The owner of the packages. |
| `branch` | The branch to use. |
| `repository` | The repository to use. |
| `branch` | The branch to use. |
| `repository` | The repository to use. |

If the registry is private, provide credentials in the url. You can use a password or a [personal access token](development/api-usage.md#authentication):

Expand Down Expand Up @@ -62,11 +61,11 @@ To publish an Alpine package (`*.apk`), perform a HTTP `PUT` operation with the
PUT https://gitea.example.com/api/packages/{owner}/alpine/{branch}/{repository}
```

| Parameter | Description |
| ------------ | ----------- |
| `owner` | The owner of the package. |
| `branch` | The branch may match the release version of the OS, ex: `v3.17`. |
| `repository` | The repository can be used [to group packages](https://wiki.alpinelinux.org/wiki/Repositories) or just `main` or similar. |
| Parameter | Description |
| -------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `owner` | The owner of the package. |
| `branch` | The branch may match the release version of the OS, ex:`v3.17`. |
| `repository` | The repository can be used[to group packages](https://wiki.alpinelinux.org/wiki/Repositories) or just `main` or similar. |

Example request using HTTP Basic authentication:

Expand All @@ -77,14 +76,15 @@ curl --user your_username:your_password_or_token \
```

If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
You cannot publish a file with the same name twice to a package. You must delete the existing package file first.

You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.

The server responds with the following HTTP Status codes.

| HTTP Status Code | Meaning |
| ----------------- | ------- |
| `201 Created` | The package has been published. |
| `400 Bad Request` | The package name, version, branch, repository or architecture are invalid. |
| HTTP Status Code | Meaning |
| ------------------- | ------------------------------------------------------------------------------------ |
| `201 Created` | The package has been published. |
| `400 Bad Request` | The package is invalid. |
| `409 Conflict` | A package file with the same combination of parameters exist already in the package. |

## Delete a package
Expand All @@ -95,13 +95,13 @@ To delete an Alpine package perform a HTTP `DELETE` operation. This will delete
DELETE https://gitea.example.com/api/packages/{owner}/alpine/{branch}/{repository}/{architecture}/{filename}
```

| Parameter | Description |
| -------------- | ----------- |
| Parameter | Description |
| ---------------- | ------------------------- |
| `owner` | The owner of the package. |
| `branch` | The branch to use. |
| `repository` | The repository to use. |
| `branch` | The branch to use. |
| `repository` | The repository to use. |
| `architecture` | The package architecture. |
| `filename` | The file to delete.
| `filename` | The file to delete. |

Example request using HTTP Basic authentication:

Expand All @@ -112,10 +112,10 @@ curl --user your_username:your_token_or_password -X DELETE \

The server responds with the following HTTP Status codes.

| HTTP Status Code | Meaning |
| ----------------- | ------- |
| `204 No Content` | Success |
| `404 Not Found` | The package or file was not found. |
| HTTP Status Code | Meaning |
| ------------------ | ---------------------------------- |
| `204 No Content` | Success |
| `404 Not Found` | The package or file was not found. |

## Install a package

Expand Down
17 changes: 8 additions & 9 deletions docs/content/usage/packages/cargo.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ menu:
sidebar_position: 5
identifier: "cargo"
---

# Cargo Package Registry

Publish [Cargo](https://doc.rust-lang.org/stable/cargo/) packages for your user or organization.
Expand Down Expand Up @@ -57,9 +56,9 @@ index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse
# git-fetch-with-cli = true
```

| Parameter | Description |
| --------- | ----------- |
| `owner` | The owner of the package. |
| Parameter | Description |
| --------- | ------------------------- |
| `owner` | The owner of the package. |

If the registry is private or you want to publish new packages, you have to configure your credentials.
Add the credentials section to the credentials file located in the current users home directory (for example `~/.cargo/credentials.toml`):
Expand All @@ -69,9 +68,9 @@ Add the credentials section to the credentials file located in the current users
token = "Bearer {token}"
```

| Parameter | Description |
| --------- | ----------- |
| `token` | Your [personal access token](development/api-usage.md#authentication) |
| Parameter | Description |
| --------- | ----------------------------------------------------------------- |
| `token` | Your[personal access token](development/api-usage.md#authentication) |

## Git vs Sparse

Expand All @@ -97,8 +96,8 @@ To install a package from the package registry, execute the following command:
cargo add {package_name}
```

| Parameter | Description |
| -------------- | ----------- |
| Parameter | Description |
| ---------------- | ----------------- |
| `package_name` | The package name. |

## Supported commands
Expand Down
23 changes: 11 additions & 12 deletions docs/content/usage/packages/chef.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ menu:
sidebar_position: 5
identifier: "chef"
---

# Chef Package Registry

Publish [Chef](https://chef.io/) cookbooks for your user or organization.
Expand All @@ -36,9 +35,9 @@ To [configure `knife`](https://docs.chef.io/workstation/knife_setup/) to use the
knife[:supermarket_site] = 'https://gitea.example.com/api/packages/{owner}/chef'
```

| Parameter | Description |
| --------- | ----------- |
| `owner` | The owner of the package. |
| Parameter | Description |
| --------- | ------------------------- |
| `owner` | The owner of the package. |

## Publish a package

Expand All @@ -48,8 +47,8 @@ To publish a Chef package execute the following command:
knife supermarket share {package_name}
```

| Parameter | Description |
| -------------- | ----------- |
| Parameter | Description |
| ---------------- | ----------------- |
| `package_name` | The package name. |

You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
Expand All @@ -68,9 +67,9 @@ Optional you can specify the package version:
knife supermarket install {package_name} {package_version}
```

| Parameter | Description |
| ----------------- | ----------- |
| `package_name` | The package name. |
| Parameter | Description |
| ------------------- | -------------------- |
| `package_name` | The package name. |
| `package_version` | The package version. |

## Delete a package
Expand All @@ -87,7 +86,7 @@ Optional you can specify the package version:
knife supermarket unshare {package_name}/versions/{package_version}
```

| Parameter | Description |
| ----------------- | ----------- |
| `package_name` | The package name. |
| Parameter | Description |
| ------------------- | -------------------- |
| `package_name` | The package name. |
| `package_version` | The package version. |
32 changes: 16 additions & 16 deletions docs/content/usage/packages/composer.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ menu:
sidebar_position: 10
identifier: "composer"
---

# Composer Package Registry

Publish [Composer](https://getcomposer.org/) packages for your user or organization.
Expand All @@ -25,15 +24,14 @@ To work with the Composer package registry, you can use [Composer](https://getco

To publish a Composer package perform a HTTP PUT operation with the package content in the request body.
The package content must be the zipped PHP project with the `composer.json` file.
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.

```
PUT https://gitea.example.com/api/packages/{owner}/composer
```

| Parameter | Description |
| ---------- | ----------- |
| `owner` | The owner of the package. |
| Parameter | Description |
| --------- | ------------------------- |
| `owner` | The owner of the package. |

If the `composer.json` file does not contain a `version` property, you must provide it as a query parameter:

Expand All @@ -58,13 +56,15 @@ curl --user your_username:your_password_or_token \
```

If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.

The server responds with the following HTTP Status codes.

| HTTP Status Code | Meaning |
| ----------------- | ------- |
| `201 Created` | The package has been published. |
| `400 Bad Request` | The package name and/or version are invalid or a package with the same name and version already exist. |
| HTTP Status Code | Meaning |
| ------------------- | ---------------------------------------------------------------------- |
| `201 Created` | The package has been published. |
| `400 Bad Request` | The package is invalid. |
| `409 Conflict` | A package file with the same combination of parameters exists already. |

## Configuring the package registry

Expand Down Expand Up @@ -93,10 +93,10 @@ To access the package registry using credentials, you must specify them in the `
}
```

| Parameter | Description |
| ---------- | ----------- |
| `owner` | The owner of the package. |
| `username` | Your Gitea username. |
| Parameter | Description |
| ------------ | ----------------------------------------------- |
| `owner` | The owner of the package. |
| `username` | Your Gitea username. |
| `password` | Your Gitea password or a personal access token. |

## Install a package
Expand All @@ -113,7 +113,7 @@ Optional you can specify the package version:
composer require {package_name}:{package_version}
```

| Parameter | Description |
| ----------------- | ----------- |
| `package_name` | The package name. |
| Parameter | Description |
| ------------------- | -------------------- |
| `package_name` | The package name. |
| `package_version` | The package version. |
31 changes: 16 additions & 15 deletions docs/content/usage/packages/conan.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ menu:
sidebar_position: 20
identifier: "conan"
---

# Conan Package Registry

Publish [Conan](https://conan.io/) packages for your user or organization.
Expand All @@ -30,12 +29,12 @@ conan remote add {remote} https://gitea.example.com/api/packages/{owner}/conan
conan user --remote {remote} --password {password} {username}
```

| Parameter | Description |
| -----------| ----------- |
| `remote` | The remote name. |
| `username` | Your Gitea username. |
| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. |
| `owner` | The owner of the package. |
| Parameter | Description |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `remote` | The remote name. |
| `username` | Your Gitea username. |
| `password` | Your Gitea password. If you are using 2FA or OAuth use a[personal access token](development/api-usage.md#authentication) instead of the password. |
| `owner` | The owner of the package. |

For example:

Expand All @@ -52,17 +51,19 @@ Publish a Conan package by running the following command:
conan upload --remote={remote} {recipe}
```

| Parameter | Description |
| ----------| ----------- |
| `remote` | The remote name. |
| `recipe` | The recipe to upload. |
| Parameter | Description |
| ---------- | --------------------- |
| `remote` | The remote name. |
| `recipe` | The recipe to upload. |

For example:

```shell
conan upload --remote=gitea ConanPackage/1.2@gitea/final
```

You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.

The Gitea Conan package registry has full [revision](https://docs.conan.io/en/latest/versioning/revisions.html) support.

## Install a package
Expand All @@ -73,10 +74,10 @@ To install a Conan package from the package registry, execute the following comm
conan install --remote={remote} {recipe}
```

| Parameter | Description |
| ----------| ----------- |
| `remote` | The remote name. |
| `recipe` | The recipe to download. |
| Parameter | Description |
| ---------- | ----------------------- |
| `remote` | The remote name. |
| `recipe` | The recipe to download. |

For example:

Expand Down
9 changes: 9 additions & 0 deletions docs/content/usage/packages/conda.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@ curl --user your_username:your_password_or_token \
https://gitea.example.com/api/packages/testuser/conda/package-1.0.conda
```

If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.

The server responds with the following HTTP Status codes.

| HTTP Status Code | Meaning |
| ----------------- | ------- |
| `201 Created` | The package has been published. |
| `400 Bad Request` | The package is invalid. |
| `409 Conflict` | A package file with the same combination of parameters exists already. |

## Install a package

To install a package from the package registry, execute one of the following commands:
Expand Down
Loading