1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-06-30 22:13:45 +02:00

Access repos by their ids (#1691)

closes #1295 
closes #648

# TODO
- [x] add new routes with `:repoID`
- [x] load repo in middleware using `:repoID` if present
- [x] update UI routes `:owner/:name` to `:repoID`
- [x] load repos using id in UI
- [x] add lookup endpoint `:owner/:name` to `:repoID`
- [x] redirect `:owner/:name` to `:repoID` in UI
- [x] use badge with `:repoID` route in UI
- [x] update `woodpecker-go`
- [x] check cli
- [x] add migrations / deprecation notes
- [x] check if #648 got solved directly
- [x] Test
  - [x] create repo
  - [x] repo pages
  - [x] ui redirects
  - [x] forge status links
This commit is contained in:
Anbraten
2023-06-12 16:07:52 -07:00
committed by GitHub
parent e3593cd9a4
commit ff01a9ff1d
98 changed files with 1402 additions and 1676 deletions

View File

@ -39,13 +39,12 @@ import (
// CreatePipeline
//
// @Summary Run/trigger a pipelines
// @Router /repos/{owner}/{name}/pipelines [post]
// @Router /repos/{repo_id}/pipelines [post]
// @Produce json
// @Success 200 {object} Pipeline
// @Tags Pipelines
// @Tags Pipelines
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param repo_id path int true "the repository id"
// @Param options body PipelineOptions true "the options for the pipeline to run"
func CreatePipeline(c *gin.Context) {
_store := store.FromContext(c)
@ -97,15 +96,14 @@ func createTmpPipeline(event model.WebhookEvent, commitSHA string, repo *model.R
// GetPipelines
//
// @Summary Get pipelines, current running and past ones
// @Router /repos/{owner}/{name}/pipelines [get]
// @Router /repos/{repo_id}/pipelines [get]
// @Produce json
// @Success 200 {array} Pipeline
// @Tags Pipelines
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param repo_id path int true "the repository id"
// @Param page query int false "for response pagination, page offset number" default(1)
// @Param perPage query int false "for response pagination, max items per page" default(50)
// @Param perPage query int false "for response pagination, max items per page" default(50)
func GetPipelines(c *gin.Context) {
repo := session.Repo(c)
@ -124,14 +122,13 @@ func GetPipelines(c *gin.Context) {
// GetPipeline
//
// @Summary Pipeline information by number
// @Router /repos/{owner}/{name}/pipelines/{number} [get]
// @Router /repos/{repo_id}/pipelines/{number} [get]
// @Produce json
// @Success 200 {object} Pipeline
// @Tags Pipelines
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param number path int true "the number of the pipeline, OR 'latest'"
// @Param repo_id path int true "the repository id"
// @Param number path int true "the number of the pipeline, OR 'latest'"
func GetPipeline(c *gin.Context) {
_store := store.FromContext(c)
if c.Param("number") == "latest" {
@ -190,13 +187,12 @@ func GetPipelineLast(c *gin.Context) {
// GetStepLogs
//
// @Summary Log information
// @Router /repos/{owner}/{name}/logs/{number}/{stepID} [get]
// @Router /repos/{repo_id}/logs/{number}/{stepID} [get]
// @Produce json
// @Success 200 {array} LogEntry
// @Tags Pipeline logs
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param repo_id path int true "the repository id"
// @Param number path int true "the number of the pipeline"
// @Param stepID path int true "the step id"
func GetStepLogs(c *gin.Context) {
@ -247,13 +243,12 @@ func GetStepLogs(c *gin.Context) {
// GetPipelineConfig
//
// @Summary Pipeline configuration
// @Router /repos/{owner}/{name}/pipelines/{number}/config [get]
// @Router /repos/{repo_id}/pipelines/{number}/config [get]
// @Produce json
// @Success 200 {array} Config
// @Tags Pipelines
// @Tags Pipelines
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param repo_id path int true "the repository id"
// @Param number path int true "the number of the pipeline"
func GetPipelineConfig(c *gin.Context) {
_store := store.FromContext(c)
@ -282,13 +277,12 @@ func GetPipelineConfig(c *gin.Context) {
// CancelPipeline
//
// @Summary Cancels a pipeline
// @Router /repos/{owner}/{name}/pipelines/{number}/cancel [post]
// @Router /repos/{repo_id}/pipelines/{number}/cancel [post]
// @Produce plain
// @Success 200
// @Tags Pipelines
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param repo_id path int true "the repository id"
// @Param number path int true "the number of the pipeline"
func CancelPipeline(c *gin.Context) {
_store := store.FromContext(c)
@ -312,13 +306,12 @@ func CancelPipeline(c *gin.Context) {
// PostApproval
//
// @Summary Start pipelines in gated repos
// @Router /repos/{owner}/{name}/pipelines/{number}/approve [post]
// @Router /repos/{repo_id}/pipelines/{number}/approve [post]
// @Produce json
// @Success 200 {object} Pipeline
// @Tags Pipelines
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param repo_id path int true "the repository id"
// @Param number path int true "the number of the pipeline"
func PostApproval(c *gin.Context) {
var (
@ -345,13 +338,12 @@ func PostApproval(c *gin.Context) {
// PostDecline
//
// @Summary Decline pipelines in gated repos
// @Router /repos/{owner}/{name}/pipelines/{number}/decline [post]
// @Router /repos/{repo_id}/pipelines/{number}/decline [post]
// @Produce json
// @Success 200 {object} Pipeline
// @Tags Pipelines
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param repo_id path int true "the repository id"
// @Param number path int true "the number of the pipeline"
func PostDecline(c *gin.Context) {
var (
@ -396,7 +388,7 @@ func GetPipelineQueue(c *gin.Context) {
//
// @Summary Restart a pipeline
// @Description Restarts a pipeline optional with altered event, deploy or environment
// @Router /repos/{owner}/{name}/pipelines/{number} [post]
// @Router /repos/{repo_id}/pipelines/{number} [post]
// @Produce json
// @Success 200 {object} Pipeline
// @Tags Pipelines
@ -478,13 +470,12 @@ func PostPipeline(c *gin.Context) {
// DeletePipelineLogs
//
// @Summary Deletes log
// @Router /repos/{owner}/{name}/logs/{number} [post]
// @Router /repos/{repo_id}/logs/{number} [post]
// @Produce plain
// @Success 200
// @Tags Pipeline logs
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
// @Param owner path string true "the repository owner's name"
// @Param name path string true "the repository name"
// @Param repo_id path int true "the repository id"
// @Param number path int true "the number of the pipeline"
func DeletePipelineLogs(c *gin.Context) {
_store := store.FromContext(c)