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 1 commit
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
36 changes: 34 additions & 2 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ type Repository struct {
NumOpenMilestones int `xorm:"-"`
NumReleases int `xorm:"-"`

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

IsMirror bool `xorm:"INDEX"`
*Mirror `xorm:"-"`
Expand Down Expand Up @@ -290,6 +291,7 @@ func (repo *Repository) innerAPIFormat(mode AccessMode, isParent bool) *api.Repo
FullName: repo.FullName(),
Description: repo.Description,
Private: repo.IsPrivate,
Archived: repo.IsArchived,
Empty: repo.IsBare,
Size: int(repo.Size / 1024),
Fork: repo.IsFork,
Expand Down Expand Up @@ -2389,6 +2391,36 @@ func CheckRepoStats() {
// ***** END: Repository.NumForks *****
}

// ToggleArchiveRepo changes the status if a repo is archived or not
kolaente marked this conversation as resolved.
Show resolved Hide resolved
func (repo *Repository) ToggleArchiveRepo() (err error) {
repo.IsArchived = !repo.IsArchived
_, err = x.Where("id = ?", repo.ID).Cols("is_archived").Update(repo)

// Enable/Disable issues and pull requests
if repo.IsArchived {
if _, err = x.
kolaente marked this conversation as resolved.
Show resolved Hide resolved
Where("repo_id = ? AND (type = ? OR type = ?)", repo.ID, UnitTypeIssues, UnitTypePullRequests).
Delete(new(RepoUnit)); err != nil {
return err
}
} else {
var units []RepoUnit
units = append(units, RepoUnit{
RepoID: repo.ID,
Type: UnitTypeIssues,
})
units = append(units, RepoUnit{
RepoID: repo.ID,
Type: UnitTypePullRequests,
})

if _, err = x.Insert(units); err != nil {
return err
}
}
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 @@ -116,6 +116,7 @@ type RepoSettingForm struct {
EnableTimetracker bool
AllowOnlyContributorsToTrackTime bool
EnableIssueDependencies bool
IsArchived bool

// Admin settings
EnableHealthCheck bool
Expand Down
10 changes: 10 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ 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.

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 @@ -1150,6 +1152,14 @@ settings.default_branch_desc = Select a default repository branch for pull reque
settings.choose_branch = Choose a branch…
settings.no_protected_branch = There are no protected branches.
settings.edit_protected_branch = Edit
settings.archive.button = Archive repo
kolaente marked this conversation as resolved.
Show resolved Hide resolved
settings.archive.header = Archive this repo
kolaente marked this conversation as resolved.
Show resolved Hide resolved
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.unarchive.button = Un-Archive repo
kolaente marked this conversation as resolved.
Show resolved Hide resolved
settings.unarchive.header = Un-Archive this repo
kolaente marked this conversation as resolved.
Show resolved Hide resolved
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.

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.

4 changes: 4 additions & 0 deletions public/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,7 @@ footer {
border-bottom-width: 0 !important;
margin-bottom: 2px !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 @@ -71,6 +71,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
21 changes: 21 additions & 0 deletions routers/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,27 @@ 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 err := repo.ToggleArchiveRepo(); err != nil {
log.Error(4, "Tried to archive a repo: %s", err)
ctx.Error(500)
Copy link
Member

Choose a reason for hiding this comment

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

This will be ignored since ctx.Redirect will use a 3XX HTTP code.

ctx.Redirect(ctx.Repo.RepoLink + "/settings")
return
}

log.Trace("Repository was archived: %s/%s", ctx.Repo.Owner.Name, repo.Name)

if repo.IsArchived {
ctx.Flash.Success(ctx.Tr("repo.settings.archive.success"))
} else {
ctx.Flash.Success(ctx.Tr("repo.settings.unarchive.success"))
}
ctx.Redirect(ctx.Repo.RepoLink + "/settings")

default:
ctx.NotFound("", nil)
}
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
5 changes: 5 additions & 0 deletions templates/repo/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<span id="count_prompt">{{.i18n.Tr "repo.topic.count_prompt"}}</span>
<span id="format_prompt">{{.i18n.Tr "repo.topic.format_prompt"}}</span>
</div>
{{if .Repository.IsArchived}}
<div class="ui warning message">
{{.i18n.Tr "repo.archive.title"}}
</div>
{{end}}
{{template "repo/sub_menu" .}}
<div class="ui stackable secondary menu mobile--margin-between-items mobile--no-negative-margins">
{{if and .PullRequestCtx.Allowed .IsViewBranch}}
Expand Down
51 changes: 51 additions & 0 deletions templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,29 @@
<p>{{.i18n.Tr "repo.settings.delete_desc"}}</p>
</div>
</div>

<div class="ui divider"></div>

<div class="item">
<div class="ui right">
<button class="ui basic red show-modal button" data-modal="#archive-repo-modal">
{{if .Repository.IsArchived}}
{{.i18n.Tr "repo.settings.unarchive.button"}}
{{else}}
{{.i18n.Tr "repo.settings.archive.button"}}
{{end}}
</button>
</div>
<div>
{{if .Repository.IsArchived}}
<h5>{{.i18n.Tr "repo.settings.unarchive.header"}}</h5>
<p>{{.i18n.Tr "repo.settings.unarchive.text"}}</p>
{{else}}
<h5>{{.i18n.Tr "repo.settings.archive.header"}}</h5>
<p>{{.i18n.Tr "repo.settings.archive.text"}}</p>
{{end}}
</div>
</div>
</div>
{{end}}
</div>
Expand Down Expand Up @@ -458,6 +481,34 @@
</div>
</div>
{{end}}

<div class="ui basic modal" id="archive-repo-modal">
<div class="ui icon header">
{{if .Repository.IsArchived}}
{{.i18n.Tr "repo.settings.unarchive.header"}}
{{else}}
{{.i18n.Tr "repo.settings.archive.header"}}
{{end}}
</div>
<div class="content center">
<p>
{{if .Repository.IsArchived}}
{{.i18n.Tr "repo.settings.unarchive.text"}}
{{else}}
{{.i18n.Tr "repo.settings.archive.text"}}
{{end}}
</p>
</div>
<form action="{{.Link}}" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="archive">
<input type="hidden" name="repo_id" value="{{.Repository.ID}}">
<div class="center actions">
<div class="ui basic cancel inverted button">{{.i18n.Tr "settings.cancel"}}</div>
<button class="ui basic inverted yellow button">{{.i18n.Tr "modal.yes"}}</button>
</div>
</form>
</div>
{{end}}

{{template "base/footer" .}}
1 change: 1 addition & 0 deletions templates/user/dashboard/dashboard.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<a :href="suburl + '/' + repo.full_name">
<i :class="repoClass(repo)"></i>
<strong class="text truncate item-name">${repo.full_name}</strong>
<i v-if="repo.archived" class="archive icon archived-icon"></i>
<span class="ui right text light grey">
${repo.stars_count} <i class="octicon octicon-star rear"></i>
</span>
Expand Down
1 change: 1 addition & 0 deletions vendor/code.gitea.io/sdk/gitea/repo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.