mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-29 21:31:02 +00:00
refresh repo info on activation
This commit is contained in:
parent
0eb09cf2b1
commit
c3732041d5
2 changed files with 24 additions and 2 deletions
|
@ -23,11 +23,11 @@ type Repo struct {
|
||||||
Branch string `json:"default_branch,omitempty" meddler:"repo_branch"`
|
Branch string `json:"default_branch,omitempty" meddler:"repo_branch"`
|
||||||
Timeout int64 `json:"timeout,omitempty" meddler:"repo_timeout"`
|
Timeout int64 `json:"timeout,omitempty" meddler:"repo_timeout"`
|
||||||
Visibility string `json:"visibility" meddler:"repo_visibility"`
|
Visibility string `json:"visibility" meddler:"repo_visibility"`
|
||||||
IsPrivate bool `json:"private,omitempty" meddler:"repo_private"`
|
IsPrivate bool `json:"private" meddler:"repo_private"`
|
||||||
IsTrusted bool `json:"trusted" meddler:"repo_trusted"`
|
IsTrusted bool `json:"trusted" meddler:"repo_trusted"`
|
||||||
IsStarred bool `json:"starred,omitempty" meddler:"-"`
|
IsStarred bool `json:"starred,omitempty" meddler:"-"`
|
||||||
IsGated bool `json:"gated" meddler:"repo_gated"`
|
IsGated bool `json:"gated" meddler:"repo_gated"`
|
||||||
IsActive bool `json:"active,omitempty" meddler:"repo_active"`
|
IsActive bool `json:"active" meddler:"repo_active"`
|
||||||
AllowPull bool `json:"allow_pr" meddler:"repo_allow_pr"`
|
AllowPull bool `json:"allow_pr" meddler:"repo_allow_pr"`
|
||||||
AllowPush bool `json:"allow_push" meddler:"repo_allow_push"`
|
AllowPush bool `json:"allow_push" meddler:"repo_allow_push"`
|
||||||
AllowDeploy bool `json:"allow_deploys" meddler:"repo_allow_deploys"`
|
AllowDeploy bool `json:"allow_deploys" meddler:"repo_allow_deploys"`
|
||||||
|
@ -38,6 +38,23 @@ type Repo struct {
|
||||||
Perm *Perm `json:"-" meddler:"-"`
|
Perm *Perm `json:"-" meddler:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update updates the repository with values from the given Repo.
|
||||||
|
func (r *Repo) Update(from *Repo) {
|
||||||
|
r.Avatar = from.Avatar
|
||||||
|
r.Link = from.Link
|
||||||
|
r.Kind = from.Kind
|
||||||
|
r.Clone = from.Clone
|
||||||
|
r.Branch = from.Branch
|
||||||
|
if from.IsPrivate != r.IsPrivate {
|
||||||
|
if from.IsPrivate {
|
||||||
|
r.Visibility = VisibilityPrivate
|
||||||
|
} else {
|
||||||
|
r.Visibility = VisibilityPublic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r.IsPrivate = from.IsPrivate
|
||||||
|
}
|
||||||
|
|
||||||
// RepoPatch represents a repository patch object.
|
// RepoPatch represents a repository patch object.
|
||||||
type RepoPatch struct {
|
type RepoPatch struct {
|
||||||
Config *string `json:"config_file,omitempty"`
|
Config *string `json:"config_file,omitempty"`
|
||||||
|
|
|
@ -71,6 +71,11 @@ func PostRepo(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
from, err := remote.Repo(user, repo.Owner, repo.Name)
|
||||||
|
if err == nil {
|
||||||
|
repo.Update(from)
|
||||||
|
}
|
||||||
|
|
||||||
err = store.UpdateRepo(c, repo)
|
err = store.UpdateRepo(c, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(500, err.Error())
|
c.String(500, err.Error())
|
||||||
|
|
Loading…
Reference in a new issue