Commit Graph

1527 Commits (main)

Author SHA1 Message Date
wxiaoguang 5a7b42dac7
Support choose email when creating a commit via web UI (more) (#33445)
Follow #33432
4 hours ago
wxiaoguang f24d73ab5f
Fix "redirect link" handling (#33440)
`a%2fb` should not redirect to `a/b`

---------

Co-authored-by: delvh <dev.lh@web.de>
10 hours ago
Lunny Xiao f88dbf86b3
Refactor repository transfer (#33211)
- Both have `RejectTransfer` and `CancelTransfer` because the permission
checks are not the same. `CancelTransfer` can be done by the doer or
those who have admin permission to access this repository.
`RejectTransfer` can be done by the receiver user if it's an individual
or those who can create repositories if it's an organization.

- Some tests are wrong, this PR corrects them.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 day ago
Lunny Xiao 75940a0191
Add tests for webhook and fix some webhook bugs (#33396)
This PR created a mock webhook server in the tests and added integration
tests for generic webhooks.
It also fixes bugs in package webhooks and pull request comment
webhooks.
1 day ago
wxiaoguang 256b94e9e9
Support choose email when creating a commit via web UI (#33432)
Initial PR for #24469
1 day ago
Rowan Bohde ac2d97cb61
Link to tree views of submodules if possible (#33424)
This is a follow-up to https://github.com/go-gitea/gitea/pull/33097. 

When linking a submodule at a commit in either the repo view, or a diff
when adding a new submodule, link to the tree view of that submodules
intead of the individual commit. This shows the user the full tree,
instead of the diff of the commit.

This makes the assumption that the tree for a given SHA is at
`<repo_url>/tree/<sha>`. This URL format is supported by both Github &
Gitlab, but not Gitea. To fix this, add a redirect from
`<username>/<repo>/tree/<ref>` to `<username>/<repo>/src/<ref>`, so that
Gitea can support this URL structure.
1 day ago
wxiaoguang 4ffc54f59a
Refactor user & avatar (#33433)
1. better GetPossibleUserByID logic
2. fix some function name & comment typos
3. do not re-generate avatar if one exists
1 day ago
Lunny Xiao 77d14fb6d3
Fix system admin cannot fork or get private fork with API (#33401)
Fix #33368
4 days ago
TheFox0x7 6ca91f555a
User facing messages for AGit errors (#33012)
Adds user facing messages to errors when submitting agit pull request
Tries to highlight the returned error more and fixes agit suggestion to
create PR on first submission.

Closes: https://github.com/go-gitea/gitea/issues/32965

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
4 days ago
Wesley van Tilburg c79adf00b8
Add basic auth support to rss/atom feeds (#33371)
Allows RSS readers to access private feeds using their basic auth
capabilities. Not all clients feature the ability to add cookies or
headers.

fixes #32458 

Tested with miniflux

no credentials:

![image](https://github.com/user-attachments/assets/8c3369f2-1cf6-4ce3-ac6e-84447e454928)


basic auth entered:

![image](https://github.com/user-attachments/assets/c93ff22c-1429-4a80-898f-91d9f35c7c61)

![image](https://github.com/user-attachments/assets/60d83afd-9dde-4973-a440-ff8138799e87)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
4 days ago
wxiaoguang 517a367abe
Use ProtonMail/go-crypto to replace keybase/go-crypto (#33402)
Fix #33400

The keybase/go-crypto is no longer maintained and it generates malformed
signatures, ProtonMail/go-crypto is the actively maintained fork.
4 days ago
wxiaoguang 2c1ff8701a
Refactor context flash msg and global variables (#33375)
1. add `GetSiteCookieFlashMessage` to help to parse flash message
2. clarify `handleRepoHomeFeed` logic
3. remove unnecessary global variables, use `sync.OnceValue` instead
4. add some tests for `IsUsableUsername` and `IsUsableRepoName`
6 days ago
wxiaoguang 06ff9b6256
Do not access GitRepo when a repo is being created (#33380) 6 days ago
Lunny Xiao e94f37f95e
Refactor webhook events (#33337)
Extract from #33320

This PR uses a map instead of a struct to store webhook event
information. It removes many duplicated functions and makes the logic
clearer.
1 week ago
wxiaoguang 6fe4d1c038
Remove duplicate "ResponseWriter.Status" method (#33346) 1 week ago
wxiaoguang 39de2955fd
Improve sync fork behavior (#33319)
Fix #33271

Suppose there is a `branch-a` in fork repo:

1. if `branch-a` exists in base repo: try to sync `base:branch-a` to `fork:branch-a`
2. if `branch-a` doesn't exist in base repo: try to sync `base:main` to `fork:branch-a`
2 weeks ago
wxiaoguang 6073e2f1bb
Refactor response writer & access logger (#33323)
And add comments & tests
2 weeks ago
hiifong b7614e2d2f
Fix parentCommit invalid memory address or nil pointer dereference. (#33204)
When the parent Commit does not exist on gitea, an error will be
reported when opening the Commit details page: invalid memory address or
nil pointer dereference.

![image](https://github.com/user-attachments/assets/4c2a9802-935f-41e9-b5b9-a4f0d745f709)

![image](https://github.com/user-attachments/assets/7b0bc15e-7f5f-4d58-8d24-fee667a799fa)
2 weeks ago
Vladimir Sysoev dc2308a959
Make tracked time representation display as hours (#33315)
Estimated time represented in hours it might be convenient to
have tracked time represented in the same way to be compared and
managed.

---------

Co-authored-by: Sysoev, Vladimir <i@vsysoev.ru>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 weeks ago
Chai-Shi 55e0756c68
Fix push message behavior (#33215)
Fixes #32769 by the logic from pr #33192

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 weeks ago
wxiaoguang cfc6e21f06
Fix incorrect ref usages (#33301)
Fix #33297

By the way, improve some locales
2 weeks ago
Kemal Zebari 2483a93fbc
Only allow admins to rename default/protected branches (#33276)
Currently, anyone with write permissions to a repo are able to rename
default or protected branches.

This change follows
[GitHub's](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch)
design by only allowing repo/site admins to change these branches.
However, it also follows are current design for protected branches and
only allows admins to modify branch names == branch protection rule
names. Glob-based rules cannot be renamed by anyone (as was already the
case, but we now catch `ErrBranchIsProtected` which we previously did
not catch, throwing a 500).
2 weeks ago
wxiaoguang b15d01b0ce
Prepare for support performance trace (#33286)
For #32973
2 weeks ago
Zettat123 d0962ce3da
Move some Actions related functions from `routers` to `services` (#33280)
Move the main logic of `generateTaskContext` and `findTaskNeeds` to the
`services` layer.

This is a part of #32751, since we need the git context and `needs` to
parse the concurrency expressions.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 weeks ago
wxiaoguang f6dbf0e7b3
Fix incorrect TagName/BranchName usages (#33279)
Add add a new test
2 weeks ago
wxiaoguang fcd096231a
Simplify context ref name (#33267) 2 weeks ago
Lunny Xiao 6410c34b7f
Refactor ref type (#33242)
Major changes:

1. do not sync ".keep" file during tests
2. fix incorrect route handler and empty repo handling (backported as #33253 with tests)
3. do not use `RepoRef`: most of the calls are abuses.
4. Use `git.RefType` instead of a new type definition `RepoRefType` on `context`.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 weeks ago
wxiaoguang a98a836e76
Support public code/issue access for private repositories (#33127)
Close #8649, close #639 (will add "anonymous access" in following PRs)
2 weeks ago
Kemal Zebari ecd463c2f1
Validate that the tag doesn't exist when creating a tag via the web (#33241)
Found while investigating #33210.

This line no longer makes sense because the form field "TagName" is
required, so this would mean that this code path would never be covered.
Because it isn't covered, we end up going down the "update release"
logic where we eventually set `Release.IsTag` to false (meaning it will
now be treated as a release instead of a tag).

This snapshot rewrites the condition to ensure that we aren't trying to
create a tag that already exists.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 weeks ago
wxiaoguang 348b7074c8
Fix incorrect ref "blob" (#33240)
1. "blob" is not a "ref", it shouldn't (and not unable to) be handled by
`RepoRefByType`
2. the `/blob/{sha}` handle should use the path param "sha" directly
3 weeks ago
wxiaoguang 2ea929a952
Refactor RefName (#33234)
And fix some FIXMEs
3 weeks ago
wxiaoguang 81352542fd
Refactor context RefName and RepoAssignment (#33226)
The `ctx.Repo.RefName` was used to be a "short name", it causes a lot of
ambiguity.

This PR does some refactoring and use `RefFullName` to replace the
legacy `RefName`, and simplify RepoAssignment
3 weeks ago
Lunny Xiao be4e961240
Fix mirror bug (#33224)
Fix #33200

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
3 weeks ago
wxiaoguang a068462ac0
Refactor context repository (#33202) 3 weeks ago
Chai-Shi e5f3c16587
Fix sync fork for consistency (#33147)
Fixes #33145

An integration test could be added.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
3 weeks ago
wxiaoguang 65aae0912a
Fix raw file API ref handling (#33172)
Fix #33164 and add more tests
3 weeks ago
Lunny Xiao 39d51e7c82
Automerge supports deleting branch automatically after merging (#32343)
Resolve #32341 
~Depends on #27151~

- [x] It will display a checkbox of deleting the head branch on the pull
request view page when starting an auto-merge task.
- [x] Add permission check before deleting the branch
- [x] Add delete branch comment for those closing pull requests because
of head branch or base branch was deleted.
- [x] Merge `RetargetChildrenOnMerge` and `AddDeletePRBranchComment`
into `service.DeleteBranch`.
3 weeks ago
TheFox0x7 2a02734f93
Refactor older tests to use testify (#33140)
Refactor checks to use assert/require
Use require.Eventually for waiting in elastic and meilisearch tests
Use require to exit early instead of assert
3 weeks ago
yp05327 e177239529
Fix typo in gitea downloader test and add missing codebase in `ToGitServiceType` (#33146) 3 weeks ago
yp05327 124079871b
Convert github.com/xanzy/go-gitlab into gitlab.com/gitlab-org/api/client-go (#33126)
Fix #32985
3 weeks ago
Lunny Xiao 67aeb1f896
Add missed transaction on setmerged (#33079)
Follow #33045. There are two updates on `Set Merged`, which should be in
one transaction.
This also introduced some refactors for changeissuestatus to make it
more clear.
3 weeks ago
Rowan Bohde a8e7caedfa
add submodule diff links (#33097)
This adds links to submodules in diffs, similar to the existing link
when viewing a repo at a specific commit. It does this by expanding diff
parsing to recognize changes to submodules, and find the specific refs
that are added, deleted or changed.

Related #25888

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
3 weeks ago
yp05327 32d45ee069
Update status check for all supported on.pull_request.types in Gitea (#33117)
Thanks @Zettat123
Follow #33116
Fix #33051

on.pull_request.types doc:

https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request

on.pull_request.types added in this PR:
```
assigned, unassigned, review_requested, review_request_removed, milestoned, demilestoned, labeled, unlabeled
```

unsupported types in Gitea:
```
// Unsupported activity types:
// converted_to_draft, ready_for_review, locked, unlocked, auto_merge_enabled, auto_merge_disabled, enqueued, dequeued
```

TODO:
- [x] add test
3 weeks ago
yp05327 0d7d2ed39d
Support the new exit code for `git remote` subcommands for git version >=2.30.0 (#33129)
Fix #32889

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
3 weeks ago
wxiaoguang 34dfc25b83
Make git clone URL could use current signed-in user (#33091)
close #33086

* Add a special value for "SSH_USER" setting: `(DOER_USERNAME)`
* Improve parseRepositoryURL and add tests (now it doesn't have hard
dependency on some setting values)

Many changes are just adding "ctx" and "doer" argument to functions.

By the way, improve app.example.ini, remove all `%(key)s` syntax, it
only makes messy and no user really cares about it.

Document: https://gitea.com/gitea/docs/pulls/138
3 weeks ago
wxiaoguang 80e4f4c4eb
Refactor package (routes and error handling, npm peer dependency) (#33111) 4 weeks ago
wxiaoguang 3d544a3ad3
Fix empty git repo handling logic (#33101)
Fix #33092
4 weeks ago
Steffen Schröter 57eb9d0b64
Inherit submodules from template repository content (#16237)
Fix #10316

---------

Signed-off-by: Steffen Schröter <steffen@vexar.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 month ago
Bo-Yi Wu 6c89de494a
feat(action): issue change title notifications (#33050)
- Add `IssueChangeTitle` method to handle issue title changes
- Add `notifyIssueChangeWithTitleOrContent` method to generalize
notification handling for issue title or content changes

action file as below:

```yaml
name: Semantic Pull Request

on:
  pull_request_target:
    types: [edited]
```

---------

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 month ago
Chai-Shi 0387195abb
[Feature] Private README.md for organization (#32872)
Implemented #29503

---------

Co-authored-by: Ben Chang <ben_chang@htc.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 month ago