Commit Graph

984 Commits

Author SHA1 Message Date
Chris DeLuca b75d2f0e03 Change markup for diff insert/delete lines
HTML provides semantic markup for the concept of inserting and deleting
content from a document. Leveraging these tags can increase the
correctness and accessibility of the document without effecting its
presentation.

See:

- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ins
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del
2022-04-28 11:25:13 +02:00
Adnan Maolood 76af91d084 gitsrht/templates/user: Remove extraneous paragraph 2022-04-20 11:04:09 +02:00
Adnan Maolood ad82b3b38c api/server: Register @private directive 2022-04-18 11:13:59 +02:00
delthas 2a5f5783d6 Fix stripping trailing slashes of URLs
Most URLs ending with a trailing slash currently 404, because the strict
mode is not properly disabled in the app.

The strict_slashes value must be set before adding the routes.

After this patch, requesting URLs with a trailing slash will work as
expected (eg git.sr.ht/~sircmpwn/git.sr.ht/)
2022-04-14 10:33:04 +02:00
delthas 530f4839a1 Fix obsolete Jinja2 imports
jinja2.Markup was moved to markupsafe.Markup.

See: https://github.com/pallets/jinja/issues/1438
2022-04-14 10:32:57 +02:00
Conrad Hoffmann 9fb34d9273 Add api-origin to example config
If the service is not behind a reverse proxy (e.g. during local
development/testing) then this is needed by meta.sr.ht for API discovery
for all services that have a seperate API component. Add this (commented
out) to the example config, to make it easier to discover this (and
require less documentation).
2022-04-08 14:09:23 +02:00
Adnan Maolood 1838cce8c7 gitsrht/blueprints/api: Fix canonical_name
Fix canonical_name, which was wrongly named canonicalName, in user
resources returned by the legacy API.

Also take the opportunity to refactor the GraphQL queries such that each
query retrieves only the data it needs.
2022-04-08 14:09:10 +02:00
Simon Ser 163edba401 gitsrht-update-hook: include branch name in job tags
This allows having a per-branch filter for build jobs. Use-cases
include a build badge which only displays status for the default
branch, or a getting the latest build artifacts only for the
default branch.
2022-04-08 14:09:07 +02:00
Drew DeVault be6100f36c gqlgen.yml: rename generated file 2022-03-24 14:39:07 +01:00
Drew DeVault e62353e5c7 Makefile: update Python version 2022-03-24 12:38:17 +01:00
Drew DeVault 6b6cdfb159 Makefile: build gitsrht-* Go programs 2022-03-24 12:12:16 +01:00
Drew DeVault 4439008384 api: update gqlgen 2022-03-24 11:34:19 +01:00
Adnan Maolood f4580eca83 api/graph: Improve error handling 2022-03-24 11:19:04 +01:00
Ignas Kiela 41c01b9e4d Get all author users with a single query for log
Right now repos log page is the slowest page on git.sr.ht, and a big
reason for that is that it currently averages on 19 queries per view,
most of them coming from the template looking up users to show links to
their user pages. We can get all the users we have before that, and pass
that on to the template. With these changes, a page view always takes 5
queries consistently.
2022-03-21 10:28:50 +01:00
xdavidwu 02ed08c389 email: use start_smtp from core.sr.ht
This make it support smtp-encryption config
2022-03-14 12:23:08 +01:00
Conrad Hoffmann 8c445ecb04 Supply missing ENUM type name 2022-03-14 12:23:02 +01:00
Adnan Maolood ad42bf4448 gitsrht: Store visibility as enum instead of varchar
Add a 'visibility' enum type to the database and use it for the
repository.visibility column.

This required changes to scm.sr.ht code. Instead of updating scm.sr.ht,
most of the scm.sr.ht code that git.sr.ht uses was moved to git.sr.ht.
2022-03-14 09:59:12 +01:00
Adnan Maolood cd8225a534 gitsrht: Add missing templates 2022-03-14 09:56:09 +01:00
Drew DeVault cc626a3fb2 .builds/alpine.yml: upgrade to 3.15 2022-02-21 18:19:33 +01:00
Hoolean 985b1e58af Fix text wrapping for multi-line cover letters and commentary
Fixes: https://todo.sr.ht/~sircmpwn/git.sr.ht/360
2022-02-21 11:32:14 +01:00
Adnan Maolood 95f9f1e539 gitsrht/blueprints/api: Accept lowercase visibility
Fixes: https://todo.sr.ht/~sircmpwn/git.sr.ht/361
2022-02-21 11:29:22 +01:00
Adnan Maolood 26f3346fff gitsrht-update-hook: Use owner username instead of pusher username
Use the owner username to authenticate to the GraphQL API instead of the
pusher username.

