mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 08:21:11 +00:00 
			
		
		
		
	add sparse url in cargo package guide (#26937)
Hello, The current package guide for cargo gives you only the git index, with the HTTP Index stabilized being used as default for crates.io and being better for most use-cases. However, it's not documented that gitea supports the sparse spec, and it does not require the _crates-index git repo for the sparse api. I personally think we should push users to use the sparse instead of the git repository. (Even let users disable crates-index repos if they only want to use sparse)
This commit is contained in:
		
					parent
					
						
							
								aaeec2a392
							
						
					
				
			
			
				commit
				
					
						e6a059a3d0
					
				
			
		
					 3 changed files with 14 additions and 5 deletions
				
			
		| 
						 | 
					@ -50,10 +50,11 @@ Add the following text to the configuration file located in the current users ho
 | 
				
			||||||
default = "gitea"
 | 
					default = "gitea"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[registries.gitea]
 | 
					[registries.gitea]
 | 
				
			||||||
index = "https://gitea.example.com/{owner}/_cargo-index.git"
 | 
					index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse index
 | 
				
			||||||
 | 
					# index = "https://gitea.example.com/{owner}/_cargo-index.git" # Git
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[net]
 | 
					# [net]
 | 
				
			||||||
git-fetch-with-cli = true
 | 
					# git-fetch-with-cli = true
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| Parameter | Description |
 | 
					| Parameter | Description |
 | 
				
			||||||
| 
						 | 
					@ -72,6 +73,12 @@ token = "Bearer {token}"
 | 
				
			||||||
| --------- | ----------- |
 | 
					| --------- | ----------- |
 | 
				
			||||||
| `token`   | Your [personal access token](development/api-usage.md#authentication) |
 | 
					| `token`   | Your [personal access token](development/api-usage.md#authentication) |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Git vs Sparse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Currently, cargo supports two ways for fetching crates in a registry: Git index & sparse index.
 | 
				
			||||||
 | 
					Sparse index is the newest method and offers better performance when updating crates compared to git.
 | 
				
			||||||
 | 
					Since Rust 1.68, sparse is the default method for crates.io.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Publish a package
 | 
					## Publish a package
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Publish a package by running the following command in your project:
 | 
					Publish a package by running the following command in your project:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,7 +50,8 @@ Cargo 将可用软件包的信息存储在一个存储在 git 仓库中的软件
 | 
				
			||||||
default = "gitea"
 | 
					default = "gitea"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[registries.gitea]
 | 
					[registries.gitea]
 | 
				
			||||||
index = "https://gitea.example.com/{owner}/_cargo-index.git"
 | 
					index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse index
 | 
				
			||||||
 | 
					# index = "https://gitea.example.com/{owner}/_cargo-index.git" # Git
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[net]
 | 
					[net]
 | 
				
			||||||
git-fetch-with-cli = true
 | 
					git-fetch-with-cli = true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,8 @@
 | 
				
			||||||
default = "gitea"
 | 
					default = "gitea"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[registries.gitea]
 | 
					[registries.gitea]
 | 
				
			||||||
index = "<gitea-origin-url data-url="{{AppSubUrl}}/{{.PackageDescriptor.Owner.Name}}/_cargo-index.git"></gitea-origin-url>"
 | 
					index = "<gitea-origin-url data-url="sparse+{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/cargo/"></gitea-origin-url>" # Sparse index
 | 
				
			||||||
 | 
					# index = "<gitea-origin-url data-url="{{AppSubUrl}}/{{.PackageDescriptor.Owner.Name}}/_cargo-index.git"></gitea-origin-url>" # Git
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[net]
 | 
					[net]
 | 
				
			||||||
git-fetch-with-cli = true</code></pre></div>
 | 
					git-fetch-with-cli = true</code></pre></div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue