Compare commits
26
Commits
main
...
release/v1.24
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6233c25b5 | ||
|
|
2bf2d00c8a | ||
|
|
9bd56a8ba0 | ||
|
|
a1dc3c9bd1 | ||
|
|
47ee84d1f3 | ||
|
|
89f1df033a | ||
|
|
94b67f1967 | ||
|
|
0a9a84df11 | ||
|
|
cdac263bb8 | ||
|
|
a5c7df7a4c | ||
|
|
6d738fecc4 | ||
|
|
38cc7453e2 | ||
|
|
b44175c071 | ||
|
|
947358dffe | ||
|
|
be1090cb2d | ||
|
|
c8f3402841 | ||
|
|
a3a95a0b67 | ||
|
|
ed527b664d | ||
|
|
e4717d426e | ||
|
|
16f15d2f7b | ||
|
|
b3f5196241 | ||
|
|
6c5f0af45d | ||
|
|
c95cb7c7e2 | ||
|
|
6747e3e0eb | ||
|
|
a12b5b3640 | ||
|
|
834dad8cef |
No files matched your search
+315
@@ -4,6 +4,321 @@ This changelog goes through the changes that have been made in each release
|
||||
without substantial changes to our git log; to see the highlights of what has
|
||||
been added to each release, please refer to the [blog](https://blog.gitea.com).
|
||||
|
||||
## [1.24.0-rc0](https://github.com/go-gitea/gitea/releases/tag/1.24.0-rc0) - 2025-04-28
|
||||
|
||||
* BREAKING
|
||||
* Make Gitea always use its internal config, ignore `/etc/gitconfig` (#33076)
|
||||
* Improve log format (#33814)
|
||||
* Fix markdown render behaviors (#34122)
|
||||
* Add package version api endpoints (#34173)
|
||||
|
||||
* FEATURES
|
||||
* Enforce two-factor auth (2FA: TOTP or WebAuthn) (#34187)
|
||||
* Add fullscreen mode as a more efficient operation way to view projects (#34081)
|
||||
* Add anonymous access support for private/unlisted repositories (#34051)
|
||||
* Support public code/issue access for private repositories (#33127)
|
||||
* Add middleware for request prioritization (#33951)
|
||||
* Add cli flags LDAP group configuration (#33933)
|
||||
* Add file tree to file view page (#32721)
|
||||
* Add material icons for file list (#33837)
|
||||
* Artifacts download api for artifact actions v4 (#33510)
|
||||
* Support choose email when creating a commit via web UI (#33432)
|
||||
* Add basic auth support to rss/atom feeds (#33371)
|
||||
* Add sorting by exclusive labels (issue priority) (#33206)
|
||||
* Add sub issue list support (#32940)
|
||||
* Private README.md for organization (#32872)
|
||||
* Email option to embed images as base64 instead of link (#32061)
|
||||
* Option to delay conflict checking of old pull requests until page view (#27779)
|
||||
* Worktime tracking for the organization level (#19808)
|
||||
|
||||
* PERFORMANCE
|
||||
* Add cache for common package queries (#22491)
|
||||
* Move issue pin to an standalone table for querying performance (#33452)
|
||||
* Improve commits list performance to reduce unnecessary database queries (#33528)
|
||||
* Optimize total count of feed when loading activities in user dashboard. (#33841)
|
||||
* Optimize heatmap query (#33853)
|
||||
* Only use prev and next buttons for pagination on user dashboard (#33981)
|
||||
* Improve pull request list API performance (#34052)
|
||||
* Cache GPG keys, emails and users when list commits (#34086)
|
||||
* Refactor Git Attribute & performance optimization (#34154)
|
||||
|
||||
* ENHANCEMENTS
|
||||
* Code
|
||||
* Display when a release attachment was uploaded (#34261)
|
||||
* Support creating relative link to raw path in markdown (#34105)
|
||||
* Improve code block readability and isolate copy button (#34009)
|
||||
* Improve repository commit view (#33877)
|
||||
* Full-file syntax highlighting for diff pages (#33766)
|
||||
* Clone repository with Tea CLI (#33725)
|
||||
* Improve sync fork behavior (#33319)
|
||||
* Make git clone URL could use current signed-in user (#33091)
|
||||
* Add submodule diff links (#33097)
|
||||
* Link to tree views of submodules if possible (#33424)
|
||||
* Only keep popular licenses (#33832)
|
||||
* De-emphasize signed commits (#31160)
|
||||
|
||||
* Actions
|
||||
* Add flat-square action badge style (#34062)
|
||||
* Update action status badge layout (#34018)
|
||||
* Download actions job logs from API (#33858)
|
||||
* Always show the "rerun" button for action jobs (#33692)
|
||||
* Add auto-expanding running actions step (#30058)
|
||||
* Update status check for all supported on.pull_request.types in Gitea (#33117)
|
||||
* Workflow_dispatch use workflow from trigger branch (#33098)
|
||||
* Add action auto-scroll (#30057)
|
||||
* Add workflow_job webhook (#33694)
|
||||
|
||||
* Pull Request
|
||||
* Auto expand "New PR" form (#33971)
|
||||
* Mark parent directory as viewed when all files are viewed (#33958)
|
||||
* Show info about maintainers are allowed to edit a PR (#33738)
|
||||
* Automerge supports deleting branch automatically after merging (#32343)
|
||||
* Add additional command hints for PowerShell & CMD (#33548)
|
||||
|
||||
* Issues
|
||||
* Allow filtering issues by any assignee (#33343)
|
||||
* Show warning on navigation if currently editing comment or title (#32920)
|
||||
* Make tracked time representation display as hours (#33315)
|
||||
* Add No Results Prompt Message on Issue List Page (#33699)
|
||||
|
||||
* Packages
|
||||
* Link to nuget dependencies (#26554)
|
||||
* Add composor source field (#33502)
|
||||
|
||||
* Administration
|
||||
* Improve navbar: add "admin" tip, add "active" style (#32927)
|
||||
* Add a option "--user-type bot" to admin user create, improve role display (#27885)
|
||||
* Improve admin user view page (#33735)
|
||||
* Support performance trace (#32973)
|
||||
* Change pprof labels to be prometheus compatible (#32865)
|
||||
* Allow admins and org owners to change org member public status (#28294)
|
||||
* Optimize the installation page (#32994)
|
||||
* Make public URL generation configurable (#34250)
|
||||
* Add a --fullname arg to gitea admin user create. (#34241)
|
||||
|
||||
* Others
|
||||
* Improve oauth2 error handling (#33969)
|
||||
* Fail mirroring more gracefully (#34002)
|
||||
* Align User Details Page Header Layout with Design Specifications (#34192)
|
||||
* Webhook add X-Gitea-Hook-Installation-Target-Type Header (#33752)
|
||||
* Optimize the dashboard (#32990)
|
||||
* Improve button layout on small screens (#33633)
|
||||
* Add cropping support when modifying the user/org/repo avatar (#33498)
|
||||
* Make ROOT_URL support using request Host header (#32564)
|
||||
* Add `show more` organizations icon in user's profile (#32986)
|
||||
* Introduce `--page-space-bottom` at 64px (#30692)
|
||||
* Improve theme display (#30671)
|
||||
* Add alphabetical project sorting (#33504)
|
||||
* Add global lock for migrations to make upgrade more safe with multiple replications (#33706)
|
||||
* Add descriptions for private repo public access settings and improve the UI (#34057)
|
||||
|
||||
* API
|
||||
* Actions Runner rest api (#33873)
|
||||
* Inclusion of rename organization api (#33303)
|
||||
* Add API to support link package to repository and unlink it (#33481)
|
||||
* Add API endpoint to request contents of multiple files simultaniously (#34139)
|
||||
* Actions artifacts API list/download check status upload confirmed (#34273)
|
||||
* Add API routes to lock and unlock issues (#34165)
|
||||
* Fix some user name usages (#33689)
|
||||
* Allow filtering /repos/{owner}/{repo}/pulls by target base branch queryparam (#33684)
|
||||
* Improve swagger generation (#33664)
|
||||
* Support Ephemeral action runners (#33570)
|
||||
* Support workflow event dispatch via API (#33545)
|
||||
* Support workflow event dispatch via API (#32059)
|
||||
* Added Description Field for Secrets and Variables (#33526)
|
||||
* Reject star-related requests if stars are disabled (#33208)
|
||||
* Let API create and edit system webhooks, attempt 2 (#33180)
|
||||
* Use `Project-URL` metadata field to get a PyPI package's homepage URL (#33089)
|
||||
* Add `last_committer_date` and `last_author_date` for file contents API (#32921)
|
||||
|
||||
* REFACTORS
|
||||
* Remove context from git struct (#33793)
|
||||
* Refactor admin/common.ts (#33788)
|
||||
* Refactor repo-settings.ts (#33785)
|
||||
* Refactor repo-issue.ts (#33784)
|
||||
* Small refactor to reduce unnecessary database queries and remove duplicated functions (#33779)
|
||||
* Refactor initRepoBranchTagSelector to use new init framework (#33776)
|
||||
* Refactor buttons to use new init framework (#33774)
|
||||
* Refactor markup and pdf-viewer to use new init framework (#33772)
|
||||
* Refactor error system (#33771)
|
||||
* Refactor mail code (#33768)
|
||||
* Update TypeScript types (#33799)
|
||||
* Refactor older tests to use testify (#33140)
|
||||
* Move notifywatch to service layer (#33825)
|
||||
* Decouple context from repository related structs (#33823)
|
||||
* Remove context from mail struct (#33811)
|
||||
* Refactor dropdown ellipsis (#34123)
|
||||
* Refactor functions to reduce repopath expose (#33892)
|
||||
* Refactor repo-diff.ts (#33746)
|
||||
* Refactor web route handler (#33488)
|
||||
* Refactor user & avatar (#33433)
|
||||
* Refactor user package (#33423)
|
||||
* Refactor decouple context from migration structs (#33399)
|
||||
* Refactor context flash msg and global variables (#33375)
|
||||
* Refactor response writer & access logger (#33323)
|
||||
* Refactor ref type (#33242)
|
||||
* Refactor context repository (#33202)
|
||||
* Refactor legacy JS (#33115)
|
||||
* Refactor legacy line-number and scroll code (#33094)
|
||||
* Refactor env var related code (#33075)
|
||||
* Move SetMerged to service layer (#33045)
|
||||
* Merge updatecommentattachment functions (#33044)
|
||||
* Refactor pull-request compare&create page (#33071)
|
||||
* Refactor repo-new.ts (#33070)
|
||||
* Refactor pagination (#33037)
|
||||
* Refactor tests (#33021)
|
||||
* Refactor markup render to fix various path problems (#34114)
|
||||
* Refactor Branch struct in package modules/git (#33980)
|
||||
* Don't create duplicated functions for code repositories and wiki repositories (#33924)
|
||||
* Move git references checking to gitrepo packages to reduce expose of repository path (#33891)
|
||||
* Refactor cache-control (#33861)
|
||||
* Decouple diff stats query from actual diffing (#33810)
|
||||
* Move part of updating protected branch logic to service layer (#33742)
|
||||
* Decouple Batch from git.Repository to simplify usage without requiring the creation of a Repository struct. (#34001)
|
||||
* Refactor tmpl and blob_excerpt (#32967)
|
||||
* Refactor template & test related code (#32938)
|
||||
* Refactor db package and remove unnecessary `DumpTables` (#32930)
|
||||
* Refactor pprof labels and process desc (#32909)
|
||||
* Refactor repo-projects.ts (#32892)
|
||||
* Refactor getpatch/getdiff functions and remove unnecessary fallback (#32817)
|
||||
* Uniform all temporary directories and allow customizing temp path (#32352)
|
||||
* Remove context from retry downloader (#33871)
|
||||
* Refactor global init code and add more comments (#33755)
|
||||
* Remove some unnecessary template helpers (#33069)
|
||||
* Move and rename UpdateRepository (#34136)
|
||||
* Move hooks function to gitrepo and reduce expose repopath (#33890)
|
||||
* Add abstraction layer to delete repository from disk (#33879)
|
||||
* Add abstraction layer to check if the repository exists on disk (#33874)
|
||||
* Move ParseCommitWithSSHSignature to service layer (#34087)
|
||||
* Move duplicated functions (#33977)
|
||||
* Extract code to their own functions for push update (#33944)
|
||||
* Move gitgraph from modules to services layer (#33527)
|
||||
* Move commits signature and verify functions to service layers (#33605)
|
||||
* Use `CloseIssue` and `ReopenIssue` instead of `ChangeStatus` (#32467)
|
||||
* Refactor arch route handlers (#32993)
|
||||
* Refactor "string truncate" (#32984)
|
||||
* Refactor arch route handlers (#32972)
|
||||
* Clarify path param naming (#32969)
|
||||
* Refactor request context (#32956)
|
||||
* Move some errors to their own sub packages (#32880)
|
||||
* Move RepoTransfer from models to models/repo sub package (#32506)
|
||||
* Move delete deploy keys into service layer (#32201)
|
||||
* Refactor webhook events (#33337)
|
||||
* Move some Actions related functions from `routers` to `services` (#33280)
|
||||
* Refactor RefName (#33234)
|
||||
* Refactor context RefName and RepoAssignment (#33226)
|
||||
* Refactor repository transfer (#33211)
|
||||
* Refactor error system (#33626)
|
||||
* Refactor error system (#33610)
|
||||
* Refactor package (routes and error handling, npm peer dependency) (#33111)
|
||||
* Use test context in tests and new loop system in benchmarks (#33648)
|
||||
* Some small refactors (#33144)
|
||||
* Simplify context ref name (#33267)
|
||||
|
||||
* BUGFIXES
|
||||
* Only allow admins to rename default/protected branches (#33276)
|
||||
* Improve "lock conversation" UI (#34207)
|
||||
* Fix incorrect file links (#34189)
|
||||
* Optimize Overflow Menu (#34183)
|
||||
* Check user/org repo limit instead of doer (#34147)
|
||||
* Make markdown render match GitHub's behavior (#34129)
|
||||
* Fix team permission (#34128)
|
||||
* Correctly handle submodule view and avoid throwing 500 error (#34121)
|
||||
* Fix users being able bypass limits with repo transfers (#34031)
|
||||
* Avoid creating unnecessary temporary cat file sub process (#33942)
|
||||
* Refactor organization menu (#33928)
|
||||
* Fix various Fomantic UI and htmx problems (#33851)
|
||||
* Fix 500 error when error occurred in migration page (#33256)
|
||||
* Validate that the tag doesn't exist when creating a tag via the web (#33241)
|
||||
* Add missed transaction on setmerged (#33079)
|
||||
* Rework create/fork/adopt/generate repository to make sure resources will be cleanup once failed (#31035)
|
||||
* Valid email address should only start with alphanumeric (#28174)
|
||||
* Fix webhook url (#34186)
|
||||
* Fix "toAbsoluteLocaleDate" test when system locale is not en-US (#33939)
|
||||
* Fix file name could not be searched if the file was not a text file when using the Bleve indexer (#33959)
|
||||
* Fix cannot delete runners via the modal dialog (#33895)
|
||||
* Fix unpin hint on the pinned pull requests (#33207)
|
||||
* Fix parentCommit invalid memory address or nil pointer dereference. (#33204)
|
||||
* Fix comment header padding (#33377)
|
||||
* Fix some migration and repo name problems (#33986)
|
||||
* Fix various trivial frontend problems (#34263)
|
||||
* Fix Set Email Preference dropdown and button placement (#34255)
|
||||
* Fix quoted replies incorrectly render user input as part of the quote (#34216)
|
||||
* Fix button alignments and remove unnecessary styles (#34206)
|
||||
* Restore form inputs on organization create error (#34201)
|
||||
* Try to fix ACME (3rd) (#33807)
|
||||
* Fix incorrect ref "blob" (#33240)
|
||||
* Fix dynamic content loading init problem (#33748)
|
||||
* Fix git empty check and HEAD request (#33690)
|
||||
* Fix Untranslated Text on Actions Page (#33635)
|
||||
|
||||
* MISC
|
||||
* Enable addtional linters (#34085)
|
||||
* Enable testifylint rules (#34075)
|
||||
* Enable staticcheck QFxxxx rules (#34064)
|
||||
* Improve Actions test (#32883)
|
||||
* Drop fomantic build (#33845)
|
||||
* Go1.24 (#33562)
|
||||
* Run yamllint with strict mode, fix issue (#33551)
|
||||
* Disable cron task to update license (#33486)
|
||||
* Optimize makefile help information generation (#33390)
|
||||
* Convert github.com/xanzy/go-gitlab into gitlab.com/gitlab-org/api/client-go (#33126)
|
||||
* Add missed changelogs (#33649)
|
||||
* Update .changelog file to add performance label group (#33472)
|
||||
* Add missing POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES in app.example.ini (#33363)
|
||||
* Update README screenshots (#33347)
|
||||
* Update unrs-resolver (#34279)
|
||||
* Update go&js dependencies (#34262)
|
||||
* Optimize the calling code of queryElems (#34235)
|
||||
* Update protected_branch.tmpl (#34193)
|
||||
* Feat/optimize span svg layout (#34185)
|
||||
* Set MERMAID_MAX_SOURCE_CHARACTERS to 50000 (#34152)
|
||||
* Update JS and PY deps (#34143)
|
||||
* Add Chinese translations for README files (#34132)
|
||||
* Use `overflow-wrap: anywhere` to replace `word-break: break-all` (#34126)
|
||||
* Clarify ownership in password change error messages (#34092)
|
||||
* Add toggleClass function in dom.ts (#34063)
|
||||
* Update to golangci-lint v2 (#34054)
|
||||
* Update Makefile test comments (#34013)
|
||||
* Update go mod dependencies (#33988)
|
||||
* Use filepath.Join instead of path.Join for file system file operations (#33978)
|
||||
* Prepare common tmpl functions in a middleware (#33957)
|
||||
* Remove unused or abused styles (#33918)
|
||||
* Update JS and PY deps, misc tweaks (#33903)
|
||||
* Try to figure out attribute checker problem (#33901)
|
||||
* Add lock for a repository pull mirror (#33876)
|
||||
* Fine tune push mirror UI (#33866)
|
||||
* Improve issue & code search (#33860)
|
||||
* Use pullrequestlist instead of []*pullrequest (#33765)
|
||||
* Upgrade act to 0.261.4 and actions-proto-go to v0.4.1 (#33760)
|
||||
* Align sidebar gears to the right (#33721)
|
||||
* Update Go dependencies (skip blevesearch, meilisearch) (#33655)
|
||||
* Add migrations and doctor fixes (#33556)
|
||||
* Remove "class-name" from svg icon (#33540)
|
||||
* Update MAINTAINERS (#33529)
|
||||
* Add "No data available" display when list is empty (#33517)
|
||||
* Use `git diff-tree` for `DiffFileTree` on diff pages (#33514)
|
||||
* Give organisation members access to organisation feeds (#33508)
|
||||
* Update feishu icon (#33470)
|
||||
* Hide/disable unusable UI elements when a repository is archived (#33459)
|
||||
* Update `@github/text-expander-element` to 2.9.0 (#33435)
|
||||
* Do not access GitRepo when a repo is being created (#33380)
|
||||
* Fix incorrect ref usages (#33301)
|
||||
* Prepare for support performance trace (#33286)
|
||||
* Enable Typescript `noImplicitThis` (#33250)
|
||||
* Remove unused CSS styles and move some styles to proper files (#33217)
|
||||
* Add .run to gitignore (#33175)
|
||||
* Fix typo in gitea downloader test and add missing codebase in `ToGitServiceType` (#33146)
|
||||
* Remove extended glob pattern from branch protection UI (#33125)
|
||||
* Clean up legacy form CSS styles (#33081)
|
||||
* Unset XDG_HOME_CONFIG as gitea manages configuration locations (#33067)
|
||||
* Add IntelliJ Gateway's .uuid to gitignore (#33052)
|
||||
* User facing messages for AGit errors (#33012)
|
||||
* Always show assignees on right (#33006)
|
||||
* Fix eslint (#33002)
|
||||
* Update JS dependencies (#32914)
|
||||
* Bump x/net (#32896) (#32900)
|
||||
|
||||
## [1.23.6](https://github.com/go-gitea/gitea/releases/tag/v1.23.6) - 2025-03-24
|
||||
|
||||
* SECURITY
|
||||
|
||||
Generated
+2
-2
@@ -625,8 +625,8 @@
|
||||
"licenseText": "\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under tLine truncated
|
||||
},
|
||||
{
|
||||
"name": "github.com/google/go-github/v61/github",
|
||||
"path": "github.com/google/go-github/v61/github/LICENSE",
|
||||
"name": "github.com/google/go-github/v71/github",
|
||||
"path": "github.com/google/go-github/v71/github/LICENSE",
|
||||
"licenseText": "Copyright (c) 2013 The go-github AUTHORS. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
|
||||
},
|
||||
{
|
||||
|
||||
+31
-58
@@ -11,7 +11,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -20,7 +19,7 @@ import (
|
||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
"code.gitea.io/gitea/modules/container"
|
||||
"code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/lfstransfer"
|
||||
@@ -37,14 +36,6 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
verbUploadPack = "git-upload-pack"
|
||||
verbUploadArchive = "git-upload-archive"
|
||||
verbReceivePack = "git-receive-pack"
|
||||
verbLfsAuthenticate = "git-lfs-authenticate"
|
||||
verbLfsTransfer = "git-lfs-transfer"
|
||||
)
|
||||
|
||||
// CmdServ represents the available serv sub-command.
|
||||
var CmdServ = &cli.Command{
|
||||
Name: "serv",
|
||||
@@ -78,22 +69,6 @@ func setup(ctx context.Context, debug bool) {
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
// keep getAccessMode() in sync
|
||||
allowedCommands = container.SetOf(
|
||||
verbUploadPack,
|
||||
verbUploadArchive,
|
||||
verbReceivePack,
|
||||
verbLfsAuthenticate,
|
||||
verbLfsTransfer,
|
||||
)
|
||||
allowedCommandsLfs = container.SetOf(
|
||||
verbLfsAuthenticate,
|
||||
verbLfsTransfer,
|
||||
)
|
||||
alphaDashDotPattern = regexp.MustCompile(`[^\w-\.]`)
|
||||
)
|
||||
|
||||
// fail prints message to stdout, it's mainly used for git serv and git hook commands.
|
||||
// The output will be passed to git client and shown to user.
|
||||
func fail(ctx context.Context, userMessage, logMsgFmt string, args ...any) error {
|
||||
@@ -139,19 +114,20 @@ func handleCliResponseExtra(extra private.ResponseExtra) error {
|
||||
|
||||
func getAccessMode(verb, lfsVerb string) perm.AccessMode {
|
||||
switch verb {
|
||||
case verbUploadPack, verbUploadArchive:
|
||||
case git.CmdVerbUploadPack, git.CmdVerbUploadArchive:
|
||||
return perm.AccessModeRead
|
||||
case verbReceivePack:
|
||||
case git.CmdVerbReceivePack:
|
||||
return perm.AccessModeWrite
|
||||
case verbLfsAuthenticate, verbLfsTransfer:
|
||||
case git.CmdVerbLfsAuthenticate, git.CmdVerbLfsTransfer:
|
||||
switch lfsVerb {
|
||||
case "upload":
|
||||
case git.CmdSubVerbLfsUpload:
|
||||
return perm.AccessModeWrite
|
||||
case "download":
|
||||
case git.CmdSubVerbLfsDownload:
|
||||
return perm.AccessModeRead
|
||||
}
|
||||
}
|
||||
// should be unreachable
|
||||
setting.PanicInDevOrTesting("unknown verb: %s %s", verb, lfsVerb)
|
||||
return perm.AccessModeNone
|
||||
}
|
||||
|
||||
@@ -230,12 +206,12 @@ func runServ(c *cli.Context) error {
|
||||
log.Debug("SSH_ORIGINAL_COMMAND: %s", os.Getenv("SSH_ORIGINAL_COMMAND"))
|
||||
}
|
||||
|
||||
words, err := shellquote.Split(cmd)
|
||||
sshCmdArgs, err := shellquote.Split(cmd)
|
||||
if err != nil {
|
||||
return fail(ctx, "Error parsing arguments", "Failed to parse arguments: %v", err)
|
||||
}
|
||||
|
||||
if len(words) < 2 {
|
||||
if len(sshCmdArgs) < 2 {
|
||||
if git.DefaultFeatures().SupportProcReceive {
|
||||
// for AGit Flow
|
||||
if cmd == "ssh_info" {
|
||||
@@ -246,25 +222,21 @@ func runServ(c *cli.Context) error {
|
||||
return fail(ctx, "Too few arguments", "Too few arguments in cmd: %s", cmd)
|
||||
}
|
||||
|
||||
verb := words[0]
|
||||
repoPath := strings.TrimPrefix(words[1], "/")
|
||||
|
||||
var lfsVerb string
|
||||
|
||||
rr := strings.SplitN(repoPath, "/", 2)
|
||||
if len(rr) != 2 {
|
||||
repoPath := strings.TrimPrefix(sshCmdArgs[1], "/")
|
||||
repoPathFields := strings.SplitN(repoPath, "/", 2)
|
||||
if len(repoPathFields) != 2 {
|
||||
return fail(ctx, "Invalid repository path", "Invalid repository path: %v", repoPath)
|
||||
}
|
||||
|
||||
username := rr[0]
|
||||
reponame := strings.TrimSuffix(rr[1], ".git")
|
||||
username := repoPathFields[0]
|
||||
reponame := strings.TrimSuffix(repoPathFields[1], ".git") // “the-repo-name" or "the-repo-name.wiki"
|
||||
|
||||
// LowerCase and trim the repoPath as that's how they are stored.
|
||||
// This should be done after splitting the repoPath into username and reponame
|
||||
// so that username and reponame are not affected.
|
||||
repoPath = strings.ToLower(strings.TrimSpace(repoPath))
|
||||
|
||||
if alphaDashDotPattern.MatchString(reponame) {
|
||||
if !repo.IsValidSSHAccessRepoName(reponame) {
|
||||
return fail(ctx, "Invalid repo name", "Invalid repo name: %s", reponame)
|
||||
}
|
||||
|
||||
@@ -286,22 +258,23 @@ func runServ(c *cli.Context) error {
|
||||
}()
|
||||
}
|
||||
|
||||
if allowedCommands.Contains(verb) {
|
||||
if allowedCommandsLfs.Contains(verb) {
|
||||
if !setting.LFS.StartServer {
|
||||
return fail(ctx, "LFS Server is not enabled", "")
|
||||
}
|
||||
if verb == verbLfsTransfer && !setting.LFS.AllowPureSSH {
|
||||
return fail(ctx, "LFS SSH transfer is not enabled", "")
|
||||
}
|
||||
if len(words) > 2 {
|
||||
lfsVerb = words[2]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
verb, lfsVerb := sshCmdArgs[0], ""
|
||||
if !git.IsAllowedVerbForServe(verb) {
|
||||
return fail(ctx, "Unknown git command", "Unknown git command %s", verb)
|
||||
}
|
||||
|
||||
if git.IsAllowedVerbForServeLfs(verb) {
|
||||
if !setting.LFS.StartServer {
|
||||
return fail(ctx, "LFS Server is not enabled", "")
|
||||
}
|
||||
if verb == git.CmdVerbLfsTransfer && !setting.LFS.AllowPureSSH {
|
||||
return fail(ctx, "LFS SSH transfer is not enabled", "")
|
||||
}
|
||||
if len(sshCmdArgs) > 2 {
|
||||
lfsVerb = sshCmdArgs[2]
|
||||
}
|
||||
}
|
||||
|
||||
requestedMode := getAccessMode(verb, lfsVerb)
|
||||
|
||||
results, extra := private.ServCommand(ctx, keyID, username, reponame, requestedMode, verb, lfsVerb)
|
||||
@@ -310,7 +283,7 @@ func runServ(c *cli.Context) error {
|
||||
}
|
||||
|
||||
// LFS SSH protocol
|
||||
if verb == verbLfsTransfer {
|
||||
if verb == git.CmdVerbLfsTransfer {
|
||||
token, err := getLFSAuthToken(ctx, lfsVerb, results)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -319,7 +292,7 @@ func runServ(c *cli.Context) error {
|
||||
}
|
||||
|
||||
// LFS token authentication
|
||||
if verb == verbLfsAuthenticate {
|
||||
if verb == git.CmdVerbLfsAuthenticate {
|
||||
url := fmt.Sprintf("%s%s/%s.git/info/lfs", setting.AppURL, url.PathEscape(results.OwnerName), url.PathEscape(results.RepoName))
|
||||
|
||||
token, err := getLFSAuthToken(ctx, lfsVerb, results)
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/google/go-github/v61/github"
|
||||
"github.com/google/go-github/v71/github"
|
||||
"github.com/urfave/cli/v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
@@ -66,7 +66,7 @@ require (
|
||||
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
|
||||
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
||||
github.com/google/go-github/v61 v61.0.0
|
||||
github.com/google/go-github/v71 v71.0.0
|
||||
github.com/google/licenseclassifier/v2 v2.0.0
|
||||
github.com/google/pprof v0.0.0-20250422154841-e1f9c1950416
|
||||
github.com/google/uuid v1.6.0
|
||||
@@ -325,6 +325,8 @@ replace github.com/charmbracelet/git-lfs-transfer => gitea.com/gitea/git-lfs-tra
|
||||
// TODO: This could be removed after https://github.com/mholt/archiver/pull/396 merged
|
||||
replace github.com/mholt/archiver/v3 => github.com/anchore/archiver/v3 v3.5.2
|
||||
|
||||
replace git.sr.ht/~mariusor/go-xsd-duration => gitea.com/gitea/go-xsd-duration v0.0.0-20220703122237-02e73435a078
|
||||
|
||||
exclude github.com/gofrs/uuid v3.2.0+incompatible
|
||||
|
||||
exclude github.com/gofrs/uuid v4.0.0+incompatible
|
||||
|
||||
@@ -14,12 +14,12 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
||||
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
|
||||
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
|
||||
gitea.com/gitea/act v0.261.4 h1:Tf9eLlvsYFtKcpuxlMvf9yT3g4Hshb2Beqw6C1STuH8=
|
||||
gitea.com/gitea/act v0.261.4/go.mod h1:Pg5C9kQY1CEA3QjthjhlrqOC/QOT5NyWNjOjRHw23Ok=
|
||||
gitea.com/gitea/git-lfs-transfer v0.2.0 h1:baHaNoBSRaeq/xKayEXwiDQtlIjps4Ac/Ll4KqLMB40=
|
||||
gitea.com/gitea/git-lfs-transfer v0.2.0/go.mod h1:UrXUCm3xLQkq15fu7qlXHUMlrhdlXHoi13KH2Dfiits=
|
||||
gitea.com/gitea/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:BAFmdZpRW7zMQZQDClaCWobRj9uL1MR3MzpCVJvc5s4=
|
||||
gitea.com/gitea/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
|
||||
gitea.com/go-chi/binding v0.0.0-20240430071103-39a851e106ed h1:EZZBtilMLSZNWtHHcgq2mt6NSGhJSZBuduAlinMEmso=
|
||||
gitea.com/go-chi/binding v0.0.0-20240430071103-39a851e106ed/go.mod h1:E3i3cgB04dDx0v3CytCgRTTn9Z/9x891aet3r456RVw=
|
||||
gitea.com/go-chi/cache v0.2.1 h1:bfAPkvXlbcZxPCpcmDVCWoHgiBSBmZN/QosnZvEC0+g=
|
||||
@@ -420,8 +420,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
|
||||
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
|
||||
github.com/google/go-github/v71 v71.0.0 h1:Zi16OymGKZZMm8ZliffVVJ/Q9YZreDKONCr+WUd0Z30=
|
||||
github.com/google/go-github/v71 v71.0.0/go.mod h1:URZXObp2BLlMjwu0O8g4y6VBneUj2bCHgnI8FfgZ51M=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/google/go-tpm v0.9.3 h1:+yx0/anQuGzi+ssRqeD6WpXjW2L/V0dItUayO0i9sRc=
|
||||
|
||||
@@ -171,6 +171,7 @@ func (run *ActionRun) IsSchedule() bool {
|
||||
|
||||
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
|
||||
_, err := db.GetEngine(ctx).ID(repo.ID).
|
||||
NoAutoTime().
|
||||
SetExpr("num_action_runs",
|
||||
builder.Select("count(*)").From("action_run").
|
||||
Where(builder.Eq{"repo_id": repo.ID}),
|
||||
|
||||
@@ -530,7 +530,7 @@ func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.
|
||||
|
||||
if opts.RequestedTeam != nil {
|
||||
env := repo_model.AccessibleTeamReposEnv(organization.OrgFromUser(opts.RequestedUser), opts.RequestedTeam)
|
||||
teamRepoIDs, err := env.RepoIDs(ctx, 1, opts.RequestedUser.NumRepos)
|
||||
teamRepoIDs, err := env.RepoIDs(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GetTeamRepositories: %w", err)
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ func TestAccessibleReposEnv_RepoIDs(t *testing.T) {
|
||||
testSuccess := func(userID int64, expectedRepoIDs []int64) {
|
||||
env, err := repo_model.AccessibleReposEnv(db.DefaultContext, org, userID)
|
||||
assert.NoError(t, err)
|
||||
repoIDs, err := env.RepoIDs(db.DefaultContext, 1, 100)
|
||||
repoIDs, err := env.RepoIDs(db.DefaultContext)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expectedRepoIDs, repoIDs)
|
||||
}
|
||||
@@ -342,25 +342,6 @@ func TestAccessibleReposEnv_RepoIDs(t *testing.T) {
|
||||
testSuccess(4, []int64{3, 32})
|
||||
}
|
||||
|
||||
func TestAccessibleReposEnv_Repos(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3})
|
||||
testSuccess := func(userID int64, expectedRepoIDs []int64) {
|
||||
env, err := repo_model.AccessibleReposEnv(db.DefaultContext, org, userID)
|
||||
assert.NoError(t, err)
|
||||
repos, err := env.Repos(db.DefaultContext, 1, 100)
|
||||
assert.NoError(t, err)
|
||||
expectedRepos := make(repo_model.RepositoryList, len(expectedRepoIDs))
|
||||
for i, repoID := range expectedRepoIDs {
|
||||
expectedRepos[i] = unittest.AssertExistsAndLoadBean(t,
|
||||
&repo_model.Repository{ID: repoID})
|
||||
}
|
||||
assert.Equal(t, expectedRepos, repos)
|
||||
}
|
||||
testSuccess(2, []int64{3, 5, 32})
|
||||
testSuccess(4, []int64{3, 32})
|
||||
}
|
||||
|
||||
func TestAccessibleReposEnv_MirrorRepos(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3})
|
||||
|
||||
@@ -47,7 +47,7 @@ func (c *commitChecker) IsCommitIDExisting(commitID string) bool {
|
||||
c.gitRepo, c.gitRepoCloser = r, closer
|
||||
}
|
||||
|
||||
exist = c.gitRepo.IsReferenceExist(commitID) // Don't use IsObjectExist since it doesn't support short hashs with gogit edition.
|
||||
exist = c.gitRepo.IsReferenceExist(commitID) // Don't use IsObjectExist since it doesn't support short hashes with gogit edition.
|
||||
c.commitCache[commitID] = exist
|
||||
return exist
|
||||
}
|
||||
+4
-27
@@ -48,8 +48,7 @@ func GetTeamRepositories(ctx context.Context, opts *SearchTeamRepoOptions) (Repo
|
||||
// accessible to a particular user
|
||||
type AccessibleReposEnvironment interface {
|
||||
CountRepos(ctx context.Context) (int64, error)
|
||||
RepoIDs(ctx context.Context, page, pageSize int) ([]int64, error)
|
||||
Repos(ctx context.Context, page, pageSize int) (RepositoryList, error)
|
||||
RepoIDs(ctx context.Context) ([]int64, error)
|
||||
MirrorRepos(ctx context.Context) (RepositoryList, error)
|
||||
AddKeyword(keyword string)
|
||||
SetSort(db.SearchOrderBy)
|
||||
@@ -132,40 +131,18 @@ func (env *accessibleReposEnv) CountRepos(ctx context.Context) (int64, error) {
|
||||
return repoCount, nil
|
||||
}
|
||||
|
||||
func (env *accessibleReposEnv) RepoIDs(ctx context.Context, page, pageSize int) ([]int64, error) {
|
||||
if page <= 0 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
repoIDs := make([]int64, 0, pageSize)
|
||||
func (env *accessibleReposEnv) RepoIDs(ctx context.Context) ([]int64, error) {
|
||||
var repoIDs []int64
|
||||
return repoIDs, db.GetEngine(ctx).
|
||||
Table("repository").
|
||||
Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id").
|
||||
Where(env.cond()).
|
||||
GroupBy("`repository`.id,`repository`."+strings.Fields(string(env.orderBy))[0]).
|
||||
GroupBy("`repository`.id,`repository`." + strings.Fields(string(env.orderBy))[0]).
|
||||
OrderBy(string(env.orderBy)).
|
||||
Limit(pageSize, (page-1)*pageSize).
|
||||
Cols("`repository`.id").
|
||||
Find(&repoIDs)
|
||||
}
|
||||
|
||||
func (env *accessibleReposEnv) Repos(ctx context.Context, page, pageSize int) (RepositoryList, error) {
|
||||
repoIDs, err := env.RepoIDs(ctx, page, pageSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GetUserRepositoryIDs: %w", err)
|
||||
}
|
||||
|
||||
repos := make([]*Repository, 0, len(repoIDs))
|
||||
if len(repoIDs) == 0 {
|
||||
return repos, nil
|
||||
}
|
||||
|
||||
return repos, db.GetEngine(ctx).
|
||||
In("`repository`.id", repoIDs).
|
||||
OrderBy(string(env.orderBy)).
|
||||
Find(&repos)
|
||||
}
|
||||
|
||||
func (env *accessibleReposEnv) MirrorRepoIDs(ctx context.Context) ([]int64, error) {
|
||||
repoIDs := make([]int64, 0, 10)
|
||||
return repoIDs, db.GetEngine(ctx).
|
||||
|
||||
+18
-9
@@ -64,18 +64,18 @@ func (err ErrRepoIsArchived) Error() string {
|
||||
}
|
||||
|
||||
type globalVarsStruct struct {
|
||||
validRepoNamePattern *regexp.Regexp
|
||||
invalidRepoNamePattern *regexp.Regexp
|
||||
reservedRepoNames []string
|
||||
reservedRepoPatterns []string
|
||||
validRepoNamePattern *regexp.Regexp
|
||||
invalidRepoNamePattern *regexp.Regexp
|
||||
reservedRepoNames []string
|
||||
reservedRepoNamePatterns []string
|
||||
}
|
||||
|
||||
var globalVars = sync.OnceValue(func() *globalVarsStruct {
|
||||
return &globalVarsStruct{
|
||||
validRepoNamePattern: regexp.MustCompile(`[-.\w]+`),
|
||||
invalidRepoNamePattern: regexp.MustCompile(`[.]{2,}`),
|
||||
reservedRepoNames: []string{".", "..", "-"},
|
||||
reservedRepoPatterns: []string{"*.git", "*.wiki", "*.rss", "*.atom"},
|
||||
validRepoNamePattern: regexp.MustCompile(`^[-.\w]+$`),
|
||||
invalidRepoNamePattern: regexp.MustCompile(`[.]{2,}`),
|
||||
reservedRepoNames: []string{".", "..", "-"},
|
||||
reservedRepoNamePatterns: []string{"*.wiki", "*.git", "*.rss", "*.atom"},
|
||||
}
|
||||
})
|
||||
|
||||
@@ -86,7 +86,16 @@ func IsUsableRepoName(name string) error {
|
||||
// Note: usually this error is normally caught up earlier in the UI
|
||||
return db.ErrNameCharsNotAllowed{Name: name}
|
||||
}
|
||||
return db.IsUsableName(vars.reservedRepoNames, vars.reservedRepoPatterns, name)
|
||||
return db.IsUsableName(vars.reservedRepoNames, vars.reservedRepoNamePatterns, name)
|
||||
}
|
||||
|
||||
// IsValidSSHAccessRepoName is like IsUsableRepoName, but it allows "*.wiki" because wiki repo needs to be accessed in SSH code
|
||||
func IsValidSSHAccessRepoName(name string) bool {
|
||||
vars := globalVars()
|
||||
if !vars.validRepoNamePattern.MatchString(name) || vars.invalidRepoNamePattern.MatchString(name) {
|
||||
return false
|
||||
}
|
||||
return db.IsUsableName(vars.reservedRepoNames, vars.reservedRepoNamePatterns[1:], name) == nil
|
||||
}
|
||||
|
||||
// TrustModelType defines the types of trust model for this repository
|
||||
|
||||
@@ -216,8 +216,23 @@ func TestIsUsableRepoName(t *testing.T) {
|
||||
|
||||
assert.Error(t, IsUsableRepoName("-"))
|
||||
assert.Error(t, IsUsableRepoName("🌞"))
|
||||
assert.Error(t, IsUsableRepoName("the/repo"))
|
||||
assert.Error(t, IsUsableRepoName("the..repo"))
|
||||
assert.Error(t, IsUsableRepoName("foo.wiki"))
|
||||
assert.Error(t, IsUsableRepoName("foo.git"))
|
||||
assert.Error(t, IsUsableRepoName("foo.RSS"))
|
||||
}
|
||||
|
||||
func TestIsValidSSHAccessRepoName(t *testing.T) {
|
||||
assert.True(t, IsValidSSHAccessRepoName("a"))
|
||||
assert.True(t, IsValidSSHAccessRepoName("-1_."))
|
||||
assert.True(t, IsValidSSHAccessRepoName(".profile"))
|
||||
assert.True(t, IsValidSSHAccessRepoName("foo.wiki"))
|
||||
|
||||
assert.False(t, IsValidSSHAccessRepoName("-"))
|
||||
assert.False(t, IsValidSSHAccessRepoName("🌞"))
|
||||
assert.False(t, IsValidSSHAccessRepoName("the/repo"))
|
||||
assert.False(t, IsValidSSHAccessRepoName("the..repo"))
|
||||
assert.False(t, IsValidSSHAccessRepoName("foo.git"))
|
||||
assert.False(t, IsValidSSHAccessRepoName("foo.RSS"))
|
||||
}
|
||||
@@ -249,7 +249,7 @@ func CreatePendingRepositoryTransfer(ctx context.Context, doer, newOwner *user_m
|
||||
}
|
||||
|
||||
repo.Status = RepositoryPendingTransfer
|
||||
if err := UpdateRepositoryCols(ctx, repo, "status"); err != nil {
|
||||
if err := UpdateRepositoryColsNoAutoTime(ctx, repo, "status"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func UpdateRepositoryOwnerNames(ctx context.Context, ownerID int64, ownerName st
|
||||
}
|
||||
defer committer.Close()
|
||||
|
||||
if _, err := db.GetEngine(ctx).Where("owner_id = ?", ownerID).Cols("owner_name").Update(&Repository{
|
||||
if _, err := db.GetEngine(ctx).Where("owner_id = ?", ownerID).Cols("owner_name").NoAutoTime().Update(&Repository{
|
||||
OwnerName: ownerName,
|
||||
}); err != nil {
|
||||
return err
|
||||
@@ -40,8 +40,8 @@ func UpdateRepositoryUpdatedTime(ctx context.Context, repoID int64, updateTime t
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateRepositoryCols updates repository's columns
|
||||
func UpdateRepositoryCols(ctx context.Context, repo *Repository, cols ...string) error {
|
||||
// UpdateRepositoryColsWithAutoTime updates repository's columns
|
||||
func UpdateRepositoryColsWithAutoTime(ctx context.Context, repo *Repository, cols ...string) error {
|
||||
_, err := db.GetEngine(ctx).ID(repo.ID).Cols(cols...).Update(repo)
|
||||
return err
|
||||
}
|
||||
|
||||
+3
-1
@@ -1198,7 +1198,8 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
|
||||
for _, email := range emailAddresses {
|
||||
user := users[email.UID]
|
||||
if user != nil {
|
||||
results[user.GetEmail()] = user
|
||||
results[user.Email] = user
|
||||
results[user.GetPlaceholderEmail()] = user
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1208,6 +1209,7 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
|
||||
return nil, err
|
||||
}
|
||||
for _, user := range users {
|
||||
results[user.Email] = user
|
||||
results[user.GetPlaceholderEmail()] = user
|
||||
}
|
||||
return results, nil
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestIsUsableUsername(t *testing.T) {
|
||||
@@ -48,14 +49,23 @@ func TestOAuth2Application_LoadUser(t *testing.T) {
|
||||
assert.NotNil(t, user)
|
||||
}
|
||||
|
||||
func TestGetUserEmailsByNames(t *testing.T) {
|
||||
func TestUserEmails(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
// ignore none active user email
|
||||
assert.ElementsMatch(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user9"}))
|
||||
assert.ElementsMatch(t, []string{"user8@example.com", "user5@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user5"}))
|
||||
|
||||
assert.ElementsMatch(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "org7"}))
|
||||
t.Run("GetUserEmailsByNames", func(t *testing.T) {
|
||||
// ignore none active user email
|
||||
assert.ElementsMatch(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user9"}))
|
||||
assert.ElementsMatch(t, []string{"user8@example.com", "user5@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user5"}))
|
||||
assert.ElementsMatch(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "org7"}))
|
||||
})
|
||||
t.Run("GetUsersByEmails", func(t *testing.T) {
|
||||
m, err := user_model.GetUsersByEmails(db.DefaultContext, []string{"user1@example.com", "user2@" + setting.Service.NoReplyAddress})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, m, 4)
|
||||
assert.EqualValues(t, 1, m["user1@example.com"].ID)
|
||||
assert.EqualValues(t, 1, m["user1@"+setting.Service.NoReplyAddress].ID)
|
||||
assert.EqualValues(t, 2, m["user2@example.com"].ID)
|
||||
assert.EqualValues(t, 2, m["user2@"+setting.Service.NoReplyAddress].ID)
|
||||
})
|
||||
}
|
||||
|
||||
func TestCanCreateOrganization(t *testing.T) {
|
||||
|
||||
@@ -39,7 +39,12 @@ func checkAttrCommand(gitRepo *git.Repository, treeish string, filenames, attrib
|
||||
)
|
||||
cancel = deleteTemporaryFile
|
||||
}
|
||||
} // else: no treeish, assume it is a not a bare repo, read from working directory
|
||||
} else {
|
||||
// Read from existing index, in cases where the repo is bare and has an index,
|
||||
// or the work tree contains unstaged changes that shouldn't affect the attribute check.
|
||||
// It is caller's responsibility to add changed ".gitattributes" into the index if they want to respect the new changes.
|
||||
cmd.AddArguments("--cached")
|
||||
}
|
||||
|
||||
cmd.AddDynamicArguments(attributes...)
|
||||
if len(filenames) > 0 {
|
||||
|
||||
@@ -57,8 +57,18 @@ func Test_Checker(t *testing.T) {
|
||||
assert.Equal(t, expectedAttrs(), attrs["i-am-a-python.p"])
|
||||
})
|
||||
|
||||
t.Run("Run git check-attr in bare repository using index", func(t *testing.T) {
|
||||
attrs, err := CheckAttributes(t.Context(), gitRepo, "", CheckAttributeOpts{
|
||||
Filenames: []string{"i-am-a-python.p"},
|
||||
Attributes: LinguistAttributes,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, attrs, 1)
|
||||
assert.Equal(t, expectedAttrs(), attrs["i-am-a-python.p"])
|
||||
})
|
||||
|
||||
if !git.DefaultFeatures().SupportCheckAttrOnBare {
|
||||
t.Skip("git version 2.40 is required to support run check-attr on bare repo")
|
||||
t.Skip("git version 2.40 is required to support run check-attr on bare repo without using index")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package git
|
||||
|
||||
const (
|
||||
CmdVerbUploadPack = "git-upload-pack"
|
||||
CmdVerbUploadArchive = "git-upload-archive"
|
||||
CmdVerbReceivePack = "git-receive-pack"
|
||||
CmdVerbLfsAuthenticate = "git-lfs-authenticate"
|
||||
CmdVerbLfsTransfer = "git-lfs-transfer"
|
||||
|
||||
CmdSubVerbLfsUpload = "upload"
|
||||
CmdSubVerbLfsDownload = "download"
|
||||
)
|
||||
|
||||
func IsAllowedVerbForServe(verb string) bool {
|
||||
switch verb {
|
||||
case CmdVerbUploadPack,
|
||||
CmdVerbUploadArchive,
|
||||
CmdVerbReceivePack,
|
||||
CmdVerbLfsAuthenticate,
|
||||
CmdVerbLfsTransfer:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsAllowedVerbForServeLfs(verb string) bool {
|
||||
switch verb {
|
||||
case CmdVerbLfsAuthenticate,
|
||||
CmdVerbLfsTransfer:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -46,18 +46,16 @@ type ServCommandResults struct {
|
||||
}
|
||||
|
||||
// ServCommand preps for a serv call
|
||||
func ServCommand(ctx context.Context, keyID int64, ownerName, repoName string, mode perm.AccessMode, verbs ...string) (*ServCommandResults, ResponseExtra) {
|
||||
func ServCommand(ctx context.Context, keyID int64, ownerName, repoName string, mode perm.AccessMode, verb, lfsVerb string) (*ServCommandResults, ResponseExtra) {
|
||||
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/serv/command/%d/%s/%s?mode=%d",
|
||||
keyID,
|
||||
url.PathEscape(ownerName),
|
||||
url.PathEscape(repoName),
|
||||
mode,
|
||||
)
|
||||
for _, verb := range verbs {
|
||||
if verb != "" {
|
||||
reqURL += "&verb=" + url.QueryEscape(verb)
|
||||
}
|
||||
}
|
||||
reqURL += "&verb=" + url.QueryEscape(verb)
|
||||
// reqURL += "&lfs_verb=" + url.QueryEscape(lfsVerb) // TODO: actually there is no use of this parameter. In the future, the URL construction should be more flexible
|
||||
_ = lfsVerb
|
||||
req := newInternalRequestAPI(ctx, reqURL, "GET")
|
||||
return requestJSONResp(req, &ServCommandResults{})
|
||||
}
|
||||
@@ -11,8 +11,8 @@ type Tag struct {
|
||||
Message string `json:"message"`
|
||||
ID string `json:"id"`
|
||||
Commit *CommitMeta `json:"commit"`
|
||||
ZipballURL string `json:"zipball_url"`
|
||||
TarballURL string `json:"tarball_url"`
|
||||
ZipballURL string `json:"zipball_url,omitempty"`
|
||||
TarballURL string `json:"tarball_url,omitempty"`
|
||||
}
|
||||
|
||||
// AnnotatedTag represents an annotated tag
|
||||
|
||||
@@ -11,11 +11,13 @@ import (
|
||||
// AccessToken represents an API access token.
|
||||
// swagger:response AccessToken
|
||||
type AccessToken struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Token string `json:"sha1"`
|
||||
TokenLastEight string `json:"token_last_eight"`
|
||||
Scopes []string `json:"scopes"`
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Token string `json:"sha1"`
|
||||
TokenLastEight string `json:"token_last_eight"`
|
||||
Scopes []string `json:"scopes"`
|
||||
Created time.Time `json:"created_at"`
|
||||
Updated time.Time `json:"last_used_at"`
|
||||
}
|
||||
|
||||
// AccessTokenList represents a list of API access token.
|
||||
|
||||
@@ -16,6 +16,7 @@ type PublicKey struct {
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at,omitempty"`
|
||||
Updated time.Time `json:"last_used_at,omitempty"`
|
||||
Owner *User `json:"user,omitempty"`
|
||||
ReadOnly bool `json:"read_only,omitempty"`
|
||||
KeyType string `json:"key_type,omitempty"`
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
func TestDateTime(t *testing.T) {
|
||||
testTz, _ := time.LoadLocation("America/New_York")
|
||||
defer test.MockVariableValue(&setting.DefaultUILocation, testTz)()
|
||||
defer test.MockVariableValue(&setting.IsProd, true)()
|
||||
defer test.MockVariableValue(&setting.IsInTesting, false)()
|
||||
|
||||
du := NewDateUtils()
|
||||
@@ -53,6 +54,7 @@ func TestDateTime(t *testing.T) {
|
||||
func TestTimeSince(t *testing.T) {
|
||||
testTz, _ := time.LoadLocation("America/New_York")
|
||||
defer test.MockVariableValue(&setting.DefaultUILocation, testTz)()
|
||||
defer test.MockVariableValue(&setting.IsProd, true)()
|
||||
defer test.MockVariableValue(&setting.IsInTesting, false)()
|
||||
|
||||
du := NewDateUtils()
|
||||
|
||||
@@ -14,6 +14,8 @@ import (
|
||||
"unicode"
|
||||
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/renderhelper"
|
||||
"code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/emoji"
|
||||
"code.gitea.io/gitea/modules/htmlutil"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
@@ -34,11 +36,11 @@ func NewRenderUtils(ctx reqctx.RequestContext) *RenderUtils {
|
||||
}
|
||||
|
||||
// RenderCommitMessage renders commit message with XSS-safe and special links.
|
||||
func (ut *RenderUtils) RenderCommitMessage(msg string, metas map[string]string) template.HTML {
|
||||
func (ut *RenderUtils) RenderCommitMessage(msg string, repo *repo.Repository) template.HTML {
|
||||
cleanMsg := template.HTMLEscapeString(msg)
|
||||
// we can safely assume that it will not return any error, since there
|
||||
// shouldn't be any special HTML.
|
||||
fullMessage, err := markup.PostProcessCommitMessage(markup.NewRenderContext(ut.ctx).WithMetas(metas), cleanMsg)
|
||||
fullMessage, err := markup.PostProcessCommitMessage(renderhelper.NewRenderContextRepoComment(ut.ctx, repo), cleanMsg)
|
||||
if err != nil {
|
||||
log.Error("PostProcessCommitMessage: %v", err)
|
||||
return ""
|
||||
@@ -52,7 +54,7 @@ func (ut *RenderUtils) RenderCommitMessage(msg string, metas map[string]string)
|
||||
|
||||
// RenderCommitMessageLinkSubject renders commit message as a XSS-safe link to
|
||||
// the provided default url, handling for special links without email to links.
|
||||
func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, metas map[string]string) template.HTML {
|
||||
func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, repo *repo.Repository) template.HTML {
|
||||
msgLine := strings.TrimLeftFunc(msg, unicode.IsSpace)
|
||||
lineEnd := strings.IndexByte(msgLine, '\n')
|
||||
if lineEnd > 0 {
|
||||
@@ -63,9 +65,8 @@ func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, me
|
||||
return ""
|
||||
}
|
||||
|
||||
// we can safely assume that it will not return any error, since there
|
||||
// shouldn't be any special HTML.
|
||||
renderedMessage, err := markup.PostProcessCommitMessageSubject(markup.NewRenderContext(ut.ctx).WithMetas(metas), urlDefault, template.HTMLEscapeString(msgLine))
|
||||
// we can safely assume that it will not return any error, since there shouldn't be any special HTML.
|
||||
renderedMessage, err := markup.PostProcessCommitMessageSubject(renderhelper.NewRenderContextRepoComment(ut.ctx, repo), urlDefault, template.HTMLEscapeString(msgLine))
|
||||
if err != nil {
|
||||
log.Error("PostProcessCommitMessageSubject: %v", err)
|
||||
return ""
|
||||
@@ -74,7 +75,7 @@ func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, me
|
||||
}
|
||||
|
||||
// RenderCommitBody extracts the body of a commit message without its title.
|
||||
func (ut *RenderUtils) RenderCommitBody(msg string, metas map[string]string) template.HTML {
|
||||
func (ut *RenderUtils) RenderCommitBody(msg string, repo *repo.Repository) template.HTML {
|
||||
msgLine := strings.TrimSpace(msg)
|
||||
lineEnd := strings.IndexByte(msgLine, '\n')
|
||||
if lineEnd > 0 {
|
||||
@@ -87,7 +88,7 @@ func (ut *RenderUtils) RenderCommitBody(msg string, metas map[string]string) tem
|
||||
return ""
|
||||
}
|
||||
|
||||
renderedMessage, err := markup.PostProcessCommitMessage(markup.NewRenderContext(ut.ctx).WithMetas(metas), template.HTMLEscapeString(msgLine))
|
||||
renderedMessage, err := markup.PostProcessCommitMessage(renderhelper.NewRenderContextRepoComment(ut.ctx, repo), template.HTMLEscapeString(msgLine))
|
||||
if err != nil {
|
||||
log.Error("PostProcessCommitMessage: %v", err)
|
||||
return ""
|
||||
@@ -105,8 +106,8 @@ func renderCodeBlock(htmlEscapedTextToRender template.HTML) template.HTML {
|
||||
}
|
||||
|
||||
// RenderIssueTitle renders issue/pull title with defined post processors
|
||||
func (ut *RenderUtils) RenderIssueTitle(text string, metas map[string]string) template.HTML {
|
||||
renderedText, err := markup.PostProcessIssueTitle(markup.NewRenderContext(ut.ctx).WithMetas(metas), template.HTMLEscapeString(text))
|
||||
func (ut *RenderUtils) RenderIssueTitle(text string, repo *repo.Repository) template.HTML {
|
||||
renderedText, err := markup.PostProcessIssueTitle(renderhelper.NewRenderContextRepoComment(ut.ctx, repo), template.HTMLEscapeString(text))
|
||||
if err != nil {
|
||||
log.Error("PostProcessIssueTitle: %v", err)
|
||||
return ""
|
||||
|
||||
@@ -32,22 +32,22 @@ func renderMarkdownToHtmlLegacy(ctx context.Context, input string) template.HTML
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).MarkdownToHtml(input)
|
||||
}
|
||||
|
||||
func renderCommitMessageLegacy(ctx context.Context, msg string, metas map[string]string) template.HTML {
|
||||
func renderCommitMessageLegacy(ctx context.Context, msg string, _ map[string]string) template.HTML {
|
||||
panicIfDevOrTesting()
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).RenderCommitMessage(msg, metas)
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).RenderCommitMessage(msg, nil)
|
||||
}
|
||||
|
||||
func renderCommitMessageLinkSubjectLegacy(ctx context.Context, msg, urlDefault string, metas map[string]string) template.HTML {
|
||||
func renderCommitMessageLinkSubjectLegacy(ctx context.Context, msg, urlDefault string, _ map[string]string) template.HTML {
|
||||
panicIfDevOrTesting()
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).RenderCommitMessageLinkSubject(msg, urlDefault, metas)
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).RenderCommitMessageLinkSubject(msg, urlDefault, nil)
|
||||
}
|
||||
|
||||
func renderIssueTitleLegacy(ctx context.Context, text string, metas map[string]string) template.HTML {
|
||||
func renderIssueTitleLegacy(ctx context.Context, text string, _ map[string]string) template.HTML {
|
||||
panicIfDevOrTesting()
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).RenderIssueTitle(text, metas)
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).RenderIssueTitle(text, nil)
|
||||
}
|
||||
|
||||
func renderCommitBodyLegacy(ctx context.Context, msg string, metas map[string]string) template.HTML {
|
||||
func renderCommitBodyLegacy(ctx context.Context, msg string, _ map[string]string) template.HTML {
|
||||
panicIfDevOrTesting()
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).RenderCommitBody(msg, metas)
|
||||
return NewRenderUtils(reqctx.FromContext(ctx)).RenderCommitBody(msg, nil)
|
||||
}
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/reqctx"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/translation"
|
||||
|
||||
@@ -47,19 +47,8 @@ mail@domain.com
|
||||
return strings.ReplaceAll(s, "<SPACE>", " ")
|
||||
}
|
||||
|
||||
var testMetas = map[string]string{
|
||||
"user": "user13",
|
||||
"repo": "repo11",
|
||||
"repoPath": "../../tests/gitea-repositories-meta/user13/repo11.git/",
|
||||
"markdownNewLineHardBreak": "true",
|
||||
"markupAllowShortIssuePattern": "true",
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
unittest.InitSettingsForTesting()
|
||||
if err := git.InitSimple(context.Background()); err != nil {
|
||||
log.Fatal("git init failed, err: %v", err)
|
||||
}
|
||||
setting.Markdown.RenderOptionsComment.ShortIssuePattern = true
|
||||
markup.Init(&markup.RenderHelperFuncs{
|
||||
IsUsernameMentionable: func(ctx context.Context, username string) bool {
|
||||
return username == "mention-user"
|
||||
@@ -74,46 +63,52 @@ func newTestRenderUtils(t *testing.T) *RenderUtils {
|
||||
return NewRenderUtils(ctx)
|
||||
}
|
||||
|
||||
func TestRenderCommitBody(t *testing.T) {
|
||||
defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableAdditionalAttributes, true)()
|
||||
type args struct {
|
||||
msg string
|
||||
func TestRenderRepoComment(t *testing.T) {
|
||||
mockRepo := &repo.Repository{
|
||||
ID: 1, OwnerName: "user13", Name: "repo11",
|
||||
Owner: &user_model.User{ID: 13, Name: "user13"},
|
||||
Units: []*repo.RepoUnit{},
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want template.HTML
|
||||
}{
|
||||
{
|
||||
name: "multiple lines",
|
||||
args: args{
|
||||
msg: "first line\nsecond line",
|
||||
t.Run("RenderCommitBody", func(t *testing.T) {
|
||||
defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableAdditionalAttributes, true)()
|
||||
type args struct {
|
||||
msg string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want template.HTML
|
||||
}{
|
||||
{
|
||||
name: "multiple lines",
|
||||
args: args{
|
||||
msg: "first line\nsecond line",
|
||||
},
|
||||
want: "second line",
|
||||
},
|
||||
want: "second line",
|
||||
},
|
||||
{
|
||||
name: "multiple lines with leading newlines",
|
||||
args: args{
|
||||
msg: "\n\n\n\nfirst line\nsecond line",
|
||||
{
|
||||
name: "multiple lines with leading newlines",
|
||||
args: args{
|
||||
msg: "\n\n\n\nfirst line\nsecond line",
|
||||
},
|
||||
want: "second line",
|
||||
},
|
||||
want: "second line",
|
||||
},
|
||||
{
|
||||
name: "multiple lines with trailing newlines",
|
||||
args: args{
|
||||
msg: "first line\nsecond line\n\n\n",
|
||||
{
|
||||
name: "multiple lines with trailing newlines",
|
||||
args: args{
|
||||
msg: "first line\nsecond line\n\n\n",
|
||||
},
|
||||
want: "second line",
|
||||
},
|
||||
want: "second line",
|
||||
},
|
||||
}
|
||||
ut := newTestRenderUtils(t)
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
assert.Equalf(t, tt.want, ut.RenderCommitBody(tt.args.msg, nil), "RenderCommitBody(%v, %v)", tt.args.msg, nil)
|
||||
})
|
||||
}
|
||||
}
|
||||
ut := newTestRenderUtils(t)
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
assert.Equalf(t, tt.want, ut.RenderCommitBody(tt.args.msg, mockRepo), "RenderCommitBody(%v, %v)", tt.args.msg, nil)
|
||||
})
|
||||
}
|
||||
|
||||
expected := `/just/a/path.bin
|
||||
expected := `/just/a/path.bin
|
||||
<a href="https://example.com/file.bin">https://example.com/file.bin</a>
|
||||
[local link](file.bin)
|
||||
[remote link](<a href="https://example.com">https://example.com</a>)
|
||||
@@ -132,22 +127,22 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
|
||||
<a href="/mention-user">@mention-user</a> test
|
||||
<a href="/user13/repo11/issues/123" class="ref-issue">#123</a>
|
||||
space`
|
||||
assert.Equal(t, expected, string(newTestRenderUtils(t).RenderCommitBody(testInput(), testMetas)))
|
||||
}
|
||||
assert.Equal(t, expected, string(newTestRenderUtils(t).RenderCommitBody(testInput(), mockRepo)))
|
||||
})
|
||||
|
||||
func TestRenderCommitMessage(t *testing.T) {
|
||||
expected := `space <a href="/mention-user" data-markdown-generated-content="">@mention-user</a> `
|
||||
assert.EqualValues(t, expected, newTestRenderUtils(t).RenderCommitMessage(testInput(), testMetas))
|
||||
}
|
||||
t.Run("RenderCommitMessage", func(t *testing.T) {
|
||||
expected := `space <a href="/mention-user" data-markdown-generated-content="">@mention-user</a> `
|
||||
assert.EqualValues(t, expected, newTestRenderUtils(t).RenderCommitMessage(testInput(), mockRepo))
|
||||
})
|
||||
|
||||
func TestRenderCommitMessageLinkSubject(t *testing.T) {
|
||||
expected := `<a href="https://example.com/link" class="muted">space </a><a href="/mention-user" data-markdown-generated-content="">@mention-user</a>`
|
||||
assert.EqualValues(t, expected, newTestRenderUtils(t).RenderCommitMessageLinkSubject(testInput(), "https://example.com/link", testMetas))
|
||||
}
|
||||
t.Run("RenderCommitMessageLinkSubject", func(t *testing.T) {
|
||||
expected := `<a href="https://example.com/link" class="muted">space </a><a href="/mention-user" data-markdown-generated-content="">@mention-user</a>`
|
||||
assert.EqualValues(t, expected, newTestRenderUtils(t).RenderCommitMessageLinkSubject(testInput(), "https://example.com/link", mockRepo))
|
||||
})
|
||||
|
||||
func TestRenderIssueTitle(t *testing.T) {
|
||||
defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableAdditionalAttributes, true)()
|
||||
expected := ` space @mention-user<SPACE><SPACE>
|
||||
t.Run("RenderIssueTitle", func(t *testing.T) {
|
||||
defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableAdditionalAttributes, true)()
|
||||
expected := ` space @mention-user<SPACE><SPACE>
|
||||
/just/a/path.bin
|
||||
https://example.com/file.bin
|
||||
[local link](file.bin)
|
||||
@@ -168,8 +163,9 @@ mail@domain.com
|
||||
<a href="/user13/repo11/issues/123" class="ref-issue">#123</a>
|
||||
space<SPACE><SPACE>
|
||||
`
|
||||
expected = strings.ReplaceAll(expected, "<SPACE>", " ")
|
||||
assert.Equal(t, expected, string(newTestRenderUtils(t).RenderIssueTitle(testInput(), testMetas)))
|
||||
expected = strings.ReplaceAll(expected, "<SPACE>", " ")
|
||||
assert.Equal(t, expected, string(newTestRenderUtils(t).RenderIssueTitle(testInput(), mockRepo)))
|
||||
})
|
||||
}
|
||||
|
||||
func TestRenderMarkdownToHtml(t *testing.T) {
|
||||
|
||||
@@ -130,6 +130,7 @@ pin = Pin
|
||||
unpin = Unpin
|
||||
|
||||
artifacts = Artifacts
|
||||
expired = Expired
|
||||
confirm_delete_artifact = Are you sure you want to delete the artifact '%s' ?
|
||||
|
||||
archived = Archived
|
||||
|
||||
@@ -895,6 +895,15 @@ func EditIssue(ctx *context.APIContext) {
|
||||
issue.MilestoneID != *form.Milestone {
|
||||
oldMilestoneID := issue.MilestoneID
|
||||
issue.MilestoneID = *form.Milestone
|
||||
if issue.MilestoneID > 0 {
|
||||
issue.Milestone, err = issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, *form.Milestone)
|
||||
if err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
issue.Milestone = nil
|
||||
}
|
||||
if err = issue_service.ChangeMilestoneAssign(ctx, issue, ctx.Doer, oldMilestoneID); err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
|
||||
@@ -609,15 +609,17 @@ func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption)
|
||||
return
|
||||
}
|
||||
|
||||
oldContent := comment.Content
|
||||
comment.Content = form.Body
|
||||
if err := issue_service.UpdateComment(ctx, comment, comment.ContentVersion, ctx.Doer, oldContent); err != nil {
|
||||
if errors.Is(err, user_model.ErrBlockedUser) {
|
||||
ctx.APIError(http.StatusForbidden, err)
|
||||
} else {
|
||||
ctx.APIErrorInternal(err)
|
||||
if form.Body != comment.Content {
|
||||
oldContent := comment.Content
|
||||
comment.Content = form.Body
|
||||
if err := issue_service.UpdateComment(ctx, comment, comment.ContentVersion, ctx.Doer, oldContent); err != nil {
|
||||
if errors.Is(err, user_model.ErrBlockedUser) {
|
||||
ctx.APIError(http.StatusForbidden, err)
|
||||
} else {
|
||||
ctx.APIErrorInternal(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIComment(ctx, ctx.Repo.Repository, comment))
|
||||
|
||||
@@ -706,6 +706,11 @@ func EditPullRequest(ctx *context.APIContext) {
|
||||
issue.MilestoneID != form.Milestone {
|
||||
oldMilestoneID := issue.MilestoneID
|
||||
issue.MilestoneID = form.Milestone
|
||||
issue.Milestone, err = issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, form.Milestone)
|
||||
if err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
}
|
||||
if err = issue_service.ChangeMilestoneAssign(ctx, issue, ctx.Doer, oldMilestoneID); err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
@@ -1632,7 +1637,9 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
||||
|
||||
apiFiles := make([]*api.ChangedFile, 0, limit)
|
||||
for i := start; i < start+limit; i++ {
|
||||
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.HeadRepo, endCommitID))
|
||||
// refs/pull/1/head stores the HEAD commit ID, allowing all related commits to be found in the base repository.
|
||||
// The head repository might have been deleted, so we should not rely on it here.
|
||||
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.BaseRepo, endCommitID))
|
||||
}
|
||||
|
||||
ctx.SetLinkHeader(totalNumberOfFiles, listOptions.PageSize)
|
||||
|
||||
@@ -62,6 +62,8 @@ func ListAccessTokens(ctx *context.APIContext) {
|
||||
Name: tokens[i].Name,
|
||||
TokenLastEight: tokens[i].TokenLastEight,
|
||||
Scopes: tokens[i].Scope.StringSlice(),
|
||||
Created: tokens[i].CreatedUnix.AsTime(),
|
||||
Updated: tokens[i].UpdatedUnix.AsTime(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||
}
|
||||
|
||||
if len(cols) > 0 {
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, cols...); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, cols...); err != nil {
|
||||
log.Error("Failed to Update: %s/%s Error: %v", ownerName, repoName, err)
|
||||
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
|
||||
Err: fmt.Sprintf("Failed to Update: %s/%s Error: %v", ownerName, repoName, err),
|
||||
|
||||
@@ -81,6 +81,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
ownerName := ctx.PathParam("owner")
|
||||
repoName := ctx.PathParam("repo")
|
||||
mode := perm.AccessMode(ctx.FormInt("mode"))
|
||||
verb := ctx.FormString("verb")
|
||||
|
||||
// Set the basic parts of the results to return
|
||||
results := private.ServCommandResults{
|
||||
@@ -295,8 +296,11 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// Because of the special ref "refs/for" we will need to delay write permission check
|
||||
if git.DefaultFeatures().SupportProcReceive && unitType == unit.TypeCode {
|
||||
// Because of the special ref "refs/for" (AGit) we will need to delay write permission check,
|
||||
// AGit flow needs to write its own ref when the doer has "reader" permission (allowing to create PR).
|
||||
// The real permission check is done in HookPreReceive (routers/private/hook_pre_receive.go).
|
||||
// Here it should relax the permission check for "git push (git-receive-pack)", but not for others like LFS operations.
|
||||
if git.DefaultFeatures().SupportProcReceive && unitType == unit.TypeCode && verb == git.CmdVerbReceivePack {
|
||||
mode = perm.AccessModeRead
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,16 @@ func MockActionsRunsJobs(ctx *context.Context) {
|
||||
Size: 1024 * 1024,
|
||||
Status: "completed",
|
||||
})
|
||||
resp.Artifacts = append(resp.Artifacts, &actions.ArtifactsViewItem{
|
||||
Name: "artifact-very-loooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
|
||||
Size: 100 * 1024,
|
||||
Status: "expired",
|
||||
})
|
||||
resp.Artifacts = append(resp.Artifacts, &actions.ArtifactsViewItem{
|
||||
Name: "artifact-really-loooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
|
||||
Size: 1024 * 1024,
|
||||
Status: "completed",
|
||||
})
|
||||
|
||||
resp.State.Run.Jobs = append(resp.State.Run.Jobs, &actions.ViewJob{
|
||||
ID: runID * 10,
|
||||
|
||||
@@ -201,7 +201,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio
|
||||
switch act.OpType {
|
||||
case activities_model.ActionCommitRepo, activities_model.ActionMirrorSyncPush:
|
||||
push := templates.ActionContent2Commits(act)
|
||||
|
||||
_ = act.LoadRepo(ctx)
|
||||
for _, commit := range push.Commits {
|
||||
if len(desc) != 0 {
|
||||
desc += "\n\n"
|
||||
@@ -209,7 +209,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio
|
||||
desc += fmt.Sprintf("<a href=\"%s\">%s</a>\n%s",
|
||||
html.EscapeString(fmt.Sprintf("%s/commit/%s", act.GetRepoAbsoluteLink(ctx), commit.Sha1)),
|
||||
commit.Sha1,
|
||||
renderUtils.RenderCommitMessage(commit.Message, nil),
|
||||
renderUtils.RenderCommitMessage(commit.Message, act.Repo),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -200,13 +200,9 @@ func ViewPost(ctx *context_module.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: "ComposeCommentMetas" (usually for comment) is not quite right, but it is still the same as what template "RenderCommitMessage" does.
|
||||
// need to be refactored together in the future
|
||||
metas := ctx.Repo.Repository.ComposeCommentMetas(ctx)
|
||||
|
||||
// the title for the "run" is from the commit message
|
||||
resp.State.Run.Title = run.Title
|
||||
resp.State.Run.TitleHTML = templates.NewRenderUtils(ctx).RenderCommitMessage(run.Title, metas)
|
||||
resp.State.Run.TitleHTML = templates.NewRenderUtils(ctx).RenderCommitMessage(run.Title, ctx.Repo.Repository)
|
||||
resp.State.Run.Link = run.Link()
|
||||
resp.State.Run.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
|
||||
resp.State.Run.CanApprove = run.NeedApproval && ctx.Repo.CanWrite(unit.TypeActions)
|
||||
@@ -588,20 +584,20 @@ func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*actions
|
||||
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
|
||||
if err != nil {
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.HTTPError(http.StatusNotFound, err.Error())
|
||||
ctx.NotFound(nil)
|
||||
return nil, nil
|
||||
}
|
||||
ctx.HTTPError(http.StatusInternalServerError, err.Error())
|
||||
ctx.ServerError("GetRunByIndex", err)
|
||||
return nil, nil
|
||||
}
|
||||
run.Repo = ctx.Repo.Repository
|
||||
jobs, err := actions_model.GetRunJobsByRunID(ctx, run.ID)
|
||||
if err != nil {
|
||||
ctx.HTTPError(http.StatusInternalServerError, err.Error())
|
||||
ctx.ServerError("GetRunJobsByRunID", err)
|
||||
return nil, nil
|
||||
}
|
||||
if len(jobs) == 0 {
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
ctx.NotFound(nil)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -401,12 +401,11 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
|
||||
ci.HeadRepo = ctx.Repo.Repository
|
||||
ci.HeadGitRepo = ctx.Repo.GitRepo
|
||||
} else if has {
|
||||
ci.HeadGitRepo, err = gitrepo.OpenRepository(ctx, ci.HeadRepo)
|
||||
ci.HeadGitRepo, err = gitrepo.RepositoryFromRequestContextOrOpen(ctx, ci.HeadRepo)
|
||||
if err != nil {
|
||||
ctx.ServerError("OpenRepository", err)
|
||||
ctx.ServerError("RepositoryFromRequestContextOrOpen", err)
|
||||
return nil
|
||||
}
|
||||
defer ci.HeadGitRepo.Close()
|
||||
} else {
|
||||
ctx.NotFound(nil)
|
||||
return nil
|
||||
@@ -721,11 +720,6 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
|
||||
// CompareDiff show different from one commit to another commit
|
||||
func CompareDiff(ctx *context.Context) {
|
||||
ci := ParseCompareInfo(ctx)
|
||||
defer func() {
|
||||
if ci != nil && ci.HeadGitRepo != nil {
|
||||
ci.HeadGitRepo.Close()
|
||||
}
|
||||
}()
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/templates"
|
||||
"code.gitea.io/gitea/modules/typesniffer"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers/utils"
|
||||
@@ -151,9 +150,13 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||
return
|
||||
}
|
||||
|
||||
dataRc, err := blob.DataAsync()
|
||||
buf, dataRc, fInfo, err := getFileReader(ctx, ctx.Repo.Repository.ID, blob)
|
||||
if err != nil {
|
||||
ctx.NotFound(err)
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("getFileReader", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -161,12 +164,8 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||
|
||||
ctx.Data["FileSize"] = blob.Size()
|
||||
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := util.ReadAtMost(dataRc, buf)
|
||||
buf = buf[:n]
|
||||
|
||||
// Only some file types are editable online as text.
|
||||
if !typesniffer.DetectContentType(buf).IsRepresentableAsText() {
|
||||
if !fInfo.st.IsRepresentableAsText() || fInfo.isLFSFile {
|
||||
ctx.NotFound(nil)
|
||||
return
|
||||
}
|
||||
@@ -377,12 +376,6 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
if isEmpty, err := ctx.Repo.GitRepo.IsEmpty(); err == nil && !isEmpty {
|
||||
_ = repo_model.UpdateRepositoryCols(ctx, &repo_model.Repository{ID: ctx.Repo.Repository.ID, IsEmpty: false}, "is_empty")
|
||||
}
|
||||
}
|
||||
|
||||
redirectForCommitChoice(ctx, form.CommitChoice, branchName, form.TreePath)
|
||||
}
|
||||
|
||||
@@ -791,7 +784,7 @@ func UploadFilePost(ctx *context.Context) {
|
||||
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
if isEmpty, err := ctx.Repo.GitRepo.IsEmpty(); err == nil && !isEmpty {
|
||||
_ = repo_model.UpdateRepositoryCols(ctx, &repo_model.Repository{ID: ctx.Repo.Repository.ID, IsEmpty: false}, "is_empty")
|
||||
_ = repo_model.UpdateRepositoryColsWithAutoTime(ctx, &repo_model.Repository{ID: ctx.Repo.Repository.ID, IsEmpty: false}, "is_empty")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,6 +418,16 @@ func UpdateIssueMilestone(ctx *context.Context) {
|
||||
continue
|
||||
}
|
||||
issue.MilestoneID = milestoneID
|
||||
if milestoneID > 0 {
|
||||
var err error
|
||||
issue.Milestone, err = issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, milestoneID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneByRepoID", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
issue.Milestone = nil
|
||||
}
|
||||
if err := issue_service.ChangeMilestoneAssign(ctx, issue, ctx.Doer, oldMilestoneID); err != nil {
|
||||
ctx.ServerError("ChangeMilestoneAssign", err)
|
||||
return
|
||||
|
||||
@@ -239,23 +239,30 @@ func UpdateCommentContent(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
oldContent := comment.Content
|
||||
newContent := ctx.FormString("content")
|
||||
contentVersion := ctx.FormInt("content_version")
|
||||
|
||||
// allow to save empty content
|
||||
comment.Content = newContent
|
||||
if err = issue_service.UpdateComment(ctx, comment, contentVersion, ctx.Doer, oldContent); err != nil {
|
||||
if errors.Is(err, user_model.ErrBlockedUser) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_user"))
|
||||
} else if errors.Is(err, issues_model.ErrCommentAlreadyChanged) {
|
||||
ctx.JSONError(ctx.Tr("repo.comments.edit.already_changed"))
|
||||
} else {
|
||||
ctx.ServerError("UpdateComment", err)
|
||||
}
|
||||
if contentVersion != comment.ContentVersion {
|
||||
ctx.JSONError(ctx.Tr("repo.comments.edit.already_changed"))
|
||||
return
|
||||
}
|
||||
|
||||
if newContent != comment.Content {
|
||||
// allow to save empty content
|
||||
oldContent := comment.Content
|
||||
comment.Content = newContent
|
||||
|
||||
if err = issue_service.UpdateComment(ctx, comment, contentVersion, ctx.Doer, oldContent); err != nil {
|
||||
if errors.Is(err, user_model.ErrBlockedUser) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_user"))
|
||||
} else if errors.Is(err, issues_model.ErrCommentAlreadyChanged) {
|
||||
ctx.JSONError(ctx.Tr("repo.comments.edit.already_changed"))
|
||||
} else {
|
||||
ctx.ServerError("UpdateComment", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := comment.LoadAttachments(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachments", err)
|
||||
return
|
||||
|
||||
@@ -1290,11 +1290,6 @@ func CompareAndPullRequestPost(ctx *context.Context) {
|
||||
)
|
||||
|
||||
ci := ParseCompareInfo(ctx)
|
||||
defer func() {
|
||||
if ci != nil && ci.HeadGitRepo != nil {
|
||||
ci.HeadGitRepo.Close()
|
||||
}
|
||||
}()
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
giturl "code.gitea.io/gitea/modules/git/url"
|
||||
"code.gitea.io/gitea/modules/gitrepo"
|
||||
"code.gitea.io/gitea/modules/httplib"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
@@ -261,6 +262,10 @@ func updateContextRepoEmptyAndStatus(ctx *context.Context, empty bool, status re
|
||||
|
||||
func handleRepoEmptyOrBroken(ctx *context.Context) {
|
||||
showEmpty := true
|
||||
if ctx.Repo.GitRepo == nil {
|
||||
// in case the repo really exists and works, but the status was incorrectly marked as "broken", we need to open and check it again
|
||||
ctx.Repo.GitRepo, _ = gitrepo.RepositoryFromRequestContextOrOpen(ctx, ctx.Repo.Repository)
|
||||
}
|
||||
if ctx.Repo.GitRepo != nil {
|
||||
reallyEmpty, err := ctx.Repo.GitRepo.IsEmpty()
|
||||
if err != nil {
|
||||
@@ -396,10 +401,8 @@ func Home(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
prepareHomeTreeSideBarSwitch(ctx)
|
||||
|
||||
title := ctx.Repo.Repository.Owner.Name + "/" + ctx.Repo.Repository.Name
|
||||
if len(ctx.Repo.Repository.Description) > 0 {
|
||||
if ctx.Repo.Repository.Description != "" {
|
||||
title += ": " + ctx.Repo.Repository.Description
|
||||
}
|
||||
ctx.Data["Title"] = title
|
||||
@@ -412,6 +415,8 @@ func Home(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
prepareHomeTreeSideBarSwitch(ctx)
|
||||
|
||||
// get the current git entry which doer user is currently looking at.
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath)
|
||||
if err != nil {
|
||||
|
||||
@@ -109,7 +109,7 @@ func findWikiRepoCommit(ctx *context.Context) (*git.Repository, *git.Commit, err
|
||||
return wikiGitRepo, nil, errBranch
|
||||
}
|
||||
// update the default branch in the database
|
||||
errDb := repo_model.UpdateRepositoryCols(ctx, &repo_model.Repository{ID: ctx.Repo.Repository.ID, DefaultWikiBranch: gitRepoDefaultBranch}, "default_wiki_branch")
|
||||
errDb := repo_model.UpdateRepositoryColsNoAutoTime(ctx, &repo_model.Repository{ID: ctx.Repo.Repository.ID, DefaultWikiBranch: gitRepoDefaultBranch}, "default_wiki_branch")
|
||||
if errDb != nil {
|
||||
return wikiGitRepo, nil, errDb
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ func TestDefaultWikiBranch(t *testing.T) {
|
||||
assert.NoError(t, wiki_service.ChangeDefaultWikiBranch(db.DefaultContext, repoWithNoWiki, "main"))
|
||||
|
||||
// repo with wiki
|
||||
assert.NoError(t, repo_model.UpdateRepositoryCols(db.DefaultContext, &repo_model.Repository{ID: 1, DefaultWikiBranch: "wrong-branch"}))
|
||||
assert.NoError(t, repo_model.UpdateRepositoryColsNoAutoTime(db.DefaultContext, &repo_model.Repository{ID: 1, DefaultWikiBranch: "wrong-branch"}))
|
||||
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki")
|
||||
ctx.SetPathParam("*", "Home")
|
||||
|
||||
@@ -795,8 +795,8 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
|
||||
return func(ctx *Context) {
|
||||
var err error
|
||||
refType := detectRefType
|
||||
if ctx.Repo.Repository.IsBeingCreated() {
|
||||
return // no git repo, so do nothing, users will see a "migrating" UI provided by "migrate/migrating.tmpl"
|
||||
if ctx.Repo.Repository.IsBeingCreated() || ctx.Repo.Repository.IsBroken() {
|
||||
return // no git repo, so do nothing, users will see a "migrating" UI provided by "migrate/migrating.tmpl", or empty repo guide
|
||||
}
|
||||
// Empty repository does not have reference information.
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
|
||||
@@ -197,13 +197,22 @@ func ToBranchProtection(ctx context.Context, bp *git_model.ProtectedBranch, repo
|
||||
|
||||
// ToTag convert a git.Tag to an api.Tag
|
||||
func ToTag(repo *repo_model.Repository, t *git.Tag) *api.Tag {
|
||||
tarballURL := util.URLJoin(repo.HTMLURL(), "archive", t.Name+".tar.gz")
|
||||
zipballURL := util.URLJoin(repo.HTMLURL(), "archive", t.Name+".zip")
|
||||
|
||||
// Archive URLs are "" if the download feature is disabled
|
||||
if setting.Repository.DisableDownloadSourceArchives {
|
||||
tarballURL = ""
|
||||
zipballURL = ""
|
||||
}
|
||||
|
||||
return &api.Tag{
|
||||
Name: t.Name,
|
||||
Message: strings.TrimSpace(t.Message),
|
||||
ID: t.ID.String(),
|
||||
Commit: ToCommitMeta(repo, t),
|
||||
ZipballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".zip"),
|
||||
TarballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".tar.gz"),
|
||||
ZipballURL: zipballURL,
|
||||
TarballURL: tarballURL,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,6 +316,7 @@ func ToPublicKey(apiLink string, key *asymkey_model.PublicKey) *api.PublicKey {
|
||||
Title: key.Name,
|
||||
Fingerprint: key.Fingerprint,
|
||||
Created: key.CreatedUnix.AsTime(),
|
||||
Updated: key.UpdatedUnix.AsTime(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ package migrations
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/google/go-github/v61/github"
|
||||
"github.com/google/go-github/v71/github"
|
||||
)
|
||||
|
||||
// ErrRepoNotCreated returns the error that repository not created
|
||||
|
||||
@@ -148,7 +148,7 @@ func (g *GiteaLocalUploader) CreateRepo(ctx context.Context, repo *base.Reposito
|
||||
return err
|
||||
}
|
||||
g.repo.ObjectFormatName = objectFormat.Name()
|
||||
return repo_model.UpdateRepositoryCols(ctx, g.repo, "object_format_name")
|
||||
return repo_model.UpdateRepositoryColsNoAutoTime(ctx, g.repo, "object_format_name")
|
||||
}
|
||||
|
||||
// Close closes this uploader
|
||||
@@ -975,7 +975,7 @@ func (g *GiteaLocalUploader) Finish(ctx context.Context) error {
|
||||
}
|
||||
|
||||
g.repo.Status = repo_model.RepositoryReady
|
||||
return repo_model.UpdateRepositoryCols(ctx, g.repo, "status")
|
||||
return repo_model.UpdateRepositoryColsWithAutoTime(ctx, g.repo, "status")
|
||||
}
|
||||
|
||||
func (g *GiteaLocalUploader) remapUser(ctx context.Context, source user_model.ExternalUserMigrated, target user_model.ExternalUserRemappable) error {
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/proxy"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
|
||||
"github.com/google/go-github/v61/github"
|
||||
"github.com/google/go-github/v71/github"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
@@ -441,9 +441,11 @@ func (g *GithubDownloaderV3) GetIssues(ctx context.Context, page, perPage int) (
|
||||
if !g.SkipReactions {
|
||||
for i := 1; ; i++ {
|
||||
g.waitAndPickClient(ctx)
|
||||
res, resp, err := g.getClient().Reactions.ListIssueReactions(ctx, g.repoOwner, g.repoName, issue.GetNumber(), &github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: perPage,
|
||||
res, resp, err := g.getClient().Reactions.ListIssueReactions(ctx, g.repoOwner, g.repoName, issue.GetNumber(), &github.ListReactionOptions{
|
||||
ListOptions: github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: perPage,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -527,9 +529,11 @@ func (g *GithubDownloaderV3) getComments(ctx context.Context, commentable base.C
|
||||
if !g.SkipReactions {
|
||||
for i := 1; ; i++ {
|
||||
g.waitAndPickClient(ctx)
|
||||
res, resp, err := g.getClient().Reactions.ListIssueCommentReactions(ctx, g.repoOwner, g.repoName, comment.GetID(), &github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: g.maxPerPage,
|
||||
res, resp, err := g.getClient().Reactions.ListIssueCommentReactions(ctx, g.repoOwner, g.repoName, comment.GetID(), &github.ListReactionOptions{
|
||||
ListOptions: github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: g.maxPerPage,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -602,9 +606,11 @@ func (g *GithubDownloaderV3) GetAllComments(ctx context.Context, page, perPage i
|
||||
if !g.SkipReactions {
|
||||
for i := 1; ; i++ {
|
||||
g.waitAndPickClient(ctx)
|
||||
res, resp, err := g.getClient().Reactions.ListIssueCommentReactions(ctx, g.repoOwner, g.repoName, comment.GetID(), &github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: g.maxPerPage,
|
||||
res, resp, err := g.getClient().Reactions.ListIssueCommentReactions(ctx, g.repoOwner, g.repoName, comment.GetID(), &github.ListReactionOptions{
|
||||
ListOptions: github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: g.maxPerPage,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -673,9 +679,11 @@ func (g *GithubDownloaderV3) GetPullRequests(ctx context.Context, page, perPage
|
||||
if !g.SkipReactions {
|
||||
for i := 1; ; i++ {
|
||||
g.waitAndPickClient(ctx)
|
||||
res, resp, err := g.getClient().Reactions.ListIssueReactions(ctx, g.repoOwner, g.repoName, pr.GetNumber(), &github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: perPage,
|
||||
res, resp, err := g.getClient().Reactions.ListIssueReactions(ctx, g.repoOwner, g.repoName, pr.GetNumber(), &github.ListReactionOptions{
|
||||
ListOptions: github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: perPage,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -760,9 +768,11 @@ func (g *GithubDownloaderV3) convertGithubReviewComments(ctx context.Context, cs
|
||||
if !g.SkipReactions {
|
||||
for i := 1; ; i++ {
|
||||
g.waitAndPickClient(ctx)
|
||||
res, resp, err := g.getClient().Reactions.ListPullRequestCommentReactions(ctx, g.repoOwner, g.repoName, c.GetID(), &github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: g.maxPerPage,
|
||||
res, resp, err := g.getClient().Reactions.ListPullRequestCommentReactions(ctx, g.repoOwner, g.repoName, c.GetID(), &github.ListReactionOptions{
|
||||
ListOptions: github.ListOptions{
|
||||
Page: i,
|
||||
PerPage: g.maxPerPage,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -71,7 +71,7 @@ func UpdateAddress(ctx context.Context, m *repo_model.Mirror, addr string) error
|
||||
// erase authentication before storing in database
|
||||
u.User = nil
|
||||
m.Repo.OriginalURL = u.String()
|
||||
return repo_model.UpdateRepositoryCols(ctx, m.Repo, "original_url")
|
||||
return repo_model.UpdateRepositoryColsNoAutoTime(ctx, m.Repo, "original_url")
|
||||
}
|
||||
|
||||
// mirrorSyncResult contains information of a updated reference.
|
||||
@@ -653,7 +653,7 @@ func checkAndUpdateEmptyRepository(ctx context.Context, m *repo_model.Mirror, re
|
||||
}
|
||||
m.Repo.IsEmpty = false
|
||||
// Update the is empty and default_branch columns
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, m.Repo, "default_branch", "is_empty"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsWithAutoTime(ctx, m.Repo, "default_branch", "is_empty"); err != nil {
|
||||
log.Error("Failed to update default branch of repository %-v. Error: %v", m.Repo, err)
|
||||
desc := fmt.Sprintf("Failed to update default branch of repository '%s': %v", m.Repo.RepoPath(), err)
|
||||
if err = system_model.CreateRepositoryNotice(desc); err != nil {
|
||||
|
||||
@@ -64,10 +64,11 @@ func RemoveOrgUser(ctx context.Context, org *organization.Organization, user *us
|
||||
if err != nil {
|
||||
return fmt.Errorf("AccessibleReposEnv: %w", err)
|
||||
}
|
||||
repoIDs, err := env.RepoIDs(ctx, 1, org.NumRepos)
|
||||
repoIDs, err := env.RepoIDs(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetUserRepositories [%d]: %w", user.ID, err)
|
||||
}
|
||||
|
||||
for _, repoID := range repoIDs {
|
||||
repo, err := repo_model.GetRepositoryByID(ctx, repoID)
|
||||
if err != nil {
|
||||
|
||||
@@ -100,7 +100,7 @@ func AdoptRepository(ctx context.Context, doer, owner *user_model.User, opts Cre
|
||||
|
||||
// 4 - update repository status
|
||||
repo.Status = repo_model.RepositoryReady
|
||||
if err = repo_model.UpdateRepositoryCols(ctx, repo, "status"); err != nil {
|
||||
if err = repo_model.UpdateRepositoryColsWithAutoTime(ctx, repo, "status"); err != nil {
|
||||
return nil, fmt.Errorf("UpdateRepositoryCols: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func UploadAvatar(ctx context.Context, repo *repo_model.Repository, data []byte)
|
||||
// Users can upload the same image to other repo - prefix it with ID
|
||||
// Then repo will be removed - only it avatar file will be removed
|
||||
repo.Avatar = newAvatar
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "avatar"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "avatar"); err != nil {
|
||||
return fmt.Errorf("UploadAvatar: Update repository avatar: %w", err)
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func DeleteAvatar(ctx context.Context, repo *repo_model.Repository) error {
|
||||
defer committer.Close()
|
||||
|
||||
repo.Avatar = ""
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "avatar"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "avatar"); err != nil {
|
||||
return fmt.Errorf("DeleteAvatar: Update repository avatar: %w", err)
|
||||
}
|
||||
|
||||
@@ -112,5 +112,5 @@ func generateAvatar(ctx context.Context, templateRepo, generateRepo *repo_model.
|
||||
return err
|
||||
}
|
||||
|
||||
return repo_model.UpdateRepositoryCols(ctx, generateRepo, "avatar")
|
||||
return repo_model.UpdateRepositoryColsNoAutoTime(ctx, generateRepo, "avatar")
|
||||
}
|
||||
@@ -663,6 +663,11 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, newB
|
||||
}
|
||||
}
|
||||
|
||||
// clear divergence cache
|
||||
if err := DelRepoDivergenceFromCache(ctx, repo.ID); err != nil {
|
||||
log.Error("DelRepoDivergenceFromCache: %v", err)
|
||||
}
|
||||
|
||||
notify_service.ChangeDefaultBranch(ctx, repo)
|
||||
|
||||
return nil
|
||||
|
||||
@@ -321,7 +321,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, owner *user_model.User,
|
||||
// 7 - update repository status to be ready
|
||||
if needsUpdateToReady {
|
||||
repo.Status = repo_model.RepositoryReady
|
||||
if err = repo_model.UpdateRepositoryCols(ctx, repo, "status"); err != nil {
|
||||
if err = repo_model.UpdateRepositoryColsWithAutoTime(ctx, repo, "status"); err != nil {
|
||||
return nil, fmt.Errorf("UpdateRepositoryCols: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
|
||||
|
||||
if repo.IsEmpty {
|
||||
if isEmpty, err := gitRepo.IsEmpty(); err == nil && !isEmpty {
|
||||
_ = repo_model.UpdateRepositoryCols(ctx, &repo_model.Repository{ID: repo.ID, IsEmpty: false, DefaultBranch: opts.NewBranch}, "is_empty", "default_branch")
|
||||
_ = repo_model.UpdateRepositoryColsWithAutoTime(ctx, &repo_model.Repository{ID: repo.ID, IsEmpty: false, DefaultBranch: opts.NewBranch}, "is_empty", "default_branch")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
|
||||
}
|
||||
|
||||
var attributesMap map[string]*attribute.Attributes
|
||||
// when uploading to an empty repo, the old branch doesn't exist, but some "global gitattributes" or "info/attributes" may exist
|
||||
if setting.LFS.StartServer {
|
||||
attributesMap, err = attribute.CheckAttributes(ctx, t.gitRepo, "" /* use temp repo's working dir */, attribute.CheckAttributeOpts{
|
||||
Attributes: []string{attribute.Filter},
|
||||
@@ -118,6 +119,12 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
|
||||
}
|
||||
|
||||
// Copy uploaded files into repository.
|
||||
// TODO: there is a small problem: when uploading LFS files with ".gitattributes", the "check-attr" runs before this loop,
|
||||
// so LFS files are not able to be added as LFS objects. Ideally we need to do in 3 steps in the future:
|
||||
// 1. Add ".gitattributes" to git index
|
||||
// 2. Run "check-attr" (the previous attribute.CheckAttributes call)
|
||||
// 3. Add files to git index (this loop)
|
||||
// This problem is trivial so maybe no need to spend too much time on it at the moment.
|
||||
for i := range infos {
|
||||
if err := copyUploadedLFSFileIntoRepository(ctx, &infos[i], attributesMap, t, opts.TreePath); err != nil {
|
||||
return err
|
||||
|
||||
@@ -198,7 +198,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork
|
||||
|
||||
// 8 - update repository status to be ready
|
||||
repo.Status = repo_model.RepositoryReady
|
||||
if err = repo_model.UpdateRepositoryCols(ctx, repo, "status"); err != nil {
|
||||
if err = repo_model.UpdateRepositoryColsWithAutoTime(ctx, repo, "status"); err != nil {
|
||||
return nil, fmt.Errorf("UpdateRepositoryCols: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ func pushNewBranch(ctx context.Context, repo *repo_model.Repository, pusher *use
|
||||
}
|
||||
}
|
||||
// Update the is empty and default_branch columns
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "default_branch", "is_empty"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsWithAutoTime(ctx, repo, "default_branch", "is_empty"); err != nil {
|
||||
return nil, fmt.Errorf("UpdateRepositoryCols: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ func updateRepository(ctx context.Context, repo *repo_model.Repository, visibili
|
||||
|
||||
e := db.GetEngine(ctx)
|
||||
|
||||
if _, err = e.ID(repo.ID).AllCols().Update(repo); err != nil {
|
||||
if _, err = e.ID(repo.ID).NoAutoTime().AllCols().Update(repo); err != nil {
|
||||
return fmt.Errorf("update: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ
|
||||
|
||||
// 6 - update repository status to be ready
|
||||
generateRepo.Status = repo_model.RepositoryReady
|
||||
if err = repo_model.UpdateRepositoryCols(ctx, generateRepo, "status"); err != nil {
|
||||
if err = repo_model.UpdateRepositoryColsWithAutoTime(ctx, generateRepo, "status"); err != nil {
|
||||
return nil, fmt.Errorf("UpdateRepositoryCols: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ func transferOwnership(ctx context.Context, doer *user_model.User, newOwnerName
|
||||
repo.OwnerName = newOwner.Name
|
||||
|
||||
// Update repository.
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "owner_id", "owner_name"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "owner_id", "owner_name"); err != nil {
|
||||
return fmt.Errorf("update owner: %w", err)
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ func transferOwnership(ctx context.Context, doer *user_model.User, newOwnerName
|
||||
return fmt.Errorf("deleteRepositoryTransfer: %w", err)
|
||||
}
|
||||
repo.Status = repo_model.RepositoryReady
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "status"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "status"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ func RejectRepositoryTransfer(ctx context.Context, repo *repo_model.Repository,
|
||||
}
|
||||
|
||||
repo.Status = repo_model.RepositoryReady
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "status"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "status"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ func CancelRepositoryTransfer(ctx context.Context, repoTransfer *repo_model.Repo
|
||||
}
|
||||
|
||||
repoTransfer.Repo.Status = repo_model.RepositoryReady
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repoTransfer.Repo, "status"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repoTransfer.Repo, "status"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ func ChangeDefaultWikiBranch(ctx context.Context, repo *repo_model.Repository, n
|
||||
}
|
||||
return db.WithTx(ctx, func(ctx context.Context) error {
|
||||
repo.DefaultWikiBranch = newBranch
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "default_wiki_branch"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "default_wiki_branch"); err != nil {
|
||||
return fmt.Errorf("unable to update database: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
data-locale-status-skipped="{{ctx.Locale.Tr "actions.status.skipped"}}"
|
||||
data-locale-status-blocked="{{ctx.Locale.Tr "actions.status.blocked"}}"
|
||||
data-locale-artifacts-title="{{ctx.Locale.Tr "artifacts"}}"
|
||||
data-locale-artifact-expired="{{ctx.Locale.Tr "expired"}}"
|
||||
data-locale-confirm-delete-artifact="{{ctx.Locale.Tr "confirm_delete_artifact"}}"
|
||||
data-locale-show-timestamps="{{ctx.Locale.Tr "show_timestamps"}}"
|
||||
data-locale-show-log-seconds="{{ctx.Locale.Tr "show_log_seconds"}}"
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="flex-text-block">
|
||||
<a class="gt-ellipsis" href="{{.RepoLink}}/src/branch/{{PathEscapeSegments .DefaultBranchBranch.DBBranch.Name}}">{{.DefaultBranchBranch.DBBranch.Name}}</a>
|
||||
<a class="gt-ellipsis branch-name" href="{{.RepoLink}}/src/branch/{{PathEscapeSegments .DefaultBranchBranch.DBBranch.Name}}">{{.DefaultBranchBranch.DBBranch.Name}}</a>
|
||||
{{if .DefaultBranchBranch.IsProtected}}
|
||||
<span data-tooltip-content="{{ctx.Locale.Tr "repo.settings.protected_branch"}}">{{svg "octicon-shield-lock"}}</span>
|
||||
{{end}}
|
||||
<button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button>
|
||||
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}}
|
||||
</div>
|
||||
<p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{ctx.RenderUtils.RenderCommitMessage .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeCommentMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .DefaultBranchBranch.DBBranch.CommitTime}}{{if .DefaultBranchBranch.DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
|
||||
<p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{ctx.RenderUtils.RenderCommitMessage .DefaultBranchBranch.DBBranch.CommitMessage .Repository}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .DefaultBranchBranch.DBBranch.CommitTime}}{{if .DefaultBranchBranch.DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
|
||||
</td>
|
||||
{{/* FIXME: here and below, the tw-overflow-visible is not quite right but it is still needed the moment: to show the important buttons when the width is narrow */}}
|
||||
<td class="tw-text-right tw-overflow-visible">
|
||||
@@ -90,20 +90,20 @@
|
||||
<td class="eight wide">
|
||||
{{if .DBBranch.IsDeleted}}
|
||||
<div class="flex-text-block">
|
||||
<span class="gt-ellipsis">{{.DBBranch.Name}}</span>
|
||||
<span class="gt-ellipsis branch-name">{{.DBBranch.Name}}</span>
|
||||
<button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button>
|
||||
</div>
|
||||
<p class="info">{{ctx.Locale.Tr "repo.branch.deleted_by" .DBBranch.DeletedBy.Name}} {{DateUtils.TimeSince .DBBranch.DeletedUnix}}</p>
|
||||
{{else}}
|
||||
<div class="flex-text-block">
|
||||
<a class="gt-ellipsis" href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments .DBBranch.Name}}">{{.DBBranch.Name}}</a>
|
||||
<a class="gt-ellipsis branch-name" href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments .DBBranch.Name}}">{{.DBBranch.Name}}</a>
|
||||
{{if .IsProtected}}
|
||||
<span data-tooltip-content="{{ctx.Locale.Tr "repo.settings.protected_branch"}}">{{svg "octicon-shield-lock"}}</span>
|
||||
{{end}}
|
||||
<button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button>
|
||||
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}}
|
||||
</div>
|
||||
<p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{ctx.RenderUtils.RenderCommitMessage .DBBranch.CommitMessage ($.Repository.ComposeCommentMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .DBBranch.CommitTime}}{{if .DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
|
||||
<p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{ctx.RenderUtils.RenderCommitMessage .DBBranch.CommitMessage $.Repository}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .DBBranch.CommitTime}}{{if .DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
|
||||
{{end}}
|
||||
</td>
|
||||
<td class="two wide ui">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="ui container fluid padded">
|
||||
<div class="ui top attached header clearing segment tw-relative commit-header">
|
||||
<div class="tw-flex tw-mb-4 tw-gap-1">
|
||||
<h3 class="tw-mb-0 tw-flex-1"><span class="commit-summary" title="{{.Commit.Summary}}">{{ctx.RenderUtils.RenderCommitMessage .Commit.Message ($.Repository.ComposeCommentMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}</h3>
|
||||
<h3 class="tw-mb-0 tw-flex-1"><span class="commit-summary" title="{{.Commit.Summary}}">{{ctx.RenderUtils.RenderCommitMessage .Commit.Message $.Repository}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}</h3>
|
||||
{{if not $.PageIsWiki}}
|
||||
<div class="commit-header-buttons">
|
||||
<a class="ui primary tiny button" href="{{.SourcePath}}">
|
||||
@@ -122,7 +122,7 @@
|
||||
{{end}}
|
||||
</div>
|
||||
{{if IsMultilineCommitMessage .Commit.Message}}
|
||||
<pre class="commit-body">{{ctx.RenderUtils.RenderCommitBody .Commit.Message ($.Repository.ComposeCommentMetas ctx)}}</pre>
|
||||
<pre class="commit-body">{{ctx.RenderUtils.RenderCommitBody .Commit.Message $.Repository}}</pre>
|
||||
{{end}}
|
||||
{{template "repo/commit_load_branches_and_tags" .}}
|
||||
</div>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary | ctx.RenderUtils.RenderEmoji}}</span>
|
||||
{{else}}
|
||||
{{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}}
|
||||
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{ctx.RenderUtils.RenderCommitMessageLinkSubject .Message $commitLink ($.Repository.ComposeCommentMetas ctx)}}</span>
|
||||
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{ctx.RenderUtils.RenderCommitMessageLinkSubject .Message $commitLink $.Repository}}</span>
|
||||
{{end}}
|
||||
</span>
|
||||
{{if IsMultilineCommitMessage .Message}}
|
||||
@@ -52,7 +52,7 @@
|
||||
{{end}}
|
||||
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}}
|
||||
{{if IsMultilineCommitMessage .Message}}
|
||||
<pre class="commit-body tw-hidden">{{ctx.RenderUtils.RenderCommitBody .Message ($.Repository.ComposeCommentMetas ctx)}}</pre>
|
||||
<pre class="commit-body tw-hidden">{{ctx.RenderUtils.RenderCommitBody .Message $.Repository}}</pre>
|
||||
{{end}}
|
||||
{{if $.CommitsTagsMap}}
|
||||
{{range (index $.CommitsTagsMap .ID.String)}}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
{{$commitLink:= printf "%s/%s" $commitBaseLink (PathEscape .ID.String)}}
|
||||
|
||||
<span class="tw-flex-1 tw-font-mono gt-ellipsis" title="{{.Summary}}">
|
||||
{{- ctx.RenderUtils.RenderCommitMessageLinkSubject .Message $commitLink ($.comment.Issue.PullRequest.BaseRepo.ComposeCommentMetas ctx) -}}
|
||||
{{- ctx.RenderUtils.RenderCommitMessageLinkSubject .Message $commitLink $.comment.Issue.PullRequest.BaseRepo -}}
|
||||
</span>
|
||||
|
||||
{{if IsMultilineCommitMessage .Message}}
|
||||
@@ -29,7 +29,7 @@
|
||||
</div>
|
||||
{{if IsMultilineCommitMessage .Message}}
|
||||
<pre class="commit-body tw-ml-[33px] tw-hidden" data-singular-commit-body-for="{{$tag}}">
|
||||
{{- ctx.RenderUtils.RenderCommitBody .Message ($.comment.Issue.PullRequest.BaseRepo.ComposeCommentMetas ctx) -}}
|
||||
{{- ctx.RenderUtils.RenderCommitBody .Message $.comment.Issue.PullRequest.BaseRepo -}}
|
||||
</pre>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
<div class="ui segment flex-text-block tw-gap-4">
|
||||
{{template "shared/issueicon" .}}
|
||||
<div class="issue-title tw-break-anywhere">
|
||||
{{ctx.RenderUtils.RenderIssueTitle .PullRequest.Issue.Title ($.Repository.ComposeCommentMetas ctx)}}
|
||||
{{ctx.RenderUtils.RenderIssueTitle .PullRequest.Issue.Title $.Repository}}
|
||||
<span class="index">#{{.PullRequest.Issue.Index}}</span>
|
||||
</div>
|
||||
<a href="{{$.RepoLink}}/pulls/{{.PullRequest.Issue.Index}}" class="ui compact button primary">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{{template "repo/commit_sign_badge" dict "Commit" $commit.Commit "CommitBaseLink" (print $.RepoLink "/commit") "CommitSignVerification" $commit.Verification}}
|
||||
|
||||
<span class="message tw-inline-block gt-ellipsis">
|
||||
<span>{{ctx.RenderUtils.RenderCommitMessage $commit.Subject ($.Repository.ComposeCommentMetas ctx)}}</span>
|
||||
<span>{{ctx.RenderUtils.RenderCommitMessage $commit.Subject $.Repository}}</span>
|
||||
</span>
|
||||
|
||||
<span class="commit-refs flex-text-inline">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="flex-item">
|
||||
<div class="flex-item-main">
|
||||
<div class="flex-item-title">
|
||||
<a class="item muted" href="{{.Link}}/releases">
|
||||
<a class="item muted" href="{{.RepoLink}}/releases">
|
||||
{{ctx.Locale.Tr "repo.releases"}}
|
||||
<span class="ui small label">{{.NumReleases}}</span>
|
||||
</a>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
{{if $pageMeta.Issue}}data-update-url="{{$pageMeta.RepoLink}}/issues/assignee?issue_ids={{$pageMeta.Issue.ID}}"{{end}}
|
||||
>
|
||||
<input class="combo-value" name="assignee_ids" type="hidden" value="{{$data.SelectedAssigneeIDs}}">
|
||||
<div class="ui dropdown text-flex-grow {{if not $pageMeta.CanModifyIssueOrPull}}disabled{{end}}">
|
||||
<a class="text muted">
|
||||
<div class="ui dropdown full-width {{if not $pageMeta.CanModifyIssueOrPull}}disabled{{end}}">
|
||||
<a class="fixed-text muted">
|
||||
<strong>{{ctx.Locale.Tr "repo.issues.new.assignees"}}</strong> {{if $pageMeta.CanModifyIssueOrPull}}{{svg "octicon-gear"}}{{end}}
|
||||
</a>
|
||||
<div class="menu">
|
||||
@@ -16,7 +16,7 @@
|
||||
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_assignees"}}">
|
||||
</div>
|
||||
<div class="scrolling menu flex-items-block">
|
||||
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_assignees"}}</div>
|
||||
<div class="item clear-selection" data-text="">{{ctx.Locale.Tr "repo.issues.new.clear_assignees"}}</div>
|
||||
<div class="divider"></div>
|
||||
{{range $data.CandidateAssignees}}
|
||||
<a class="item" href="#" data-value="{{.ID}}">
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
{{if $pageMeta.Issue}}data-update-url="{{$pageMeta.RepoLink}}/issues/labels?issue_ids={{$pageMeta.Issue.ID}}"{{end}}
|
||||
>
|
||||
<input class="combo-value" name="label_ids" type="hidden" value="{{$data.SelectedLabelIDs}}">
|
||||
<div class="ui dropdown text-flex-grow {{if not $pageMeta.CanModifyIssueOrPull}}disabled{{end}}">
|
||||
<a class="text muted">
|
||||
<div class="ui dropdown full-width {{if not $pageMeta.CanModifyIssueOrPull}}disabled{{end}}">
|
||||
<a class="fixed-text muted">
|
||||
<strong>{{ctx.Locale.Tr "repo.issues.new.labels"}}</strong> {{if $pageMeta.CanModifyIssueOrPull}}{{svg "octicon-gear"}}{{end}}
|
||||
</a>
|
||||
<div class="menu">
|
||||
@@ -17,7 +17,7 @@
|
||||
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_labels"}}">
|
||||
</div>
|
||||
<div class="scrolling menu">
|
||||
<a class="item clear-selection" href="#">{{ctx.Locale.Tr "repo.issues.new.clear_labels"}}</a>
|
||||
<a class="item clear-selection" data-text="" href="#">{{ctx.Locale.Tr "repo.issues.new.clear_labels"}}</a>
|
||||
<div class="divider"></div>
|
||||
{{$previousExclusiveScope := "_no_scope"}}
|
||||
{{range $data.RepoLabels}}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
{{if $pageMeta.Issue}}data-update-url="{{$pageMeta.RepoLink}}/issues/milestone?issue_ids={{$pageMeta.Issue.ID}}"{{end}}
|
||||
>
|
||||
<input class="combo-value" name="milestone_id" type="hidden" value="{{$data.SelectedMilestoneID}}">
|
||||
<div class="ui dropdown text-flex-grow {{if not $pageMeta.CanModifyIssueOrPull}}disabled{{end}}">
|
||||
<a class="text muted">
|
||||
<div class="ui dropdown full-width {{if not $pageMeta.CanModifyIssueOrPull}}disabled{{end}}">
|
||||
<a class="fixed-text muted">
|
||||
<strong>{{ctx.Locale.Tr "repo.issues.new.milestone"}}</strong> {{if $pageMeta.CanModifyIssueOrPull}}{{svg "octicon-gear"}}{{end}}
|
||||
</a>
|
||||
<div class="menu">
|
||||
@@ -19,7 +19,7 @@
|
||||
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_milestones"}}">
|
||||
</div>
|
||||
<div class="scrolling menu">
|
||||
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}</div>
|
||||
<div class="item clear-selection" data-text="">{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}</div>
|
||||
<div class="divider"></div>
|
||||
{{if $data.OpenMilestones}}
|
||||
<div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}</div>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
{{if $pageMeta.Issue}}data-update-url="{{$pageMeta.RepoLink}}/issues/projects?issue_ids={{$pageMeta.Issue.ID}}"{{end}}
|
||||
>
|
||||
<input class="combo-value" name="project_id" type="hidden" value="{{$data.SelectedProjectID}}">
|
||||
<div class="ui dropdown text-flex-grow {{if not $pageMeta.CanModifyIssueOrPull}}disabled{{end}}">
|
||||
<a class="text muted">
|
||||
<div class="ui dropdown full-width {{if not $pageMeta.CanModifyIssueOrPull}}disabled{{end}}">
|
||||
<a class="fixed-text muted">
|
||||
<strong>{{ctx.Locale.Tr "repo.issues.new.projects"}}</strong> {{if $pageMeta.CanModifyIssueOrPull}}{{svg "octicon-gear"}}{{end}}
|
||||
</a>
|
||||
<div class="menu">
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="scrolling menu">
|
||||
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_projects"}}</div>
|
||||
<div class="item clear-selection" data-text="">{{ctx.Locale.Tr "repo.issues.new.clear_projects"}}</div>
|
||||
<div class="divider"></div>
|
||||
{{if $data.OpenProjects}}
|
||||
<div class="header">{{ctx.Locale.Tr "repo.issues.new.open_projects"}}</div>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
{{if $pageMeta.Issue}}data-update-url="{{$pageMeta.RepoLink}}/issues/request_review?issue_ids={{$pageMeta.Issue.ID}}"{{end}}
|
||||
>
|
||||
<input type="hidden" class="combo-value" name="reviewer_ids">{{/* match CreateIssueForm */}}
|
||||
<div class="ui dropdown text-flex-grow {{if or (not $hasCandidates) (not $data.CanChooseReviewer)}}disabled{{end}}">
|
||||
<a class="text muted">
|
||||
<div class="ui dropdown full-width {{if or (not $hasCandidates) (not $data.CanChooseReviewer)}}disabled{{end}}">
|
||||
<a class="fixed-text muted">
|
||||
<strong>{{ctx.Locale.Tr "repo.issues.review.reviewers"}}</strong> {{if $data.CanChooseReviewer}}{{svg "octicon-gear"}}{{end}}
|
||||
</a>
|
||||
<div class="menu flex-items-menu">
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
{{if and .CanUseTimetracker (not .Repository.IsArchived)}}
|
||||
<div class="divider"></div>
|
||||
<div>
|
||||
<div class="ui dropdown text-flex-grow jump">
|
||||
<a class="text muted">
|
||||
<div class="ui dropdown full-width jump">
|
||||
<a class="fixed-text muted">
|
||||
<div>
|
||||
<strong>{{ctx.Locale.Tr "repo.issues.tracker"}}</strong> {{if $.IsStopwatchRunning}}{{svg "octicon-stopwatch"}}{{end}}
|
||||
<strong>{{ctx.Locale.Tr "repo.issues.tracker"}}</strong>
|
||||
{{if $.IsStopwatchRunning}}{{svg "octicon-stopwatch"}}{{end}}
|
||||
</div>
|
||||
{{svg "octicon-gear"}}
|
||||
</a>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
{{$canEditIssueTitle := and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .Repository.IsArchived)}}
|
||||
<div class="issue-title" id="issue-title-display">
|
||||
<h1 class="tw-break-anywhere">
|
||||
{{ctx.RenderUtils.RenderIssueTitle .Issue.Title ($.Repository.ComposeCommentMetas ctx)}}
|
||||
{{ctx.RenderUtils.RenderIssueTitle .Issue.Title $.Repository}}
|
||||
<span class="index">#{{.Issue.Index}}</span>
|
||||
</h1>
|
||||
<div class="issue-title-buttons">
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}}
|
||||
|
||||
{{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}}
|
||||
<span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{ctx.RenderUtils.RenderCommitMessageLinkSubject .LatestCommit.Message $commitLink ($.Repository.ComposeCommentMetas ctx)}}</span>
|
||||
<span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{ctx.RenderUtils.RenderCommitMessageLinkSubject .LatestCommit.Message $commitLink $.Repository}}</span>
|
||||
{{if IsMultilineCommitMessage .LatestCommit.Message}}
|
||||
<button class="ui button ellipsis-button" aria-expanded="false" data-global-click="onRepoEllipsisButtonClick">...</button>
|
||||
<pre class="commit-body tw-hidden">{{ctx.RenderUtils.RenderCommitBody .LatestCommit.Message ($.Repository.ComposeCommentMetas ctx)}}</pre>
|
||||
<pre class="commit-body tw-hidden">{{ctx.RenderUtils.RenderCommitBody .LatestCommit.Message $.Repository}}</pre>
|
||||
{{end}}
|
||||
</span>
|
||||
{{end}}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<div class="repo-file-cell message loading-icon-2px">
|
||||
{{if $commit}}
|
||||
{{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}}
|
||||
{{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.Message $commitLink ($.Repository.ComposeCommentMetas ctx)}}
|
||||
{{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.Message $commitLink $.Repository}}
|
||||
{{else}}
|
||||
… {{/* will be loaded again by LastCommitLoaderURL */}}
|
||||
{{end}}
|
||||
|
||||
Generated
+15
@@ -19978,11 +19978,21 @@
|
||||
"type": "object",
|
||||
"title": "AccessToken represents an API access token.",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"x-go-name": "Created"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "ID"
|
||||
},
|
||||
"last_used_at": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"x-go-name": "Updated"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"x-go-name": "Name"
|
||||
@@ -25477,6 +25487,11 @@
|
||||
"type": "string",
|
||||
"x-go-name": "KeyType"
|
||||
},
|
||||
"last_used_at": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"x-go-name": "Updated"
|
||||
},
|
||||
"read_only": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "ReadOnly"
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
<img alt class="ui avatar" src="{{$push.AvatarLink ctx .AuthorEmail}}" title="{{.AuthorName}}" width="16" height="16">
|
||||
<a class="ui sha label" href="{{$commitLink}}">{{ShortSha .Sha1}}</a>
|
||||
<span class="text truncate">
|
||||
{{ctx.RenderUtils.RenderCommitMessage .Message ($repo.ComposeCommentMetas ctx)}}
|
||||
{{ctx.RenderUtils.RenderCommitMessage .Message $repo}}
|
||||
</span>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"testing"
|
||||
@@ -72,12 +73,37 @@ func TestAdminDeleteUser(t *testing.T) {
|
||||
|
||||
session := loginUser(t, "user1")
|
||||
|
||||
csrf := GetUserCSRFToken(t, session)
|
||||
req := NewRequestWithValues(t, "POST", "/-/admin/users/8/delete", map[string]string{
|
||||
"_csrf": csrf,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
usersToDelete := []struct {
|
||||
userID int64
|
||||
purge bool
|
||||
}{
|
||||
{
|
||||
userID: 2,
|
||||
purge: true,
|
||||
},
|
||||
{
|
||||
userID: 8,
|
||||
},
|
||||
}
|
||||
|
||||
assertUserDeleted(t, 8)
|
||||
unittest.CheckConsistencyFor(t, &user_model.User{})
|
||||
for _, entry := range usersToDelete {
|
||||
t.Run(fmt.Sprintf("DeleteUser%d", entry.userID), func(t *testing.T) {
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: entry.userID})
|
||||
assert.NotNil(t, user)
|
||||
|
||||
var query string
|
||||
if entry.purge {
|
||||
query = "?purge=true"
|
||||
}
|
||||
|
||||
csrf := GetUserCSRFToken(t, session)
|
||||
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/-/admin/users/%d/delete%s", entry.userID, query), map[string]string{
|
||||
"_csrf": csrf,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
assertUserDeleted(t, entry.userID)
|
||||
unittest.CheckConsistencyFor(t, &user_model.User{})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,10 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
@@ -17,11 +20,15 @@ import (
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/services/convert"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
"code.gitea.io/gitea/services/gitdiff"
|
||||
issue_service "code.gitea.io/gitea/services/issue"
|
||||
pull_service "code.gitea.io/gitea/services/pull"
|
||||
files_service "code.gitea.io/gitea/services/repository/files"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -424,3 +431,94 @@ func TestAPICommitPullRequest(t *testing.T) {
|
||||
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/commits/%s/pull", owner.Name, repo.Name, invalidCommitSHA).AddTokenAuth(ctx.Token)
|
||||
ctx.Session.MakeRequest(t, req, http.StatusNotFound)
|
||||
}
|
||||
|
||||
func TestAPIViewPullFilesWithHeadRepoDeleted(t *testing.T) {
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
baseRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
|
||||
ctx := NewAPITestContext(t, "user1", baseRepo.Name, auth_model.AccessTokenScopeAll)
|
||||
|
||||
doAPIForkRepository(ctx, "user2")(t)
|
||||
|
||||
forkedRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ForkID: baseRepo.ID, OwnerName: "user1"})
|
||||
|
||||
// add a new file to the forked repo
|
||||
addFileToForkedResp, err := files_service.ChangeRepoFiles(git.DefaultContext, forkedRepo, user1, &files_service.ChangeRepoFilesOptions{
|
||||
Files: []*files_service.ChangeRepoFile{
|
||||
{
|
||||
Operation: "create",
|
||||
TreePath: "file_1.txt",
|
||||
ContentReader: strings.NewReader("file1"),
|
||||
},
|
||||
},
|
||||
Message: "add file1",
|
||||
OldBranch: "master",
|
||||
NewBranch: "fork-branch-1",
|
||||
Author: &files_service.IdentityOptions{
|
||||
GitUserName: user1.Name,
|
||||
GitUserEmail: user1.Email,
|
||||
},
|
||||
Committer: &files_service.IdentityOptions{
|
||||
GitUserName: user1.Name,
|
||||
GitUserEmail: user1.Email,
|
||||
},
|
||||
Dates: &files_service.CommitDateOptions{
|
||||
Author: time.Now(),
|
||||
Committer: time.Now(),
|
||||
},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, addFileToForkedResp)
|
||||
|
||||
// create Pull
|
||||
pullIssue := &issues_model.Issue{
|
||||
RepoID: baseRepo.ID,
|
||||
Title: "Test pull-request-target-event",
|
||||
PosterID: user1.ID,
|
||||
Poster: user1,
|
||||
IsPull: true,
|
||||
}
|
||||
pullRequest := &issues_model.PullRequest{
|
||||
HeadRepoID: forkedRepo.ID,
|
||||
BaseRepoID: baseRepo.ID,
|
||||
HeadBranch: "fork-branch-1",
|
||||
BaseBranch: "master",
|
||||
HeadRepo: forkedRepo,
|
||||
BaseRepo: baseRepo,
|
||||
Type: issues_model.PullRequestGitea,
|
||||
}
|
||||
|
||||
prOpts := &pull_service.NewPullRequestOptions{Repo: baseRepo, Issue: pullIssue, PullRequest: pullRequest}
|
||||
err = pull_service.NewPullRequest(git.DefaultContext, prOpts)
|
||||
assert.NoError(t, err)
|
||||
pr := convert.ToAPIPullRequest(t.Context(), pullRequest, user1)
|
||||
|
||||
ctx = NewAPITestContext(t, "user2", baseRepo.Name, auth_model.AccessTokenScopeAll)
|
||||
doAPIGetPullFiles(ctx, pr, func(t *testing.T, files []*api.ChangedFile) {
|
||||
if assert.Len(t, files, 1) {
|
||||
assert.Equal(t, "file_1.txt", files[0].Filename)
|
||||
assert.Empty(t, files[0].PreviousFilename)
|
||||
assert.Equal(t, 1, files[0].Additions)
|
||||
assert.Equal(t, 1, files[0].Changes)
|
||||
assert.Equal(t, 0, files[0].Deletions)
|
||||
assert.Equal(t, "added", files[0].Status)
|
||||
}
|
||||
})(t)
|
||||
|
||||
// delete the head repository of the pull request
|
||||
forkCtx := NewAPITestContext(t, "user1", forkedRepo.Name, auth_model.AccessTokenScopeAll)
|
||||
doAPIDeleteRepository(forkCtx)(t)
|
||||
|
||||
doAPIGetPullFiles(ctx, pr, func(t *testing.T, files []*api.ChangedFile) {
|
||||
if assert.Len(t, files, 1) {
|
||||
assert.Equal(t, "file_1.txt", files[0].Filename)
|
||||
assert.Empty(t, files[0].PreviousFilename)
|
||||
assert.Equal(t, 1, files[0].Additions)
|
||||
assert.Equal(t, 1, files[0].Changes)
|
||||
assert.Equal(t, 0, files[0].Deletions)
|
||||
assert.Equal(t, "added", files[0].Status)
|
||||
}
|
||||
})(t)
|
||||
})
|
||||
}
|
||||
@@ -6,12 +6,16 @@ package integration
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestChangeDefaultBranch(t *testing.T) {
|
||||
@@ -38,3 +42,96 @@ func TestChangeDefaultBranch(t *testing.T) {
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
}
|
||||
|
||||
func checkDivergence(t *testing.T, session *TestSession, branchesURL, expectedDefaultBranch string, expectedBranchToDivergence map[string]git.DivergeObject) {
|
||||
req := NewRequest(t, "GET", branchesURL)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
branchNodes := htmlDoc.doc.Find(".branch-name").Nodes
|
||||
branchNames := []string{}
|
||||
for _, node := range branchNodes {
|
||||
branchNames = append(branchNames, node.FirstChild.Data)
|
||||
}
|
||||
|
||||
expectBranchCount := len(expectedBranchToDivergence)
|
||||
|
||||
assert.Len(t, branchNames, expectBranchCount+1)
|
||||
assert.Equal(t, expectedDefaultBranch, branchNames[0])
|
||||
|
||||
allCountBehindNodes := htmlDoc.doc.Find(".count-behind").Nodes
|
||||
allCountAheadNodes := htmlDoc.doc.Find(".count-ahead").Nodes
|
||||
|
||||
assert.Len(t, allCountAheadNodes, expectBranchCount)
|
||||
assert.Len(t, allCountBehindNodes, expectBranchCount)
|
||||
|
||||
for i := range expectBranchCount {
|
||||
branchName := branchNames[i+1]
|
||||
assert.Contains(t, expectedBranchToDivergence, branchName)
|
||||
|
||||
expectedCountAhead := expectedBranchToDivergence[branchName].Ahead
|
||||
expectedCountBehind := expectedBranchToDivergence[branchName].Behind
|
||||
countAhead, err := strconv.Atoi(allCountAheadNodes[i].FirstChild.Data)
|
||||
assert.NoError(t, err)
|
||||
countBehind, err := strconv.Atoi(allCountBehindNodes[i].FirstChild.Data)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, expectedCountAhead, countAhead)
|
||||
assert.Equal(t, expectedCountBehind, countBehind)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChangeDefaultBranchDivergence(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 16})
|
||||
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
|
||||
|
||||
session := loginUser(t, owner.Name)
|
||||
branchesURL := fmt.Sprintf("/%s/%s/branches", owner.Name, repo.Name)
|
||||
settingsBranchesURL := fmt.Sprintf("/%s/%s/settings/branches", owner.Name, repo.Name)
|
||||
|
||||
// check branch divergence before switching default branch
|
||||
expectedBranchToDivergenceBefore := map[string]git.DivergeObject{
|
||||
"not-signed": {
|
||||
Ahead: 0,
|
||||
Behind: 0,
|
||||
},
|
||||
"good-sign-not-yet-validated": {
|
||||
Ahead: 0,
|
||||
Behind: 1,
|
||||
},
|
||||
"good-sign": {
|
||||
Ahead: 1,
|
||||
Behind: 3,
|
||||
},
|
||||
}
|
||||
checkDivergence(t, session, branchesURL, "master", expectedBranchToDivergenceBefore)
|
||||
|
||||
// switch default branch
|
||||
newDefaultBranch := "good-sign-not-yet-validated"
|
||||
csrf := GetUserCSRFToken(t, session)
|
||||
req := NewRequestWithValues(t, "POST", settingsBranchesURL, map[string]string{
|
||||
"_csrf": csrf,
|
||||
"action": "default_branch",
|
||||
"branch": newDefaultBranch,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// check branch divergence after switching default branch
|
||||
expectedBranchToDivergenceAfter := map[string]git.DivergeObject{
|
||||
"master": {
|
||||
Ahead: 1,
|
||||
Behind: 0,
|
||||
},
|
||||
"not-signed": {
|
||||
Ahead: 1,
|
||||
Behind: 0,
|
||||
},
|
||||
"good-sign": {
|
||||
Ahead: 1,
|
||||
Behind: 2,
|
||||
},
|
||||
}
|
||||
checkDivergence(t, session, branchesURL, newDefaultBranch, expectedBranchToDivergenceAfter)
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -100,22 +101,29 @@ func TestEmptyRepoAddFile(t *testing.T) {
|
||||
assert.Contains(t, resp.Body.String(), "test-file.md")
|
||||
|
||||
// if the repo is in incorrect state, it should be able to self-heal (recover to correct state)
|
||||
user30EmptyRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: 30, Name: "empty"})
|
||||
user30EmptyRepo.IsEmpty = true
|
||||
user30EmptyRepo.DefaultBranch = "no-such"
|
||||
_, err := db.GetEngine(db.DefaultContext).ID(user30EmptyRepo.ID).Cols("is_empty", "default_branch").Update(user30EmptyRepo)
|
||||
require.NoError(t, err)
|
||||
user30EmptyRepo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: 30, Name: "empty"})
|
||||
assert.True(t, user30EmptyRepo.IsEmpty)
|
||||
testEmptyOrBrokenRecover := func(t *testing.T, isEmpty, isBroken bool) {
|
||||
user30EmptyRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: 30, Name: "empty"})
|
||||
user30EmptyRepo.IsEmpty = isEmpty
|
||||
user30EmptyRepo.Status = util.Iif(isBroken, repo_model.RepositoryBroken, repo_model.RepositoryReady)
|
||||
user30EmptyRepo.DefaultBranch = "no-such"
|
||||
_, err := db.GetEngine(db.DefaultContext).ID(user30EmptyRepo.ID).Cols("is_empty", "status", "default_branch").Update(user30EmptyRepo)
|
||||
require.NoError(t, err)
|
||||
user30EmptyRepo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: 30, Name: "empty"})
|
||||
assert.Equal(t, isEmpty, user30EmptyRepo.IsEmpty)
|
||||
assert.Equal(t, isBroken, user30EmptyRepo.Status == repo_model.RepositoryBroken)
|
||||
|
||||
req = NewRequest(t, "GET", "/user30/empty")
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
redirect = test.RedirectURL(resp)
|
||||
assert.Equal(t, "/user30/empty", redirect)
|
||||
req = NewRequest(t, "GET", "/user30/empty")
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
redirect = test.RedirectURL(resp)
|
||||
assert.Equal(t, "/user30/empty", redirect)
|
||||
|
||||
req = NewRequest(t, "GET", "/user30/empty")
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
assert.Contains(t, resp.Body.String(), "test-file.md")
|
||||
req = NewRequest(t, "GET", "/user30/empty")
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
assert.Contains(t, resp.Body.String(), "test-file.md")
|
||||
}
|
||||
testEmptyOrBrokenRecover(t, true, false)
|
||||
testEmptyOrBrokenRecover(t, false, true)
|
||||
testEmptyOrBrokenRecover(t, true, true)
|
||||
}
|
||||
|
||||
func TestEmptyRepoUploadFile(t *testing.T) {
|
||||
|
||||
@@ -11,8 +11,10 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -30,6 +32,7 @@ import (
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/kballard/go-shellquote"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -105,7 +108,12 @@ func testGitGeneral(t *testing.T, u *url.URL) {
|
||||
|
||||
// Setup key the user ssh key
|
||||
withKeyFile(t, keyname, func(keyFile string) {
|
||||
t.Run("CreateUserKey", doAPICreateUserKey(sshContext, "test-key", keyFile))
|
||||
var keyID int64
|
||||
t.Run("CreateUserKey", doAPICreateUserKey(sshContext, "test-key", keyFile, func(t *testing.T, key api.PublicKey) {
|
||||
keyID = key.ID
|
||||
}))
|
||||
assert.NotZero(t, keyID)
|
||||
t.Run("LFSAccessTest", doSSHLFSAccessTest(sshContext, keyID))
|
||||
|
||||
// Setup remote link
|
||||
// TODO: get url from api
|
||||
@@ -136,6 +144,36 @@ func testGitGeneral(t *testing.T, u *url.URL) {
|
||||
})
|
||||
}
|
||||
|
||||
func doSSHLFSAccessTest(_ APITestContext, keyID int64) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
sshCommand := os.Getenv("GIT_SSH_COMMAND") // it is set in withKeyFile
|
||||
sshCmdParts, err := shellquote.Split(sshCommand) // and parse the ssh command to construct some mocked arguments
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("User2AccessOwned", func(t *testing.T) {
|
||||
sshCmdUser2Self := append(slices.Clone(sshCmdParts),
|
||||
"-p", strconv.Itoa(setting.SSH.ListenPort), "git@"+setting.SSH.ListenHost,
|
||||
"git-lfs-authenticate", "user2/repo1.git", "upload", // accessible to own repo
|
||||
)
|
||||
cmd := exec.CommandContext(t.Context(), sshCmdUser2Self[0], sshCmdUser2Self[1:]...)
|
||||
_, err := cmd.Output()
|
||||
assert.NoError(t, err) // accessible, no error
|
||||
})
|
||||
|
||||
t.Run("User2AccessOther", func(t *testing.T) {
|
||||
sshCmdUser2Other := append(slices.Clone(sshCmdParts),
|
||||
"-p", strconv.Itoa(setting.SSH.ListenPort), "git@"+setting.SSH.ListenHost,
|
||||
"git-lfs-authenticate", "user5/repo4.git", "upload", // inaccessible to other's (user5/repo4)
|
||||
)
|
||||
cmd := exec.CommandContext(t.Context(), sshCmdUser2Other[0], sshCmdUser2Other[1:]...)
|
||||
_, err := cmd.Output()
|
||||
var errExit *exec.ExitError
|
||||
require.ErrorAs(t, err, &errExit) // inaccessible, error
|
||||
assert.Contains(t, string(errExit.Stderr), fmt.Sprintf("User: 2:user2 with Key: %d:test-key is not authorized to write to user5/repo4.", keyID))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func ensureAnonymousClone(t *testing.T, u *url.URL) {
|
||||
dstLocalPath := t.TempDir()
|
||||
t.Run("CloneAnonymous", doGitClone(dstLocalPath, u))
|
||||
|
||||
@@ -184,6 +184,15 @@ func testIssueAddComment(t *testing.T, session *TestSession, issueURL, content,
|
||||
return int64(id)
|
||||
}
|
||||
|
||||
func testIssueChangeMilestone(t *testing.T, session *TestSession, repoLink string, issueID, milestoneID int64) {
|
||||
req := NewRequestWithValues(t, "POST", fmt.Sprintf(repoLink+"/issues/milestone?issue_ids=%d", issueID), map[string]string{
|
||||
"_csrf": GetUserCSRFToken(t, session),
|
||||
"id": strconv.FormatInt(milestoneID, 10),
|
||||
})
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
assert.Equal(t, `{"ok":true}`, strings.TrimSpace(resp.Body.String()))
|
||||
}
|
||||
|
||||
func TestNewIssue(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
session := loginUser(t, "user2")
|
||||
|
||||
@@ -12,8 +12,6 @@ import (
|
||||
"testing"
|
||||
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
@@ -40,40 +38,24 @@ func TestRepoCommits(t *testing.T) {
|
||||
|
||||
func Test_ReposGitCommitListNotMaster(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
// Login as User2.
|
||||
session := loginUser(t, user.Name)
|
||||
|
||||
// Test getting commits (Page 1)
|
||||
req := NewRequestf(t, "GET", "/%s/repo16/commits/branch/master", user.Name)
|
||||
session := loginUser(t, "user2")
|
||||
req := NewRequest(t, "GET", "/user2/repo16/commits/branch/master")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
doc := NewHTMLParser(t, resp.Body)
|
||||
commits := []string{}
|
||||
var commits []string
|
||||
doc.doc.Find("#commits-table .commit-id-short").Each(func(i int, s *goquery.Selection) {
|
||||
commitURL, exists := s.Attr("href")
|
||||
assert.True(t, exists)
|
||||
assert.NotEmpty(t, commitURL)
|
||||
commitURL, _ := s.Attr("href")
|
||||
commits = append(commits, path.Base(commitURL))
|
||||
})
|
||||
assert.Equal(t, []string{"69554a64c1e6030f051e5c3f94bfbd773cd6a324", "27566bd5738fc8b4e3fef3c5e72cce608537bd95", "5099b81332712fe655e34e8dd63574f503f61811"}, commits)
|
||||
|
||||
assert.Len(t, commits, 3)
|
||||
assert.Equal(t, "69554a64c1e6030f051e5c3f94bfbd773cd6a324", commits[0])
|
||||
assert.Equal(t, "27566bd5738fc8b4e3fef3c5e72cce608537bd95", commits[1])
|
||||
assert.Equal(t, "5099b81332712fe655e34e8dd63574f503f61811", commits[2])
|
||||
|
||||
userNames := []string{}
|
||||
var userHrefs []string
|
||||
doc.doc.Find("#commits-table .author-wrapper").Each(func(i int, s *goquery.Selection) {
|
||||
userPath, exists := s.Attr("href")
|
||||
assert.True(t, exists)
|
||||
assert.NotEmpty(t, userPath)
|
||||
userNames = append(userNames, path.Base(userPath))
|
||||
userHref, _ := s.Attr("href")
|
||||
userHrefs = append(userHrefs, userHref)
|
||||
})
|
||||
|
||||
assert.Len(t, userNames, 3)
|
||||
assert.Equal(t, "User2", userNames[0])
|
||||
assert.Equal(t, "user21", userNames[1])
|
||||
assert.Equal(t, "User2", userNames[2])
|
||||
assert.Equal(t, []string{"/user2", "/user21", "/user2"}, userHrefs)
|
||||
}
|
||||
|
||||
func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
|
||||
|
||||
@@ -241,19 +241,68 @@ func Test_WebhookIssueComment(t *testing.T) {
|
||||
|
||||
testAPICreateWebhookForRepo(t, session, "user2", "repo1", provider.URL(), "issue_comment")
|
||||
|
||||
// 2. trigger the webhook
|
||||
issueURL := testNewIssue(t, session, "user2", "repo1", "Title2", "Description2")
|
||||
testIssueAddComment(t, session, issueURL, "issue title2 comment1", "")
|
||||
t.Run("create comment", func(t *testing.T) {
|
||||
// 2. trigger the webhook
|
||||
issueURL := testNewIssue(t, session, "user2", "repo1", "Title2", "Description2")
|
||||
testIssueAddComment(t, session, issueURL, "issue title2 comment1", "")
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.Equal(t, "issue_comment", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "created", payloads[0].Action)
|
||||
assert.Equal(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.Equal(t, "Title2", payloads[0].Issue.Title)
|
||||
assert.Equal(t, "Description2", payloads[0].Issue.Body)
|
||||
assert.Equal(t, "issue title2 comment1", payloads[0].Comment.Body)
|
||||
// 3. validate the webhook is triggered
|
||||
assert.Equal(t, "issue_comment", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "created", payloads[0].Action)
|
||||
assert.Equal(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.Equal(t, "Title2", payloads[0].Issue.Title)
|
||||
assert.Equal(t, "Description2", payloads[0].Issue.Body)
|
||||
assert.Equal(t, "issue title2 comment1", payloads[0].Comment.Body)
|
||||
})
|
||||
|
||||
t.Run("update comment", func(t *testing.T) {
|
||||
payloads = make([]api.IssueCommentPayload, 0, 2)
|
||||
triggeredEvent = ""
|
||||
|
||||
// 2. trigger the webhook
|
||||
issueURL := testNewIssue(t, session, "user2", "repo1", "Title3", "Description3")
|
||||
commentID := testIssueAddComment(t, session, issueURL, "issue title3 comment1", "")
|
||||
modifiedContent := "issue title2 comment1 - modified"
|
||||
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/comments/%d", "user2", "repo1", commentID), map[string]string{
|
||||
"_csrf": GetUserCSRFToken(t, session),
|
||||
"content": modifiedContent,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.Equal(t, "issue_comment", triggeredEvent)
|
||||
assert.Len(t, payloads, 2)
|
||||
assert.EqualValues(t, "edited", payloads[1].Action)
|
||||
assert.Equal(t, "repo1", payloads[1].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[1].Issue.Repo.FullName)
|
||||
assert.Equal(t, "Title3", payloads[1].Issue.Title)
|
||||
assert.Equal(t, "Description3", payloads[1].Issue.Body)
|
||||
assert.Equal(t, modifiedContent, payloads[1].Comment.Body)
|
||||
})
|
||||
|
||||
t.Run("Update comment with no content change", func(t *testing.T) {
|
||||
payloads = make([]api.IssueCommentPayload, 0, 2)
|
||||
triggeredEvent = ""
|
||||
commentContent := "issue title3 comment1"
|
||||
|
||||
// 2. trigger the webhook
|
||||
issueURL := testNewIssue(t, session, "user2", "repo1", "Title3", "Description3")
|
||||
commentID := testIssueAddComment(t, session, issueURL, commentContent, "")
|
||||
|
||||
payloads = make([]api.IssueCommentPayload, 0, 2)
|
||||
triggeredEvent = ""
|
||||
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/comments/%d", "user2", "repo1", commentID), map[string]string{
|
||||
"_csrf": GetUserCSRFToken(t, session),
|
||||
"content": commentContent,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
// 3. validate the webhook is not triggered because no content change
|
||||
assert.Empty(t, triggeredEvent)
|
||||
assert.Empty(t, payloads)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -355,6 +404,78 @@ func Test_WebhookIssue(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func Test_WebhookIssueMilestone(t *testing.T) {
|
||||
var payloads []api.IssuePayload
|
||||
var triggeredEvent string
|
||||
provider := newMockWebhookProvider(func(r *http.Request) {
|
||||
content, _ := io.ReadAll(r.Body)
|
||||
var payload api.IssuePayload
|
||||
err := json.Unmarshal(content, &payload)
|
||||
assert.NoError(t, err)
|
||||
payloads = append(payloads, payload)
|
||||
triggeredEvent = "issues"
|
||||
}, http.StatusOK)
|
||||
defer provider.Close()
|
||||
|
||||
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
|
||||
// create a new webhook with special webhook for repo1
|
||||
session := loginUser(t, "user2")
|
||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 1})
|
||||
testAPICreateWebhookForRepo(t, session, "user2", "repo1", provider.URL(), "issue_milestone")
|
||||
|
||||
t.Run("assign a milestone", func(t *testing.T) {
|
||||
// trigger the webhook
|
||||
testIssueChangeMilestone(t, session, repo1.Link(), 1, 1)
|
||||
|
||||
// validate the webhook is triggered
|
||||
assert.Equal(t, "issues", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.Equal(t, "milestoned", string(payloads[0].Action))
|
||||
assert.Equal(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.Equal(t, "issue1", payloads[0].Issue.Title)
|
||||
assert.Equal(t, "content for the first issue", payloads[0].Issue.Body)
|
||||
assert.EqualValues(t, 1, payloads[0].Issue.Milestone.ID)
|
||||
})
|
||||
|
||||
t.Run("change a milestong", func(t *testing.T) {
|
||||
// trigger the webhook again
|
||||
triggeredEvent = ""
|
||||
payloads = make([]api.IssuePayload, 0, 1)
|
||||
// change milestone to 2
|
||||
testIssueChangeMilestone(t, session, repo1.Link(), 1, 2)
|
||||
|
||||
// validate the webhook is triggered
|
||||
assert.Equal(t, "issues", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.Equal(t, "milestoned", string(payloads[0].Action))
|
||||
assert.Equal(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.Equal(t, "issue1", payloads[0].Issue.Title)
|
||||
assert.Equal(t, "content for the first issue", payloads[0].Issue.Body)
|
||||
assert.EqualValues(t, 2, payloads[0].Issue.Milestone.ID)
|
||||
})
|
||||
|
||||
t.Run("remove a milestone", func(t *testing.T) {
|
||||
// trigger the webhook again
|
||||
triggeredEvent = ""
|
||||
payloads = make([]api.IssuePayload, 0, 1)
|
||||
// change milestone to 0
|
||||
testIssueChangeMilestone(t, session, repo1.Link(), 1, 0)
|
||||
|
||||
// validate the webhook is triggered
|
||||
assert.Equal(t, "issues", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.Equal(t, "demilestoned", string(payloads[0].Action))
|
||||
assert.Equal(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.Equal(t, "issue1", payloads[0].Issue.Title)
|
||||
assert.Equal(t, "content for the first issue", payloads[0].Issue.Body)
|
||||
assert.Nil(t, payloads[0].Issue.Milestone)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_WebhookPullRequest(t *testing.T) {
|
||||
var payloads []api.PullRequestPayload
|
||||
var triggeredEvent string
|
||||
|
||||
@@ -1188,16 +1188,6 @@ the "!important" is necessary to override Fomantic UI menu item styles, meanwhil
|
||||
text-overflow: ellipsis !important;
|
||||
}
|
||||
|
||||
.ui.dropdown.text-flex-grow {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.ui.dropdown.text-flex-grow > .text {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.svg.octicon-file-directory-fill,
|
||||
.svg.octicon-file-directory-open-fill,
|
||||
.svg.octicon-file-submodule {
|
||||
|
||||
@@ -100,67 +100,3 @@
|
||||
border-bottom: 1px solid var(--color-secondary);
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
text-expander {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
text-expander .suggestions {
|
||||
position: absolute;
|
||||
min-width: 180px;
|
||||
padding: 0;
|
||||
margin-top: 24px;
|
||||
list-style: none;
|
||||
background: var(--color-box-body);
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--color-secondary);
|
||||
box-shadow: 0 .5rem 1rem var(--color-shadow);
|
||||
z-index: 100; /* needs to be > 20 to be on top of dropzone's .dz-details */
|
||||
}
|
||||
|
||||
text-expander .suggestions li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
text-expander .suggestions li + li {
|
||||
border-top: 1px solid var(--color-secondary-alpha-40);
|
||||
}
|
||||
|
||||
text-expander .suggestions li:first-child {
|
||||
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
||||
}
|
||||
|
||||
text-expander .suggestions li:last-child {
|
||||
border-radius: 0 0 var(--border-radius) var(--border-radius);
|
||||
}
|
||||
|
||||
text-expander .suggestions li:only-child {
|
||||
border-radius: var(--border-radius);
|
||||
}
|
||||
|
||||
text-expander .suggestions li:hover {
|
||||
background: var(--color-hover);
|
||||
}
|
||||
|
||||
text-expander .suggestions .fullname {
|
||||
font-weight: var(--font-weight-normal);
|
||||
margin-left: 4px;
|
||||
color: var(--color-text-light-1);
|
||||
}
|
||||
|
||||
text-expander .suggestions li[aria-selected="true"],
|
||||
text-expander .suggestions li[aria-selected="true"] span {
|
||||
background: var(--color-primary);
|
||||
color: var(--color-primary-contrast);
|
||||
}
|
||||
|
||||
text-expander .suggestions img {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
text-expander .suggestions,
|
||||
.tribute-container {
|
||||
position: absolute;
|
||||
max-height: min(300px, 95vh);
|
||||
max-width: min(500px, 95vw);
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
white-space: nowrap;
|
||||
background: var(--color-menu);
|
||||
box-shadow: 0 6px 18px var(--color-shadow);
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--color-secondary);
|
||||
z-index: 100; /* needs to be > 20 to be on top of dropzone's .dz-details */
|
||||
}
|
||||
|
||||
text-expander {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
text-expander .suggestions {
|
||||
padding: 0;
|
||||
margin-top: 24px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
text-expander .suggestions li,
|
||||
.tribute-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
gap: 6px;
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
text-expander .suggestions li,
|
||||
.tribute-container li {
|
||||
padding: 3px 6px;
|
||||
}
|
||||
|
||||
text-expander .suggestions li + li,
|
||||
.tribute-container li + li {
|
||||
border-top: 1px solid var(--color-secondary);
|
||||
}
|
||||
|
||||
text-expander .suggestions li:first-child {
|
||||
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
||||
}
|
||||
|
||||
text-expander .suggestions li:last-child {
|
||||
border-radius: 0 0 var(--border-radius) var(--border-radius);
|
||||
}
|
||||
|
||||
text-expander .suggestions li:only-child {
|
||||
border-radius: var(--border-radius);
|
||||
}
|
||||
|
||||
text-expander .suggestions .fullname,
|
||||
.tribute-container li .fullname {
|
||||
font-weight: var(--font-weight-normal);
|
||||
color: var(--color-text-light-1);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
text-expander .suggestions li:hover,
|
||||
text-expander .suggestions li:hover *,
|
||||
text-expander .suggestions li[aria-selected="true"],
|
||||
text-expander .suggestions li[aria-selected="true"] *,
|
||||
.tribute-container li.highlight,
|
||||
.tribute-container li.highlight * {
|
||||
background: var(--color-primary);
|
||||
color: var(--color-primary-contrast);
|
||||
}
|
||||
|
||||
text-expander .suggestions img,
|
||||
.tribute-item img {
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
object-fit: contain;
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
|
||||
.tribute-container {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tribute-container ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.tribute-container li.no-match {
|
||||
cursor: default;
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
.project-header {
|
||||
padding: 0.5em 0;
|
||||
overflow-x: auto; /* in fullscreen mode, the position is fixed, so we can't use "flex wrap" which would change the height */
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.project-header h2 {
|
||||
@@ -101,17 +101,11 @@
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.fullscreen.projects-view .project-header {
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 0.5em;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
background-color: var(--color-body);
|
||||
border-bottom: 1px solid var(--color-secondary);
|
||||
.fullscreen.projects-view {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Hide project-description in full-screen due to its variable height. No need to show it for better space use. */
|
||||
@@ -120,9 +114,7 @@
|
||||
}
|
||||
|
||||
.fullscreen.projects-view #project-board {
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
max-height: calc(100vh - 70px);
|
||||
flex: 1;
|
||||
max-height: unset;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
@import "tributejs/dist/tribute.css";
|
||||
|
||||
.tribute-container {
|
||||
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.25);
|
||||
border-radius: var(--border-radius);
|
||||
}
|
||||
|
||||
.tribute-container ul {
|
||||
margin-top: 0 !important;
|
||||
background: var(--color-body) !important;
|
||||
}
|
||||
|
||||
.tribute-container li {
|
||||
padding: 3px 0.5rem !important;
|
||||
}
|
||||
|
||||
.tribute-container li span.fullname {
|
||||
font-weight: var(--font-weight-normal);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.tribute-container li.highlight,
|
||||
.tribute-container li:hover {
|
||||
background: var(--color-primary) !important;
|
||||
color: var(--color-primary-contrast) !important;
|
||||
}
|
||||
|
||||
.tribute-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
@@ -39,7 +39,7 @@
|
||||
@import "./features/imagediff.css";
|
||||
@import "./features/codeeditor.css";
|
||||
@import "./features/projects.css";
|
||||
@import "./features/tribute.css";
|
||||
@import "./features/expander.css";
|
||||
@import "./features/cropper.css";
|
||||
@import "./features/console.css";
|
||||
|
||||
|
||||
+14
-4
@@ -50,23 +50,33 @@
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.issue-sidebar-combo .ui.dropdown .item:not(.checked) .item-check-mark {
|
||||
visibility: hidden;
|
||||
.issue-content-right .ui.dropdown.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.issue-content-right .dropdown > .menu {
|
||||
.issue-content-right .ui.dropdown.full-width > .fixed-text {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.issue-content-right .ui.dropdown > .menu {
|
||||
max-width: 270px;
|
||||
min-width: 0;
|
||||
max-height: 500px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.issue-content-right .dropdown > .menu .item-secondary-info small {
|
||||
.issue-content-right .ui.dropdown > .menu .item-secondary-info small {
|
||||
display: block;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.issue-sidebar-combo > .ui.dropdown .item:not(.checked) .item-check-mark {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.issue-content-left,
|
||||
.issue-content-right {
|
||||
|
||||
@@ -4080,7 +4080,7 @@ $.fn.dropdown.settings = {
|
||||
search : 'input.search, .menu > .search > input, .menu input.search',
|
||||
sizer : '> span.sizer',
|
||||
text : '> .text:not(.icon)',
|
||||
unselectable : '.disabled, .filtered',
|
||||
unselectable : '.disabled, .filtered, .tw-hidden', // GITEA-PATCH: tw-hidden hides the item so it is also unselectable
|
||||
clearIcon : '> .remove.icon'
|
||||
},
|
||||
|
||||
|
||||
Loaded 100 of 107 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user