repo repair should update private status
This commit is contained in:
parent
47c1caa7cd
commit
cf549e47c3
1 changed files with 39 additions and 2 deletions
|
@ -217,6 +217,22 @@ func RepairRepo(c *gin.Context) {
|
|||
c.String(500, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
from, err := remote.Repo(user, repo.Owner, repo.Name)
|
||||
if err == nil {
|
||||
repo.Name = from.Name
|
||||
repo.Owner = from.Owner
|
||||
repo.FullName = from.FullName
|
||||
repo.Avatar = from.Avatar
|
||||
repo.Link = from.Link
|
||||
repo.Clone = from.Clone
|
||||
repo.IsPrivate = from.IsPrivate
|
||||
if repo.IsPrivate != from.IsPrivate {
|
||||
repo.ResetVisibility()
|
||||
}
|
||||
store.UpdateRepo(c, repo)
|
||||
}
|
||||
|
||||
c.Writer.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
|
@ -265,6 +281,27 @@ func MoveRepo(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
RepairRepo(c)
|
||||
}
|
||||
// creates the jwt token used to verify the repository
|
||||
t := token.New(token.HookToken, repo.FullName)
|
||||
sig, err := t.Sign(repo.Hash)
|
||||
if err != nil {
|
||||
c.String(500, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// reconstruct the link
|
||||
host := httputil.GetURL(c.Request)
|
||||
link := fmt.Sprintf(
|
||||
"%s/hook?access_token=%s",
|
||||
host,
|
||||
sig,
|
||||
)
|
||||
|
||||
remote.Deactivate(user, repo, host)
|
||||
err = remote.Activate(user, repo, link)
|
||||
if err != nil {
|
||||
c.String(500, err.Error())
|
||||
return
|
||||
}
|
||||
c.Writer.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue