Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Archive repos #5009

Merged
merged 94 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
16a96f3
Rebased to gitea-master
kolaente Oct 3, 2018
232f71e
Updated gitea/go-sdk
kolaente Oct 5, 2018
fbf39fe
Removed unused setting of status code
kolaente Oct 5, 2018
8655d0e
Added error message if archiving fails
kolaente Oct 5, 2018
6f53048
updated gitea go-sdk
kolaente Oct 5, 2018
b365cd9
Prevent adding/editing/removing of files via web ui when a repo is ar…
kolaente Oct 5, 2018
34c1419
generated swagger
kolaente Oct 5, 2018
a7cc8fa
fmt
kolaente Oct 5, 2018
3877a2d
trigger ci
kolaente Oct 5, 2018
9c366eb
trigger ci
kolaente Oct 5, 2018
4b38053
fixed fmt (make fmt does not work)
kolaente Oct 6, 2018
d94b479
fixed fmt (make fmt does not work)
kolaente Oct 6, 2018
b4fb9cd
Moved check if a repo is archived to appropriate function
kolaente Oct 11, 2018
afa879a
Moved functions to restrict upload/editing of files to a middleware
kolaente Oct 11, 2018
88a916e
Removed deleting repo units to disable issues/pull requests
kolaente Oct 12, 2018
365217a
Fixed lint
kolaente Oct 12, 2018
be792b5
Disabled all possibilities of editing/adding an issue or pull request…
kolaente Oct 12, 2018
0b3a040
Merge branch 'master' into feature/archive-repos
kolaente Oct 12, 2018
88ed10a
Merge branch 'master' into feature/archive-repos
kolaente Oct 13, 2018
5564126
Merge branch 'master' into feature/archive-repos
kolaente Oct 15, 2018
376cb8a
Disabled archiving if the repo is a mirror
kolaente Oct 15, 2018
fa5e308
Merge branch 'master' into feature/archive-repos
kolaente Oct 17, 2018
f522479
Merge branch 'master' into feature/archive-repos
kolaente Oct 17, 2018
ffed84e
Merge branch 'master' into feature/archive-repos
kolaente Oct 17, 2018
3cee9db
Merge branch 'master' into feature/archive-repos
kolaente Oct 18, 2018
badaed3
Merge branch 'master' into feature/archive-repos
kolaente Oct 18, 2018
587c539
Merge branch 'master' into feature/archive-repos
kolaente Oct 20, 2018
4e51555
Refactored the function a repo is archived
kolaente Oct 20, 2018
7e9928b
Merge branch 'master' into feature/archive-repos
kolaente Oct 20, 2018
35168a2
Merge remote-tracking branch 'origin/feature/archive-repos' into feat…
kolaente Oct 20, 2018
e85bde0
Reset to gitea/master
kolaente Oct 23, 2018
3de3a52
Merge branch 'master' into feature/archive-repos
kolaente Oct 25, 2018
8125e5c
Merge remote-tracking branch 'origin/feature/archive-repos' into feat…
kolaente Oct 25, 2018
d7540c3
regenerated css
kolaente Oct 25, 2018
3717807
Made more clear what its doing by renaming the actions
kolaente Oct 25, 2018
33b1100
merge with gitea-master
kolaente Oct 29, 2018
5b6d3ab
Merge branch 'master' into feature/archive-repos
kolaente Oct 31, 2018
4875328
Merge remote-tracking branch 'origin/feature/archive-repos' into feat…
kolaente Nov 1, 2018
4ba0284
Fixed flash message when archiving a repo
kolaente Nov 1, 2018
427a19d
removed uneeded check
kolaente Nov 3, 2018
abc4769
Merge branch 'master' into feature/archive-repos
kolaente Nov 3, 2018
1845c55
Merge branch 'master' into feature/archive-repos
kolaente Nov 4, 2018
1d4743e
Merge branch 'master' into feature/archive-repos
lunny Nov 5, 2018
e6e6514
Merge branch 'master' into feature/archive-repos
kolaente Nov 5, 2018
52c423a
Merge branch 'master' into feature/archive-repos
kolaente Nov 9, 2018
a907901
Merge branch 'master' into feature/archive-repos
kolaente Nov 21, 2018
ea44530
merge with gitea-master
kolaente Nov 22, 2018
35c043b
update css
kolaente Nov 22, 2018
d839ef3
Merge branch 'master' into feature/archive-repos
kolaente Nov 23, 2018
a1cdf69
Merge branch 'master' into feature/archive-repos
kolaente Nov 23, 2018
5a51757
merge with gitea master
kolaente Nov 29, 2018
d6769d9
update css
kolaente Nov 29, 2018
9ac5878
Merge branch 'master' into feature/archive-repos
kolaente Nov 29, 2018
f14bf50
Merge branch 'master' into feature/archive-repos
kolaente Nov 30, 2018
9c02656
Merge branch 'master' into feature/archive-repos
kolaente Dec 2, 2018
9f79370
Merge branch 'master' into feature/archive-repos
kolaente Dec 2, 2018
21a6ee9
Merge branch 'master' into feature/archive-repos
kolaente Dec 3, 2018
f0558ad
Moved check for being able to edit a file to CanEnableEditor()
kolaente Dec 3, 2018
ff9b36d
language improvements
kolaente Dec 3, 2018
e0ba3c3
should disable all reply buttons on pull requests
kolaente Dec 3, 2018
06b57c4
disable wiki
kolaente Dec 3, 2018
3e3ef92
disable new releases
kolaente Dec 3, 2018
5a2d7a0
disabled repo actions
kolaente Dec 3, 2018
b9e4ef2
Merge branch 'master' into feature/archive-repos
kolaente Dec 8, 2018
f56ebf1
merge with master
kolaente Dec 13, 2018
ee1460c
Merge branch 'master' into feature/archive-repos
kolaente Dec 18, 2018
f58ed26
Merge branch 'master' into feature/archive-repos
kolaente Dec 21, 2018
24cc9a6
Merge branch 'master' into feature/archive-repos
kolaente Dec 22, 2018
14f176e
Merge branch 'master' into feature/archive-repos
kolaente Dec 27, 2018
3f3d4bf
Fix issue unwatch button being displayed
kolaente Dec 27, 2018
6f15e7f
Fix labels or milestone page resulting in 500 error
kolaente Dec 27, 2018
39c9cd5
Fixed milestone not viewable
kolaente Dec 27, 2018
de0c4e0
Disabled branch settings
kolaente Dec 27, 2018
5095950
Added archived icon in repo header
kolaente Dec 27, 2018
d40cbde
merge with gitea-master
kolaente Jan 3, 2019
d1f9402
Merge branch 'master' into feature/archive-repos
kolaente Jan 4, 2019
212b21f
Merge branch 'master' into feature/archive-repos
kolaente Jan 6, 2019
36b947b
Add message if a bare repo is archived
kolaente Jan 6, 2019
feb2c74
Disabled new labels from set if a repo is archived
kolaente Jan 6, 2019
dce82f5
Merge branch 'master' into feature/archive-repos
kolaente Jan 7, 2019
a07b36b
Merge branch 'master' into feature/archive-repos
kolaente Jan 8, 2019
dcaefdb
Merge branch 'master' into feature/archive-repos
kolaente Jan 11, 2019
4cf4278
Merge branch 'master' into feature/archive-repos
kolaente Jan 11, 2019
b4de2fe
Merge branch 'master' into feature/archive-repos
kolaente Jan 12, 2019
8af6f25
Merge branch 'master' into feature/archive-repos
kolaente Jan 13, 2019
37977a2
Merge branch 'master' into feature/archive-repos
kolaente Jan 14, 2019
8bb4bb2
Merge branch 'master' into feature/archive-repos
kolaente Jan 14, 2019
c60da13
Merge branch 'master' into feature/archive-repos
kolaente Jan 16, 2019
559b4cf
Merge branch 'master' into feature/archive-repos
kolaente Jan 17, 2019
06b99c9
merge with master
kolaente Jan 20, 2019
280baa5
merge with master
kolaente Jan 22, 2019
0a118f0
Merge branch 'master' into feature/archive-repos
kolaente Jan 22, 2019
71d9305
Fixed wrong order of ignerr
kolaente Jan 22, 2019
746f9a9
merge with gitea-master
kolaente Jan 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ type Repository struct {
NumOpenMilestones int `xorm:"-"`
NumReleases int `xorm:"-"`

IsPrivate bool `xorm:"INDEX"`
IsEmpty bool `xorm:"INDEX"`
IsPrivate bool `xorm:"INDEX"`
IsEmpty bool `xorm:"INDEX"`
IsArchived bool `xorm:"INDEX"`

IsMirror bool `xorm:"INDEX"`
*Mirror `xorm:"-"`
Expand Down Expand Up @@ -292,6 +293,7 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool)
Description: repo.Description,
Private: repo.IsPrivate,
Empty: repo.IsEmpty,
Archived: repo.IsArchived,
Size: int(repo.Size / 1024),
Fork: repo.IsFork,
Parent: parent,
Expand Down Expand Up @@ -2341,6 +2343,13 @@ func CheckRepoStats() {
// ***** END: Repository.NumForks *****
}

// SetArchiveRepoState sets if a repo is archived
func (repo *Repository) SetArchiveRepoState(isArchived bool) (err error) {
repo.IsArchived = isArchived
_, err = x.Where("id = ?", repo.ID).Cols("is_archived").Update(repo)
return
}

// ___________ __
// \_ _____/__________| | __
// | __)/ _ \_ __ \ |/ /
Expand Down
1 change: 1 addition & 0 deletions modules/auth/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ type RepoSettingForm struct {
EnableTimetracker bool
AllowOnlyContributorsToTrackTime bool
EnableIssueDependencies bool
IsArchived bool

// Admin settings
EnableHealthCheck bool
Expand Down
11 changes: 10 additions & 1 deletion modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,23 @@ type Repository struct {

// CanEnableEditor returns true if repository is editable and user has proper access level.
func (r *Repository) CanEnableEditor() bool {
return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanEnableEditor() && r.IsViewBranch
return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanEnableEditor() && r.IsViewBranch && !r.Repository.IsArchived
}

// CanCreateBranch returns true if repository is editable and user has proper access level.
func (r *Repository) CanCreateBranch() bool {
return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanCreateBranch()
}

// RepoMustNotBeArchived checks if a repo is archived
func RepoMustNotBeArchived() macaron.Handler {
return func(ctx *Context) {
if ctx.Repo.Repository.IsArchived {
ctx.NotFound("IsArchived", fmt.Errorf(ctx.Tr("repo.archive.title")))
}
}
}

// CanCommitToBranch returns true if repository is editable and user has proper access level
// and branch is not protected for push
func (r *Repository) CanCommitToBranch(doer *models.User) (bool, error) {
Expand Down
16 changes: 16 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ forks = Forks
pick_reaction = Pick your reaction
reactions_more = and %d more

archive.title = This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
archive.issue.nocomment = This repo is archived. You cannot comment on issues.
archive.pull.nocomment = This repo is archived. You cannot comment on pull requests.

form.reach_limit_of_creation = You have already reached your limit of %d repositories.
form.name_reserved = The repository name '%s' is reserved.
form.name_pattern_not_allowed = The pattern '%s' is not allowed in a repository name.
Expand Down Expand Up @@ -1176,6 +1180,18 @@ settings.choose_branch = Choose a branch…
settings.no_protected_branch = There are no protected branches.
settings.edit_protected_branch = Edit
settings.protected_branch_required_approvals_min = Required approvals cannot be negative.
settings.archive.button = Archive Repo
settings.archive.header = Archive This Repo
settings.archive.text = Archiving the repo will make it entirely read-only. It is hidden from the dashboard, cannot be committed to and no issues or pull-requests can be created.
settings.archive.success = The repo was successfully archived.
settings.archive.error = An error occured while trying to archive the repo. See the log for more details.
settings.archive.error_ismirror = You cannot archive a mirrored repo.
settings.archive.branchsettings_unavailable = Branch settings are not available if the repo is archived.
settings.unarchive.button = Un-Archive Repo
settings.unarchive.header = Un-Archive This Repo
settings.unarchive.text = Un-Archiving the repo will restore its ability to recieve commits and pushes, as well as new issues and pull-requests.
settings.unarchive.success = The repo was successfully un-archived.
settings.unarchive.error = An error occured while trying to un-archive the repo. See the log for more details.

diff.browse_source = Browse Source
diff.parent = parent
Expand Down
2 changes: 1 addition & 1 deletion public/css/index.css

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions public/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,11 @@ footer {
.heatmap-color-5 {
background-color: #2f6b1b;
}

.archived-icon{
color: lighten(#000, 70%) !important;
}

.archived-icon{
color: lighten(#000, 70%) !important;
}
6 changes: 6 additions & 0 deletions routers/repo/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ func HTTP(ctx *context.Context) {
return
}

// Don't allow pushing if the repo is archived
if repo.IsArchived && !isPull {
ctx.HandleText(http.StatusForbidden, "This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.")
kolaente marked this conversation as resolved.
Show resolved Hide resolved
return
}

// Only public pull don't need auth.
isPublicPull := !repo.IsPrivate && isPull
var (
Expand Down
2 changes: 1 addition & 1 deletion routers/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func Releases(ctx *context.Context) {
}

writeAccess := ctx.Repo.CanWrite(models.UnitTypeReleases)
ctx.Data["CanCreateRelease"] = writeAccess
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived

opts := models.FindReleasesOptions{
IncludeDrafts: writeAccess,
Expand Down
41 changes: 41 additions & 0 deletions routers/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,47 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
ctx.Flash.Success(ctx.Tr("repo.settings.wiki_deletion_success"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")

case "archive":
lafriks marked this conversation as resolved.
Show resolved Hide resolved
if !ctx.Repo.IsOwner() {
ctx.Error(403)
return
}

if repo.IsMirror {
ctx.Flash.Error(ctx.Tr("repo.settings.archive.error_ismirror"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
return
}

if err := repo.SetArchiveRepoState(true); err != nil {
log.Error(4, "Tried to archive a repo: %s", err)
ctx.Flash.Error(ctx.Tr("repo.settings.archive.error"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
return
}

ctx.Flash.Success(ctx.Tr("repo.settings.archive.success"))

log.Trace("Repository was archived: %s/%s", ctx.Repo.Owner.Name, repo.Name)
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
case "unarchive":
if !ctx.Repo.IsOwner() {
ctx.Error(403)
return
}

if err := repo.SetArchiveRepoState(false); err != nil {
log.Error(4, "Tried to unarchive a repo: %s", err)
ctx.Flash.Error(ctx.Tr("repo.settings.unarchive.error"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
return
}

ctx.Flash.Success(ctx.Tr("repo.settings.unarchive.success"))

log.Trace("Repository was un-archived: %s/%s", ctx.Repo.Owner.Name, repo.Name)
ctx.Redirect(ctx.Repo.RepoLink + "/settings")

default:
ctx.NotFound("", nil)
}
Expand Down
4 changes: 2 additions & 2 deletions routers/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func renderDirectory(ctx *context.Context, treeLink string) {

// Check permission to add or upload new file.
if ctx.Repo.CanWrite(models.UnitTypeCode) && ctx.Repo.IsViewBranch {
ctx.Data["CanAddFile"] = true
ctx.Data["CanUploadFile"] = setting.Repository.Upload.Enabled
ctx.Data["CanAddFile"] = !ctx.Repo.Repository.IsArchived
ctx.Data["CanUploadFile"] = setting.Repository.Upload.Enabled && !ctx.Repo.Repository.IsArchived
}
}

Expand Down
4 changes: 2 additions & 2 deletions routers/repo/wiki.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, *gi
// Wiki renders single wiki page
func Wiki(ctx *context.Context) {
ctx.Data["PageIsWiki"] = true
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(models.UnitTypeWiki)
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(models.UnitTypeWiki) && !ctx.Repo.Repository.IsArchived

if !ctx.Repo.Repository.HasWiki() {
ctx.Data["Title"] = ctx.Tr("repo.wiki")
Expand Down Expand Up @@ -246,7 +246,7 @@ func WikiPages(ctx *context.Context) {

ctx.Data["Title"] = ctx.Tr("repo.wiki.pages")
ctx.Data["PageIsWiki"] = true
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(models.UnitTypeWiki)
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(models.UnitTypeWiki) && !ctx.Repo.Repository.IsArchived

wikiRepo, commit, err := findWikiRepoCommit(ctx)
if err != nil {
Expand Down
34 changes: 17 additions & 17 deletions routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/branches", func() {
m.Combo("").Get(repo.ProtectedBranch).Post(repo.ProtectedBranchPost)
m.Combo("/*").Get(repo.SettingsProtectedBranch).
Post(bindIgnErr(auth.ProtectBranchForm{}), repo.SettingsProtectedBranchPost)
Post(bindIgnErr(auth.ProtectBranchForm{}), context.RepoMustNotBeArchived(), repo.SettingsProtectedBranchPost)
}, repo.MustBeNotEmpty)

m.Group("/hooks", func() {
Expand Down Expand Up @@ -530,13 +530,13 @@ func RegisterRoutes(m *macaron.Macaron) {
})
}, reqSignIn, context.RepoAssignment(), reqRepoAdmin, context.UnitTypes(), context.RepoRef())

m.Get("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), repo.Action)
m.Get("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.RepoMustNotBeArchived(), repo.Action)

m.Group("/:username/:reponame", func() {
m.Group("/issues", func() {
m.Combo("/new").Get(context.RepoRef(), repo.NewIssue).
Post(bindIgnErr(auth.CreateIssueForm{}), repo.NewIssuePost)
}, reqRepoIssueReader)
}, context.RepoMustNotBeArchived(), reqRepoIssueReader)
// FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest.
// So they can apply their own enable/disable logic on routers.
m.Group("/issues", func() {
Expand All @@ -557,32 +557,32 @@ func RegisterRoutes(m *macaron.Macaron) {
})
})
m.Post("/reactions/:action", bindIgnErr(auth.ReactionForm{}), repo.ChangeIssueReaction)
})
}, context.RepoMustNotBeArchived())

m.Post("/labels", reqRepoIssuesOrPullsWriter, repo.UpdateIssueLabel)
m.Post("/milestone", reqRepoIssuesOrPullsWriter, repo.UpdateIssueMilestone)
m.Post("/assignee", reqRepoIssuesOrPullsWriter, repo.UpdateIssueAssignee)
m.Post("/status", reqRepoIssuesOrPullsWriter, repo.UpdateIssueStatus)
})
}, context.RepoMustNotBeArchived())
m.Group("/comments/:id", func() {
m.Post("", repo.UpdateCommentContent)
m.Post("/delete", repo.DeleteComment)
m.Post("/reactions/:action", bindIgnErr(auth.ReactionForm{}), repo.ChangeCommentReaction)
})
}, context.RepoMustNotBeArchived())
m.Group("/labels", func() {
m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel)
m.Post("/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel)
m.Post("/delete", repo.DeleteLabel)
m.Post("/initialize", bindIgnErr(auth.InitializeLabelsForm{}), repo.InitializeLabels)
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
}, context.RepoMustNotBeArchived(), reqRepoIssuesOrPullsWriter, context.RepoRef())
m.Group("/milestones", func() {
m.Combo("/new").Get(repo.NewMilestone).
Post(bindIgnErr(auth.CreateMilestoneForm{}), repo.NewMilestonePost)
m.Get("/:id/edit", repo.EditMilestone)
m.Post("/:id/edit", bindIgnErr(auth.CreateMilestoneForm{}), repo.EditMilestonePost)
m.Get("/:id/:action", repo.ChangeMilestonStatus)
m.Post("/delete", repo.DeleteMilestone)
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
}, context.RepoMustNotBeArchived(), reqRepoIssuesOrPullsWriter, context.RepoRef())
m.Group("/milestone", func() {
m.Get("/:id", repo.MilestoneIssuesAndPulls)
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
Expand All @@ -607,7 +607,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/upload-file", repo.UploadFileToServer)
m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
}, context.RepoRef(), repo.MustBeEditable, repo.MustBeAbleToUpload)
}, reqRepoCodeWriter, repo.MustBeNotEmpty)
}, context.RepoMustNotBeArchived(), reqRepoCodeWriter, repo.MustBeNotEmpty)

m.Group("/branches", func() {
m.Group("/_new/", func() {
Expand All @@ -617,7 +617,7 @@ func RegisterRoutes(m *macaron.Macaron) {
}, bindIgnErr(auth.NewBranchForm{}))
m.Post("/delete", repo.DeleteBranchPost)
m.Post("/restore", repo.RestoreBranchPost)
}, reqRepoCodeWriter, repo.MustBeNotEmpty)
}, context.RepoMustNotBeArchived(), reqRepoCodeWriter, repo.MustBeNotEmpty)

}, reqSignIn, context.RepoAssignment(), context.UnitTypes())

Expand All @@ -630,11 +630,11 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/new", repo.NewRelease)
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
m.Post("/delete", repo.DeleteRelease)
}, reqSignIn, repo.MustBeNotEmpty, reqRepoReleaseWriter, context.RepoRef())
}, reqSignIn, repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, context.RepoRef())
m.Group("/releases", func() {
m.Get("/edit/*", repo.EditRelease)
m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
}, reqSignIn, repo.MustBeNotEmpty, reqRepoReleaseWriter, func(ctx *context.Context) {
}, reqSignIn, repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, func(ctx *context.Context) {
var err error
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
if err != nil {
Expand All @@ -652,7 +652,7 @@ func RegisterRoutes(m *macaron.Macaron) {

m.Group("/:username/:reponame", func() {
m.Post("/topics", repo.TopicsPost)
}, context.RepoAssignment(), reqRepoAdmin)
}, context.RepoMustNotBeArchived(), context.RepoAssignment(), reqRepoAdmin)

m.Group("/:username/:reponame", func() {
m.Group("", func() {
Expand All @@ -672,7 +672,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Combo("/:page/_edit").Get(repo.EditWiki).
Post(bindIgnErr(auth.NewWikiForm{}), repo.EditWikiPost)
m.Post("/:page/delete", repo.DeleteWikiPagePost)
}, reqSignIn, reqRepoWikiWriter)
}, context.RepoMustNotBeArchived(), reqSignIn, reqRepoWikiWriter)
}, repo.MustEnableWiki, context.RepoRef())

m.Group("/wiki", func() {
Expand All @@ -694,14 +694,14 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get(".diff", repo.DownloadPullDiff)
m.Get(".patch", repo.DownloadPullPatch)
m.Get("/commits", context.RepoRef(), repo.ViewPullCommits)
m.Post("/merge", reqRepoPullsWriter, bindIgnErr(auth.MergePullRequestForm{}), repo.MergePullRequest)
m.Post("/cleanup", context.RepoRef(), repo.CleanUpPullRequest)
m.Post("/merge", context.RepoMustNotBeArchived(), reqRepoPullsWriter, bindIgnErr(auth.MergePullRequestForm{}), repo.MergePullRequest)
m.Post("/cleanup", context.RepoMustNotBeArchived(), context.RepoRef(), repo.CleanUpPullRequest)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, this will delete the branch on the head repository not the base repository. For example. there are some pull requests merged but not clean up on the base repository, but then it's archived. Then should user delete head repository's branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean we should still enable the possiblity to still clean it when its archived?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, need more discuss.

m.Group("/files", func() {
m.Get("", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.ViewPullFiles)
m.Group("/reviews", func() {
m.Post("/comments", bindIgnErr(auth.CodeCommentForm{}), repo.CreateCodeComment)
m.Post("/submit", bindIgnErr(auth.SubmitReviewForm{}), repo.SubmitReview)
})
}, context.RepoMustNotBeArchived())
})
}, repo.MustAllowPulls)

Expand Down
5 changes: 4 additions & 1 deletion templates/explore/repo_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
{{range .Repos}}
<div class="item">
<div class="ui header">
<a class="name" href="{{.Link}}">{{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}}</a>
<a class="name" href="{{.Link}}">
{{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}}
{{if .IsArchived}}<i class="archive icon archived-icon"></i>{{end}}
</a>
{{if .IsPrivate}}
<span class="text gold"><i class="octicon octicon-lock"></i></span>
{{else if .IsFork}}
Expand Down
Loading