You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forgejo/models
mrsdizzie 8d99ee2773
Add Organization Wide Labels (#10814)
* Add organization wide labels

Implement organization wide labels similar to organization wide
webhooks. This lets you create individual labels for organizations that can be used
for all repos under that organization (so being able to reuse the same
label across multiple repos).

This makes it possible for small organizations with many repos to use
labels effectively.

Fixes #7406

* Add migration

* remove comments

* fix tests

* Update options/locale/locale_en-US.ini

Removed unused translation string

* show org labels in issue search label filter

* Use more clear var name

* rename migration after merge from master

* comment typo

* update migration again after rebase with master

* check for orgID <=0 per guillep2k review

* fmt

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* remove unused code

* Make sure RepoID is 0 when searching orgID per code review

* more changes/code review requests

* More descriptive translation var per code review

* func description/delete comment when issue label deleted instead of hiding it

* remove comment

* only use issues in that repo when calculating number of open issues for org label on repo label page

* Add integration test for IssuesSearch API with labels

* remove unused function

* Update models/issue_label.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Use subquery in GetLabelIDsInReposByNames

* Fix tests to use correct orgID

* fix more tests

* IssuesSearch api now uses new BuildLabelNamesIssueIDsCondition. Add a few more tests as well

* update comment for clarity

* Revert previous code change now that we can use the new BuildLabelNamesIssueIDsCondition

* Don't sort repos by date in IssuesSearch API

After much debugging I've found a strange issue where in some cases MySQL will return a different result than other enigines if a query is sorted by a null collumn. For example with our integration test data where we don't set updated_unix in repository fixtures:

SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 45

Returns different results for MySQL than other engines. However, the similar query:

SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 30

Returns the same results.

This causes integration tests to fail on MySQL in certain cases but would never show up in a real installation. Since this API call always returns issues based on the optionally provided repo_priority_id or the issueID itself, there is no change to results by changing the repo sorting method used to get ids earlier in the function.

* linter is back!

* code review

* remove now unused option

* Fix newline at end of files

* more unused code

* update to master

* check for matching ids before query

* Update models/issue_label.go

Co-Authored-By: 6543 <6543@obermui.de>

* Update models/issue_label.go

* update comments

* Update routers/org/setting.go

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
4 years ago
..
fixtures Add Organization Wide Labels (#10814) 4 years ago
migrations Add Organization Wide Labels (#10814) 4 years ago
access.go Upgrade xorm to v1.0.0 (#10646) 4 years ago
access_test.go Fix "access" fixtures and tests (#10247) 4 years ago
action.go Fix potential bugs (#10513) 4 years ago
action_list.go refactor: reduce sql query in retrieveFeeds (#3547) 6 years ago
action_test.go Restricted users (#6274) 5 years ago
admin.go Use gitea forked macaron (#7933) 5 years ago
admin_test.go Fix tests code to prevent some runtime errors (#2381) 7 years ago
attachment.go Fix potential bugs (#10513) 4 years ago
attachment_test.go Reading pull attachments should depend on read UnitTypePullRequests (#10346) 4 years ago
avatar.go make avatar lookup occur at image request (#10540) 4 years ago
branches.go Allow to set protected file patterns that can not be changed under no conditions (#10806) 4 years ago
branches_test.go Add deleted_branch table fixture (#2832) 7 years ago
commit_status.go API add/generalize pagination (#9452) 4 years ago
commit_status_test.go Fix wrong hint when status checking is running on pull request view (#9886) 5 years ago
consistency.go Auto-subscribe user to repository when they commit/tag to it (#7657) 5 years ago
context.go Refactor repository check and sync functions (#9854) 5 years ago
convert.go Move database settings from models to setting (#7806) 5 years ago
error.go Add Organization Wide Labels (#10814) 4 years ago
error_oauth2.go gofmt (#1662) 7 years ago
external_login_user.go Migrate reviews when migrating repository from github (#9463) 5 years ago
fixture_generation.go Move fixture generation to contrib and add test (#10277) 4 years ago
fixture_test.go Move fixture generation to contrib and add test (#10277) 4 years ago
gpg_key.go Show Signer in commit lists and add basic trust (#10425) 4 years ago
gpg_key_test.go Display ui time with customize time location (#7792) 5 years ago
helper.go Add reactions to issues/PR and comments (#2856) 7 years ago
helper_directory.go Remove SavePatch and generate patches on the fly (#9302) 5 years ago
helper_environment.go Move PushUpdateAddDeleteTags to repository module from models (#10106) 4 years ago
issue.go Add Organization Wide Labels (#10814) 4 years ago
issue_assignees.go Remove Unused Functions (#10516) 4 years ago
issue_assignees_test.go Fix API Bug (fail on empty assignees) (#8873) 5 years ago
issue_comment.go Fix potential bugs (#10513) 4 years ago
issue_comment_list.go Fixed repo link in generated comment for cross repository dependency (#9863) 5 years ago
issue_comment_test.go Pull request review/approval and comment on code (#3748) 6 years ago
issue_dependency.go Display ui time with customize time location (#7792) 5 years ago
issue_dependency_test.go Refactor comment (#9330) 5 years ago
issue_label.go Add Organization Wide Labels (#10814) 4 years ago
issue_label_test.go Add Organization Wide Labels (#10814) 4 years ago
issue_list.go Add Approval Counts to pulls list (#10238) 4 years ago
issue_list_test.go Add Organization Wide Labels (#10814) 4 years ago
issue_lock.go remove unused method and rename createcommentWithNoAction (#9367) 5 years ago
issue_milestone.go Fix milestones too many SQL variables bug (#10880) 4 years ago
issue_milestone_test.go Fix milestones too many SQL variables bug (#10880) 4 years ago
issue_reaction.go API add/generalize pagination (#9452) 4 years ago
issue_reaction_test.go Migrate reactions when migrating repository from github (#9599) 5 years ago
issue_stopwatch.go API add/generalize pagination (#9452) 4 years ago
issue_stopwatch_test.go Display ui time with customize time location (#7792) 5 years ago
issue_test.go issue search on my related repositories (#9758) 4 years ago
issue_tracked_time.go API add/generalize pagination (#9452) 4 years ago
issue_tracked_time_test.go [API] Extend times API (#9200) 5 years ago
issue_user.go Mail assignee when issue/pull request is assigned (#8546) 5 years ago
issue_user_test.go Add "Update Branch" button to Pull Requests (#9784) 5 years ago
issue_watch.go [BugFix] Avoid mailing explicit unwatched (#10475) 4 years ago
issue_watch_test.go API add/generalize pagination (#9452) 4 years ago
issue_xref.go remove unused method and rename createcommentWithNoAction (#9367) 5 years ago
issue_xref_test.go Refactor comment (#9330) 5 years ago
lfs.go Restricted users (#6274) 5 years ago
lfs_lock.go Make repository management section handle lfs locks (#8726) 5 years ago
list_options.go Upgrade xorm to v1.0.0 (#10646) 4 years ago
log.go Upgrade xorm to v1.0.0 (#10646) 4 years ago
login_source.go Upgrade xorm to v1.0.0 (#10646) 4 years ago
main_test.go Unit tests for wiki routers (#3022) 7 years ago
migrate.go Fix migration information update bug when linked github account (#10310) 4 years ago
models.go Fix typo of MSSQL (#10850) 4 years ago
models_test.go Move database settings from models to setting (#7806) 5 years ago
notification.go Upgrade golangci-lint to 1.24.0 (#10894) 4 years ago
notification_test.go [API] Add notification endpoint (#9488) 5 years ago
oauth2.go OAuth2: add Yandex provider (#8335) (#10564) 4 years ago
oauth2_application.go adds API endpoints to manage OAuth2 Application (list/create/delete) (#10437) 4 years ago
oauth2_application_test.go OAuth2 Grant UI (#6625) 5 years ago
org.go Ensure DeleteUser is not allowed to Delete Orgs and visa versa (#10134) 4 years ago
org_team.go Upgrade xorm to v1.0.0 (#10646) 4 years ago
org_team_test.go API add/generalize pagination (#9452) 4 years ago
org_test.go Ensure DeleteUser is not allowed to Delete Orgs and visa versa (#10134) 4 years ago
pull.go Add Approval Counts to pulls list (#10238) 4 years ago
pull_list.go API add/generalize pagination (#9452) 4 years ago
pull_sign.go Display pull request head branch even the branch deleted or repository deleted (#10413) 4 years ago
pull_test.go Display pull request head branch even the branch deleted or repository deleted (#10413) 4 years ago
release.go Move PushUpdateAddDeleteTags to repository module from models (#10106) 4 years ago
repo.go Option to set default branch at repository creation (#10803) 4 years ago
repo_activity.go Add top author stats to activity page (#9615) 5 years ago
repo_branch.go Move newbranch to standalone package (#9627) 5 years ago
repo_collaboration.go Show Signer in commit lists and add basic trust (#10425) 4 years ago
repo_collaboration_test.go API add/generalize pagination (#9452) 4 years ago
repo_generate.go API add/generalize pagination (#9452) 4 years ago
repo_generate_test.go Variable expansion in repository templates (#9163) 5 years ago
repo_indexer.go Index code and stats only for non-empty repositories (#10251) 4 years ago
repo_issue.go Add EnableTimetracking option to app settings (#3719) 6 years ago
repo_language_stats.go Index code and stats only for non-empty repositories (#10251) 4 years ago
repo_list.go Fix milestones too many SQL variables bug (#10880) 4 years ago
repo_list_test.go API add/generalize pagination (#9452) 4 years ago
repo_mirror.go Move some repository methods from models to modules/repository (#9353) 5 years ago
repo_permission.go Restricted users (#6274) 5 years ago
repo_permission_test.go fix bug when update owner team then visit team's repo return 404 (#6119) 5 years ago
repo_redirect.go Move repoWorkPool outside rename/transfer repository (#9086) 5 years ago
repo_redirect_test.go Move repoWorkPool outside rename/transfer repository (#9086) 5 years ago
repo_sign.go Sign: Handle ErrTwoFactorNotEnrolled correctly (#10008) 4 years ago
repo_test.go Move create/fork repository from models to modules/repository (#9489) 5 years ago
repo_unit.go Upgrade xorm to v1.0.0 (#10646) 4 years ago
repo_watch.go Code Refactor of IssueWatch related things (#10401) 4 years ago
repo_watch_test.go API add/generalize pagination (#9452) 4 years ago
review.go Migrate reviews when migrating repository from github (#9463) 5 years ago
review_test.go Branch protection: Possibility to not use whitelist but allow anyone with write access (#9055) 5 years ago
ssh_key.go Use ErrKeyUnableToVerify if fail to calc fingerprint in ssh-keygen (#10863) 4 years ago
ssh_key_test.go Fix SSH2 conditonal in key parsing code (#8806) 5 years ago
star.go API add/generalize pagination (#9452) 4 years ago
star_test.go API add/generalize pagination (#9452) 4 years ago
task.go Move create/fork repository from models to modules/repository (#9489) 5 years ago
test_fixtures.go Upgrade xorm to v1.0.0 (#10646) 4 years ago
token.go FIX Pagination of ListAccessTokens and GetIssueWatchers (#10449) 4 years ago
token_test.go API add/generalize pagination (#9452) 4 years ago
topic.go Update topics repo count when deleting repository (#10051) 4 years ago
topic_test.go API add/generalize pagination (#9452) 4 years ago
twofactor.go Display ui time with customize time location (#7792) 5 years ago
u2f.go Display ui time with customize time location (#7792) 5 years ago
u2f_test.go Override xorm type mapping for U2F counter (#6232) 5 years ago
unit.go Add setting to set default and global disabled repository units. (#8788) 5 years ago
unit_tests.go Upgrade xorm to v1.0.0 (#10646) 4 years ago
update.go Remove Unused Functions (#10516) 4 years ago
upload.go Use gitea forked macaron (#7933) 5 years ago
user.go Add restricted user filter to LDAP authentication (#10600) 4 years ago
user_follow.go Refactor session close as xorm already does everything needed internally (#2020) 7 years ago
user_follow_test.go Move user_follow to separate file (#1210) 7 years ago
user_heatmap.go Move database settings from models to setting (#7806) 5 years ago
user_heatmap_test.go Restricted users (#6274) 5 years ago
user_mail.go Admin page for managing user e-mail activation (#10557) 4 years ago
user_mail_test.go Admin page for managing user e-mail activation (#10557) 4 years ago
user_openid.go Fix SQL quoting (#5117) 6 years ago
user_openid_test.go Add golangci (#6418) 5 years ago
user_test.go Ensure DeleteUser is not allowed to Delete Orgs and visa versa (#10134) 4 years ago
userlist.go API add/generalize pagination (#9452) 4 years ago
userlist_test.go Team permission to create repository in organization (#8312) 5 years ago
webhook.go Add Matrix webhook (#10831) 4 years ago
webhook_test.go Granular webhook events (#9626) 4 years ago
wiki.go Add owner_name column for table repository for maintaince reason (#9717) 5 years ago
wiki_test.go Move wiki related funtions from models to services/wiki (#9355) 5 years ago