Commit Graph

984 Commits

Author SHA1 Message Date
Adnan Maolood 8cc65ff876 gitsrht-update-hook: Use GraphQL for repository updates
Use GraphQL to update repository information so that user webhooks are
delivered.

The notice for autocreated repositories has been updated to reflect that
autocreated repositories are no longer deleted automatically.
2022-02-14 15:42:09 +01:00
Adnan Maolood 80c097e164 gitsrht/blueprints: Fix variable name 2022-02-14 15:42:09 +01:00
Adnan Maolood ea08854593 gitsrht-update-hook: go fmt 2022-02-14 15:42:09 +01:00
Adnan Maolood 6d95477839 gitsrht-shell: Use GraphQL for repository updates
Use GraphQL to update repository information so that user webhooks are
delivered.

As a consequence of this, autocreated repositories will have a default
visibility of PRIVATE instead of 'autocreated', and will therefore not
be deleted.
2022-02-14 15:42:09 +01:00
Adnan Maolood c63695bbd3 gitsrht-shell: go fmt 2022-02-14 15:42:09 +01:00
Adnan Maolood fede074a76 gitsrht-shell: go mod tidy 2022-02-14 15:42:09 +01:00
Adnan Maolood 91f92f2eac gitsrht-{shell,update-hook}: Support SRHT_CONFIG variable
Attempt to load the configuration file from the path specified in the
SRHT_CONFIG environment variable. If that fails, fallback to
/etc/sr.ht/config.ini.
2022-02-14 15:42:09 +01:00
Adnan Maolood dbd2a13b87 gitsrht/blueprints/manage: Fix GraphQL error handling 2022-02-14 15:42:09 +01:00
Adnan Maolood 91178ad95a gitsrht/templates/create.html: Fix variable names 2022-02-14 15:42:09 +01:00
Adnan Maolood 2c7b92d17a api/graph: Convert some errors into GraphQL errors 2022-02-14 15:42:09 +01:00
Adnan Maolood fd3c98802b api/graph: Remove usage of database.Apply 2022-02-14 15:42:09 +01:00
Adnan Maolood cbb50860b5 api/graph: Replace gqlErrorf with valid.Errorf 2022-02-14 15:42:09 +01:00
Adnan Maolood 6c4a0101f1 api/graph: Fix panic on nil inputs
Previously, a mutation which explicitly specified a null input would
cause the resolver to panic:

    mutation {
    	updateRepository(id: 1, input: {name: null}) {
        	id
        }
    }

Check that the input is not nil before casting it to avoid this panic.
2022-02-14 15:42:09 +01:00
Adnan Maolood b9b9f20166 api/graph: Add User.repository query
Replace the Query.repositoryByName and repositoryByOwner queries with a
new User.repository query which is more graph-like.

References: https://todo.sr.ht/~sircmpwn/sr.ht/309
2022-02-14 15:42:09 +01:00
Adnan Maolood 05916cebc1 api: Remove generated files, update Makefile
References: https://todo.sr.ht/~sircmpwn/sr.ht/307
2022-02-14 15:42:09 +01:00
Adnan Maolood bb9baf6584 gitsrht: Use GraphQL for repository updates/deletion
Rewrite the web frontend to use GraphQL mutations where necessary to
ensure that GraphQL user webhooks are delivered. Most of the routes
defined by scm.sr.ht became part of git.sr.ht. A separate commit will
remove those routes from scm.sr.ht to avoid conflicts.

As a bonus, a new clone endpoint was added to facilitate easy cloning of
third-party repositories. A clone button was added to the user dashboard
to make this functionality easily accessible.
2022-02-14 15:42:09 +01:00
Adnan Maolood c06bc64d77 api/graph: Add cloneUrl to createRepository
Add support for cloning repositories by URL using the optional cloneUrl
parameter.
2022-02-14 15:42:09 +01:00
Adnan Maolood 498c7c6bdb api/graph/model/object: Resolve tags
This fixes an error caused by attempting to resolve a reference which
points to a tag object.
2022-02-14 15:42:09 +01:00
Adnan Maolood f97f63dbfa api/graph: Remove repository query
Remove the repository query since it can be used to enumerate unlisted
repositories by ID.
2022-02-14 15:42:09 +01:00
Adnan Maolood 2506b8b2d2 api: Rig up user webhook delivery 2022-02-14 15:42:08 +01:00
Adnan Maolood e7c61e7404 api/graph: Rig up user webhook queries and mutations 2022-02-14 15:42:08 +01:00
Adnan Maolood b1fb3b187f go generate 2022-02-14 15:42:08 +01:00
Adnan Maolood 7b18ce30f0 api/graph/model: Add user webhook models 2022-02-14 15:42:08 +01:00
Adnan Maolood 5e0e5a63f8 gitsrht/alembic: Add GraphQL user webhook tables 2022-02-14 15:42:08 +01:00
Adnan Maolood c7e5713f38 go generate 2022-02-14 15:42:08 +01:00
Adnan Maolood f481c63492 api/graph: Design GraphQL-native webhooks schema 2022-02-14 15:42:08 +01:00
наб d3efd77b6d Unsplit blame chunks from consecutive final commits
These are split, like in porcelain mode in CLI, when consecutive final
commit lines are non-consecutive in the originals (I think?)