Fixes: https://todo.sr.ht/~sircmpwn/git.sr.ht/362
2022-02-21 11:25:13 +01:00
Adnan Maolood 42c0008108 api/loaders: Add RepositoriesByOwnerIDRepoName loader 2022-02-17 14:47:37 +01:00
Adnan Maolood aaa1f6f287 api/loaders: Refactor RepositoriesByOwnerRepoName 2022-02-17 14:47:36 +01:00
Adnan Maolood 4e8fd8c296 api: Handle clone errors
This adds two new columns to the database: clone_status and clone_error,
which are used to store the clone status as well as any error that
occurs. The error is then displayed to the user in the frontend.
2022-02-17 14:45:57 +01:00
Adnan Maolood c3727531fd api/graph/schema.graphqls: Clarify Entity docstrings 2022-02-17 14:43:25 +01:00
Adnan Maolood d3869ff5f2 api/loaders: Remove unused loader 2022-02-17 14:43:24 +01:00
Adnan Maolood a15657f955 api/webhooks: Move middlewares to core-go 2022-02-17 14:43:06 +01:00
Adnan Maolood d0c8853244 gitsrht-update-hook/post-update: Always execute updateRepository
Always execute the updateRepository GraphQL mutation so that the
repository updated timestamp will be set.
2022-02-15 13:12:07 +01:00
Adnan Maolood ffb36c00d0 api/graph: Delete artifacts upon repository deletion
Upon deleting a repository, gather a list of all the artifacts
associated with it and schedule their deletion in a background task.

Fixes: https://todo.sr.ht/~sircmpwn/git.sr.ht/356
2022-02-15 13:12:07 +01:00
Adnan Maolood 9d12b36978 api/graph/repos: Rename from clones 2022-02-15 13:12:06 +01:00
Adnan Maolood 052afbaeb7 Drop source_repo_id and upstream_uri from repository 2022-02-15 13:12:06 +01:00
Adnan Maolood f02b01b777 gitsrht/types: Remove Repository.update_visibility method 2022-02-15 13:12:05 +01:00
Adnan Maolood 709b95dfb3 gitsrht/alembic: Remove usage of update_visibility
This method will be removed from the Repository class. Print a warning
instead.
2022-02-15 13:12:04 +01:00
Drew DeVault 136bd3848a API: createRepository: create git-daemon-export-ok
This file is necessary for git clones to work for public and unlisted
repositories.
2022-02-15 09:11:22 +01:00
Adnan Maolood fb3f415734 api/clones: Unset clone_in_progress on panic 2022-02-14 16:00:01 +01:00
Adnan Maolood 47ec8529b4 api/clones: Timeout clones after 10 minutes 2022-02-14 15:42:10 +01:00
Adnan Maolood 91eb5822e8 gitsrht: Indicate if a clone is in progress 2022-02-14 15:42:10 +01:00
Adnan Maolood 115487d546 api/graph: Execute webhook queries before deletion
Execute GraphQL webhook queries after the repository has been deleted
from the database, but before the files have been removed from the
filesystem. This prevents filesystem errors during query execution.

We don't need to execute the query before the repository is deleted from
the database since all the information we need from the database has
been retrieved.

References: https://todo.sr.ht/~sircmpwn/sr.ht/301
2022-02-14 15:42:10 +01:00
Adnan Maolood 902c41aa31 gitsrht-update-hook: Only update repo when necessary
Only update repository information when a new description or visibility
is specified in the push options. This prevents an extraneous
REPO_UPDATE event from being triggered on every push.

Also remove the updateVisibility function, as this is taken care of by
the GraphQL API.
2022-02-14 15:42:10 +01:00
Adnan Maolood 81c8b7d3e2 gitsrht: Remove references to autocreated
The autocreated visibility isn't used anymore.
2022-02-14 15:42:10 +01:00
Adnan Maolood 54933b0dad gitsrht/blueprints: Pass view to empty-repo template
This allows the currently selected view to be highlighted.
2022-02-14 15:42:10 +01:00
Adnan Maolood bfe927d305 gitsrht/templates/repo: Remove go-source meta tag
The go-source meta tag was only used by godoc.org, which is now
obsolete. We should encourage the use of forge meta tags instead.
2022-02-14 15:42:10 +01:00
Drew DeVault e5bf52f988 API: Switch to SourceHut go-git tree 2022-02-14 15:42:10 +01:00
Adnan Maolood 188abe70fa api/graph: Do clones in the background 2022-02-14 15:42:10 +01:00
Adnan Maolood 8806cc14f6 api/graph: Add HEAD field to RepoInput type
Add a HEAD field to the RepoInput type to allow setting the default
branch name with the updateRepository GraphQL mutation. Also modify the
frontend to use the HEAD field for the repository settings page.

Implements: https://todo.sr.ht/~sircmpwn/git.sr.ht/358
2022-02-14 15:42:10 +01:00
Adnan Maolood 63c4d12448 Makefile: Fix race condition
Generating the GraphQL API with gqlgen will fail if the loaders have not
been generated yet. Ensure that the loaders are always generated first.
2022-02-14 15:42:10 +01:00
Drew DeVault e99eddb3c0 API: Update go.mod, style fixes 2022-02-14 15:42:10 +01:00
Adnan Maolood 3ba441903e gitsrht: Add missing routes
These routes should have been added to git.sr.ht along with the rest of
the routes moved over from scm.sr.ht.
2022-02-14 15:42:10 +01:00
Adnan Maolood eb8cf38ab0 gitsrht: Remove debugging print statement 2022-02-14 15:42:10 +01:00