Commit Graph

14447 Commits

Author SHA1 Message Date
zeripath f1f0430f9f
Add Contributed backport command (#22643)
This PR provides a contributed backport command to help create backports
for Gitea.

It represents a significant improvement on my previously described
shell-script.

It can be installed using `go install contrib/backport/backport.go`.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-01-31 22:10:54 +00:00
Ivan Maximov 519939fa8c
Fix typo in command-line.en-us.md (#22681)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-31 21:43:39 +00:00
Ivan Maximov f518b42d4c
Fix typo in linked-references.en-us.md (#22682) 2023-01-31 21:43:27 +00:00
Ivan Maximov 66877aed54
Fix typo in guidelines-backend.en-us.md (#22690) 2023-01-31 21:43:12 +00:00
Ivan Maximov 706f4686b8
Fix typo in storage.en-us.md (#22694) 2023-01-31 22:42:41 +01:00
JakobDev be93e48ccb
Hide collapse icon in diff with no lines (#21094)
Sometimes (e.g. renaming a file) nothing of the content is changed. In
this case, it makes no sense to show the collapse icon in a diff.
2023-01-31 11:40:22 -06:00
Felipe Leopoldo Sologuren Gutiérrez 85016af1fe
Fixes accessibility behavior of Watching, Staring and Fork buttons (#22634)
Add tabindex to buttons of repository views.
2023-01-31 16:28:43 +01:00
KN4CK3R b80538f37d
Disable test for incoming email (#22686)
Disable this test for the moment because the used imap container image
seems unstable which results in many failed CI builds.

Co-authored-by: Jason Song <i@wolfogre.com>
2023-01-31 14:56:22 +01:00
Francesco Siddi c14d3e80e8
Remove label color from global issue filters (#22660)
The use of ui colors (red, green, etc) should be limited to actionable
or dismissable entries. Before this commit, a green/red label was used
to display issues count on each repository. This did not add any
meaningful information to the list.

Removing the label reduces ambiguity and makes the list easier to scan
visually.


![label_compare](https://user-images.githubusercontent.com/451841/215360696-a881b765-207d-4ffa-8bec-398f8e5dab1e.jpg)

---------

Co-authored-by: delvh <dev.lh@web.de>
2023-01-31 20:58:34 +08:00
wxiaoguang 36dc11869d
Use correct captured group range when parsing cross-reference (#22672)
Fixes #22666 (Replace #22668)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: zeripath <art27@cantab.net>
2023-01-31 10:08:05 +01:00
yp05327 f47ea60c07
set user visibility class to basic (#22674)
Same to https://github.com/go-gitea/gitea/pull/22605

![user
package](https://user-images.githubusercontent.com/18380374/215669905-71fe01c3-c011-4867-97a6-3df5f940a6bf.PNG)
![user
projects](https://user-images.githubusercontent.com/18380374/215669909-1a4f74f1-bbde-4913-9ba5-51c44cc63862.PNG)

These two page are both used at user and org, so if i fixed the org
page, the user page will be also be fixed.
2023-01-31 07:05:25 +00:00
crystal 03f37d82fe
Fix README TOC links (#22577)
Fixes anchored markup links by adding `user-content-` (which is
prepended to IDs)

Closes https://codeberg.org/Codeberg/Community/issues/894
2023-01-31 13:21:29 +08:00
Jason Song 4011821c94
Implement actions (#21937)
Close #13539.

Co-authored by: @lunny @appleboy @fuxiaohei and others.

Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner

### Summary

The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:

- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.

**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.

### ⚠️ Breaking

`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.

### Some important reviews

- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868

### What it looks like

<details>

#### Manage runners

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">

#### List runs

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">


#### View logs

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">



</details>

### How to try it

<details>

#### 1. Start Gitea

Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).

Add additional configurations in `app.ini` to enable Actions:

```ini
[actions]
ENABLED = true
```

Start it.

If all is well, you'll see the management page of runners:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">


#### 2. Start runner

Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.

If all is well, you'll see a new runner has been added:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">

#### 3. Enable actions for a repo

Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">

If all is well, you'll see a new tab "Actions":

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">

#### 4. Upload workflow files

Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:

```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
  Explore-GitHub-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
      - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
      - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v3
      - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
      - run: echo "🖥️ The workflow is now ready to test your code on the runner."
      - name: List files in the repository
        run: |
          ls ${{ github.workspace }}
      - run: echo "🍏 This job's status is ${{ job.status }}."
```

If all is well, you'll see a new run in `Actions` tab:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">

#### 5. Check the logs of jobs

Click a run and you'll see the logs:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">

#### 6. Go on

You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.

Come on, PRs are welcome.

</details>

See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)

---------

Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 09:45:19 +08:00
Brecht Van Lommel b5b3e0714e
Pull request yaml template support for including commit body in a field (#22629)
When using a markdown template the commit body is prepended to text in
the description. This adds the same functionality for yaml templates,
adding the commit message in a field with id "body".

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-30 22:39:07 +08:00
Gusted 1b53a9e914
Don't return duplicated users who can create org repo (#22560)
- Currently the function `GetUsersWhoCanCreateOrgRepo` uses a query that
is able to have duplicated users in the result, this is can happen under
the condition that a user is in team that either is the owner team or
has permission to create organization repositories.
- Add test code to simulate the above condition for user 3,
[`TestGetUsersWhoCanCreateOrgRepo`](a1fcb1cfb8/models/organization/org_test.go (L435))
is the test function that tests for this.
- The fix is quite trivial use a map keyed by user id in order to drop
duplicates.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-30 18:12:45 +08:00
Brecht Van Lommel be315c76fb
Fix poor alignment of organization description on organization home page (#22656)
Don't generate nested `<p>`, use `<div>` like description on the user
profile page.

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-30 16:16:12 +08:00
techknowlogick 203681d084
Issues: support setting issue template field values with query (#22545) 2023-01-30 12:36:04 +08:00
KN4CK3R d0d257b243
Add support for commit cross references (#22645)
Fixes #22628

This PR adds cross references for commits by using the format
`owner/repo@commit` . References are rendered like
[go-gitea/lgtm@6fe88302](#dummy).

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-30 09:50:01 +08:00
Brecht Van Lommel 3ff5a6a365
Fix missing message in git hook when pull requests disabled on fork (#22625)
And also the other way around, it would show an non-working URL in the
message when pull requests are disabled on the base repository but
enabled on the fork.
2023-01-29 15:00:10 -06:00
KN4CK3R d283a31f03
Check quota limits for container uploads (#22450)
The test coverage has revealed that container packages were not checked
against the quota limits.
2023-01-29 11:34:29 -06:00
John Olheiser 2052a9e2b4
Consume hcaptcha and pwn deps (#22610)
This PR just consumes the
[hcaptcha](https://gitea.com/jolheiser/hcaptcha) and
[haveibeenpwned](https://gitea.com/jolheiser/pwn) modules directly into
Gitea.

Also let this serve as a notice that I'm fine with transferring my
license (which was already MIT) from my own name to "The Gitea Authors".

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-29 09:49:51 -06:00
techknowlogick e88b529b31
Issues: add Project filter to issues list and search (#22544)
Currently only a single project like milestone, not multiple like
labels.

Implements #14298

Code by @brechtvl

---------

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-01-29 11:45:29 +08:00
Felipe Leopoldo Sologuren Gutiérrez 2b1e47e2a2
Improve accessibility of navigation bar and footer (#22635)
Added ARIA navigation landmark to navigation bar and aria label for both
nav bar and footer.

Contributed by @forgejo.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-29 09:29:10 +08:00
Lunny Xiao c0015979a6
Support system hook API (#14537)
This add system hook API
2023-01-28 19:12:10 +01:00
zeripath 78e6b21c1a
Improve checkIfPRContentChanged (#22611)
The code for checking if a commit has caused a change in a PR is
extremely inefficient and affects the head repository instead of using a
temporary repository.

This PR therefore makes several significant improvements:

* A temporary repo like that used in merging.
* The diff code is then significant improved to use a three-way diff
instead of comparing diffs (possibly binary) line-by-line - in memory...

Ref #22578

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-01-28 15:54:40 +00:00
Felipe Leopoldo Sologuren Gutiérrez e9cd18b557
Link issue and pull requests status change in UI notifications directly to their event in the timelined view. (#22627)
Adding the related comment to the issue and pull request status change
in the UI notifications allows to navigate directly to the specific
event in its dedicated view, easing the reading of last comments and to
the editor for additional comments if desired.
2023-01-28 11:16:46 +00:00
a1012112796 48f5d51908
fix permission check for creating comment while mail (#22524)
only creating comment on locked issue request write permission,
for others, read permission is enough.

related to https://github.com/go-gitea/gitea/pull/22056

/cc @KN4CK3R

---------

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-28 17:28:55 +08:00
Otto Richter (fnetX) 95d9fbdcf3
Fix error on account activation with wrong passwd (#22609)
On activating local accounts, the error message didn't differentiate
between using a wrong or expired token, or a wrong password. The result
could already be obtained from the behaviour (different screens were
presented), but the error message was misleading and lead to confusion
for new users on Codeberg with Forgejo.

Now, entering a wrong password for a valid token prints a different
error message.

The problem was introduced in 0f14f69e60.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-28 15:59:46 +08:00
Felipe Leopoldo Sologuren Gutiérrez 74466eb133
Fixes accessibility of empty repository commit status (#22632)
Avoid empty labelled anchor in repo without commits.

Contributed by @forgejo.

<!--

Please check the following:

1. Make sure you are targeting the `main` branch, pull requests on
release branches are only allowed for bug fixes.
2. Read contributing guidelines:
https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md
3. Describe what your pull request does and which issue you're targeting
(if any)

-->
2023-01-28 00:40:17 +02:00
KN4CK3R 51a92cb821
Use `--index-url` in PyPi description (#22620)
Fixes #22616

Co-authored-by: zeripath <art27@cantab.net>
2023-01-27 15:12:18 +01:00
KN4CK3R 5ff037ef51
Show migration validation error (#22619)
Discord request:
https://discord.com/channels/322538954119184384/322910365237248000/1067083214096703488

If there is a json schema validation error the full file content gets
dumped into the log. That does not help and may be a lot of data. This
PR prints the schema validation error message instead.
2023-01-27 20:56:00 +08:00
techknowlogick 2903afb78f
Allow issue templates to not render title (#22589)
This adds a yaml attribute that will allow the option for when markdown
is rendered that the title will be not included in the output

Based on work from @brechtvl
2023-01-26 22:45:49 -06:00
John Olheiser 642db3c8f7
Fix `delete_repo` in template (#22606)
Currently the value doesn't match the model, so selecting it results in
a 500.

e8ac6a9aea/models/auth/token_scope.go (L42)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-26 14:36:15 -06:00
yp05327 4f8c0eba9a
set org visibility class to basic in header (#22605)
Fixes https://github.com/go-gitea/gitea/issues/22601

At people and team page, we have red private tag or orange limited tag,
but at repo page, it is gray (basic).
I think it is better to set them into same color (basic).
2023-01-26 12:44:34 -06:00
JakobDev 4d072a4c4e
Add API endpoint to get latest release (#21267)
This PR adds a new API endpoint to get the latest stable release of a
repo, similar to [GitHub
API](https://docs.github.com/en/rest/releases/releases#get-the-latest-release).
2023-01-26 10:33:47 -06:00
wxiaoguang e8ac6a9aea
Add ARIA support for Fomantic UI checkboxes (#22599)
Replace #22593

This is a general approach to add ARIA support for all Fomantic UI
checkboxes (including radioboxes)

* Pros:
* General approach, it works for all Fomantic UI checkboxes / radioboxes
    * No need to write IDs manually everywhere
    * No need to tell new contributors to write IDs again and again

* Cons:
* Slightly affects performance, but it's really trivial, because there
was already a heavy `$('.ui.checkbox').checkbox()` for Fomantic UI
before. So everything is still fine.


Screenshot (from the repo setting page, which has various checkboxes):

<details>


![image](https://user-images.githubusercontent.com/2114189/214480937-3a54d36f-55c3-49de-9c45-c4bb21f1f4c6.png)

</details>
2023-01-25 17:52:10 +02:00
Brecht Van Lommel c8139c0f64
Webhooks: for issue close/reopen action, add commit ID that caused it (#22583)
The `commit_id` property name is the same as equivalent functionality in
GitHub. If the action was not caused by a commit, an empty string is
used.

This can for example be used to automatically add a Resolved label to an
issue fixed by a commit, or clear it when the issue is reopened.
2023-01-24 23:47:53 -05:00
Brecht Van Lommel a31fedd2c2 Add templates to customize text when creating and migrating repositories
These can be used to explain which types of repositories a Gitea instance is
willing to host, or other rules for creating repositories.
2023-01-24 22:36:48 -05:00
Sybren 25f4b7d7cd
Prevent duplicate labels when importing more than 99 (#22591)
Importing labels (via `gitea restore-repo`) did not split them up into
batches properly. The first "batch" would create all labels, the second
"batch" would create all labels except those in the first "batch", etc.
This meant that when importing more than 99 labels (the batch size)
there would always be duplicate ones.

This is solved by actually passing `labels[:lbBatchSize]` to the
`CreateLabels()` function, instead of the entire list `labels`.
2023-01-24 19:44:55 +00:00
Yarden Shoham b91bc68092
Remove address from DCO (#22595)
I copy-pasted from https://developercertificate.org/
2023-01-24 18:52:38 +00:00
Sybren 95e8ea9440
Allow setting `redirect_to` cookie on OAuth login (#22594)
The regular login flow can use a `redirect_to` cookie to ensure the user
ends their authentication flow on the same page as where they started
it.

This commit adds the same functionality to the OAuth login URLs, so that
you can use URLs like these to directly use a specific OAuth provider:

`/user/oauth2/{provider}?redirect_to={post-login path}`

Only the `auth.SignInOAuth()` function needed a change for this, as the
rest of the login flow is aware of this cookie and uses it properly
already.
2023-01-24 11:41:38 -05:00
John Olheiser 9cc15d18df
Project links should use parent link methods (#22587)
Instead of re-creating, these should use the available `Link` methods
from the "parent" of the project, which also take sub-urls into account.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-23 15:51:18 -06:00
rekayno 519b91ad2d
link update in README files (#22582)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2023-01-23 15:57:57 -05:00
John Olheiser 649f89efdc
Frontport 1.18.2 and 1.18.3 Changelogs (#22580)
Frontport #22530 #22575

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-23 09:36:00 -06:00
tiny6996 29b78bce33
Fix incorrect Redis URL snippets in the example app.ini (#22573)
Fixes #22571

Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
2023-01-23 02:17:15 +00:00
KN4CK3R 21dd4a252a
Prevent multiple `To` recipients (#22566)
Change the mailer interface to prevent leaking of possible hidden email
addresses when sending to multiple recipients.

Co-authored-by: Gusted <williamzijl7@hotmail.com>
2023-01-22 08:23:52 -06:00
techknowlogick 6737e1c5d5
gitlab supports ssh key signing (#22564) 2023-01-22 18:17:49 +08:00
Francesco Siddi 920ae2367f
Address feedback from #22517 (#22563)
- use octicons for icon
- use fomantic for centering the link
2023-01-21 22:14:43 -06:00
Lunny Xiao eb793c3361
Fix bug on user setting (#22539)
Fix #22537

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2023-01-21 15:31:11 +01:00
silverwind a1fcb1cfb8
Update JS dependencies (#22538)
- Update all JS dependencies
- Add new eslint rules
- Rebuild SVGs
- Tested citation and build

SVG changes are because of https://github.com/primer/octicons/pull/883.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-01-21 10:42:13 +08:00