Closes: https://todo.sr.ht/~sircmpwn/git.sr.ht/357
2022-01-26 09:03:42 +01:00
Adnan Maolood 6067e8806a api/graph: Disallow invalid names in updateRepository 2022-01-13 19:26:38 +01:00
Simon Ser 9a9280faef api: import github.com/99designs/gqlgen
Create a new generate.go file which imports github.com/99designs/gqlgen.
This fixes this kind of error because go mod now knows about the
dependency:

    /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/cmd/gen.go:9:2: missing go.sum entry for module providing package github.com/urfave/cli/v2 (imported by github.com/99designs/gqlgen/cmd); to add:
    	go get github.com/99designs/gqlgen/cmd@v0.13.0
    /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/imports/prune.go:15:2: missing go.sum entry for module providing package golang.org/x/tools/go/ast/astutil (imported by github.com/99designs/gqlgen/internal/imports); to add:
    	go get github.com/99designs/gqlgen/internal/imports@v0.13.0
    /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/code/packages.go:8:2: missing go.sum entry for module providing package golang.org/x/tools/go/packages (imported by github.com/99designs/gqlgen/internal/code); to add:
    	go get github.com/99designs/gqlgen/internal/code@v0.13.0
    /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/imports/prune.go:16:2: missing go.sum entry for module providing package golang.org/x/tools/imports (imported by github.com/99designs/gqlgen/internal/imports); to add:
    	go get github.com/99designs/gqlgen/internal/imports@v0.13.0
    graph/resolver.go:7: running "go": exit status 1
    missing go.sum entry for module providing package github.com/vektah/dataloaden; to add:
    	go mod download github.com/vektah/dataloaden
    loaders/middleware.go:3: running "./gen": exit status 1
2022-01-11 09:37:45 +01:00
Simon Ser 0e2f1e4e0f go fmt 2022-01-11 09:37:44 +01:00
Simon Ser 1722324c7b api/graph: use GraphQL descriptions for docs 2022-01-11 09:37:43 +01:00
Drew DeVault 5c6ca3bd2f templates: include parent head block
Among other things, this ensures that the robots meta tag is present for
unlisted repositories.
2022-01-10 08:35:25 +01:00
Thorben Günther c0bc32deae api: Add settings field to version 2022-01-02 09:55:55 +01:00
Peter Sanchez 85f05c5103 Updating core-go version and go mod tidy 2021-12-22 12:30:17 +01:00
наб 94786a1ec9 gitsrht-update-hook: only print "skip-ci => not submitting" message once
Instead of for every pushed ref with submittable manifests
2021-12-15 11:34:41 +01:00
Simon Ser 1d8109ca57 Allow uploading multiple artifacts at once
Useful to upload both the tarball and the PGP signature at once,
for instance.

For some reason getlist returns a non-empty list even if the user
selects no file. If the user selects one or multiple files, it
behaves as expected. That's why len(file_list) isn't used for
validation.
2021-12-13 11:23:30 +01:00
наб d768598c0e /~o/r/refs/r: sort artifacts by filename
Now they're returned in SQL iteration order (by primary key?),
which sucks really bad if there's a few groups of similar artifacts
which get displayed in an effectively-random order
2021-12-13 10:20:59 +01:00
Drew DeVault 6603c1a766 gitsrht-keys: upgrade srht-keys dependency 2021-12-08 12:00:28 +01:00
Julien Moutinho 34326ace88 gitsrht-update-hook: update go.{mod,sum} for go-redis 2021-12-08 11:58:10 +01:00
Julien Moutinho 4596e334af gitsrht-keys: update go.{mod,sum} for go-redis 2021-12-08 11:58:10 +01:00
Julien Moutinho 389cc64d5d gitsrht-dispatch: add support for supplementary groups 2021-12-08 11:58:09 +01:00
Julien Moutinho 5a74fbcf42 gitsrht-update-hook: update go-redis to support Unix sockets 2021-12-08 11:58:09 +01:00
Julien Moutinho 0c9fd38127 gitsrht-keys: update go-redis to support Unix sockets 2021-12-08 11:58:07 +01:00
Ignas Kiela 7ea630b776 Add webhook queue monitoring 2021-12-08 11:58:02 +01:00
Ignas Kiela cee86147ce Use requests session with RefdbBackend 2021-12-08 11:57:54 +01:00
Peter Sanchez 3b62a4ceb4 go.mod: core-go version bump 2021-12-01 09:35:05 +01:00
Adnan Maolood 567e8f34ec Add forge and VCS meta tags
See https://sr.ht/~ancarda/vcs-autodiscovery/

References: https://todo.sr.ht/~sircmpwn/git.sr.ht/163
2021-11-29 08:52:21 +01:00
Robin Jarry 98568b1377 log: display clickable links
Replace explicit urls or email addresses by clickable links. Reuse the
existing regular expression in srht/markdown.py.

Detect references to valid commit ids and replace them by links to
git.sr.ht commits.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-24 09:15:52 +01:00
Simon Ser 4bddca82e9 gitsrht-update-hook: fix logger formatting
- Some Println calls were using format strings
- Some Printf calls were used without a format string
- %e is not valid, use %v instead
2021-11-05 10:33:01 +01:00
Bor Grošelj Simić f5db865a3b fix a 500 on refs/ in repos without a default branch 2021-10-25 08:48:20 +02:00