aboutsummaryrefslogtreecommitdiff
path: root/internal/route/repo
diff options
context:
space:
mode:
authorAchilleas Koutsou <achilleas.k@gmail.com>2020-09-03 21:04:22 +0200
committerGitHub <noreply@github.com>2020-09-04 03:04:22 +0800
commitc4360747a3bdd0d5a5a673bfcdee05f9d911ba1e (patch)
tree4c8ca23dc3f449bc946b6c75c0fec8dd928dbb73 /internal/route/repo
parent23ff182d1f8df2978785772bc58cf0ebfd2aeb0c (diff)
repo: support unlisted but publicly accessible repositories (#6176)
Co-authored-by: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>
Diffstat (limited to 'internal/route/repo')
-rw-r--r--internal/route/repo/pull.go1
-rw-r--r--internal/route/repo/repo.go2
-rw-r--r--internal/route/repo/setting.go4
3 files changed, 6 insertions, 1 deletions
diff --git a/internal/route/repo/pull.go b/internal/route/repo/pull.go
index e1778275..05837ca1 100644
--- a/internal/route/repo/pull.go
+++ b/internal/route/repo/pull.go
@@ -60,6 +60,7 @@ func parseBaseRepository(c *context.Context) *db.Repository {
c.Data["repo_name"] = baseRepo.Name
c.Data["description"] = baseRepo.Description
c.Data["IsPrivate"] = baseRepo.IsPrivate
+ c.Data["IsUnlisted"] = baseRepo.IsUnlisted
if err = baseRepo.GetOwner(); err != nil {
c.Error(err, "get owner")
diff --git a/internal/route/repo/repo.go b/internal/route/repo/repo.go
index aa949930..259aba56 100644
--- a/internal/route/repo/repo.go
+++ b/internal/route/repo/repo.go
@@ -126,6 +126,7 @@ func CreatePost(c *context.Context, f form.CreateRepo) {
License: f.License,
Readme: f.Readme,
IsPrivate: f.Private || conf.Repository.ForcePrivate,
+ IsUnlisted: f.Unlisted,
AutoInit: f.AutoInit,
})
if err == nil {
@@ -197,6 +198,7 @@ func MigratePost(c *context.Context, f form.MigrateRepo) {
Name: f.RepoName,
Description: f.Description,
IsPrivate: f.Private || conf.Repository.ForcePrivate,
+ IsUnlisted: f.Unlisted,
IsMirror: f.Mirror,
RemoteAddr: remoteAddr,
})
diff --git a/internal/route/repo/setting.go b/internal/route/repo/setting.go
index df2b7bfa..ee30225d 100644
--- a/internal/route/repo/setting.go
+++ b/internal/route/repo/setting.go
@@ -87,10 +87,12 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
// Visibility of forked repository is forced sync with base repository.
if repo.IsFork {
f.Private = repo.BaseRepo.IsPrivate
+ f.Unlisted = repo.BaseRepo.IsUnlisted
}
- visibilityChanged := repo.IsPrivate != f.Private
+ visibilityChanged := repo.IsPrivate != f.Private || repo.IsUnlisted != f.Unlisted
repo.IsPrivate = f.Private
+ repo.IsUnlisted = f.Unlisted
if err := db.UpdateRepository(repo, visibilityChanged); err != nil {
c.Error(err, "update repository")
return