2016-02-27 05:41:36 +00:00
|
|
|
{- This file is part of Vervis.
|
|
|
|
-
|
2022-06-22 06:19:37 +00:00
|
|
|
- Written in 2016, 2018, 2019, 2020, 2022
|
|
|
|
- by fr33domlover <fr33domlover@riseup.net>.
|
2016-02-27 05:41:36 +00:00
|
|
|
-
|
|
|
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
|
|
|
-
|
|
|
|
- The author(s) have dedicated all copyright and related and neighboring
|
|
|
|
- rights to this software to the public domain worldwide. This software is
|
|
|
|
- distributed without any warranty.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
|
|
|
- with this software. If not, see
|
|
|
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Vervis.Handler.Repo
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
( getRepoR
|
|
|
|
, getRepoInboxR
|
|
|
|
, postRepoInboxR
|
|
|
|
, getRepoOutboxR
|
|
|
|
, getRepoOutboxItemR
|
|
|
|
, getRepoFollowersR
|
|
|
|
|
|
|
|
, getDarcsDownloadR
|
|
|
|
, getGitRefDiscoverR
|
|
|
|
, postGitUploadRequestR
|
|
|
|
|
|
|
|
, getRepoSourceR
|
|
|
|
, getRepoBranchSourceR
|
|
|
|
, getRepoCommitsR
|
|
|
|
, getRepoBranchCommitsR
|
|
|
|
, getRepoCommitR
|
|
|
|
|
2016-02-27 05:41:36 +00:00
|
|
|
, getRepoNewR
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
, postRepoNewR
|
|
|
|
, postRepoDeleteR
|
|
|
|
, getRepoEditR
|
|
|
|
, postRepoEditR
|
|
|
|
, postRepoFollowR
|
|
|
|
, postRepoUnfollowR
|
|
|
|
|
|
|
|
, postPostReceiveR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{-
|
|
|
|
, getReposR
|
2016-06-05 21:11:05 +00:00
|
|
|
, putRepoR
|
2016-05-13 19:23:56 +00:00
|
|
|
, postRepoR
|
2019-08-28 15:31:40 +00:00
|
|
|
, getRepoBranchR
|
2016-05-29 14:13:25 +00:00
|
|
|
, getRepoDevsR
|
|
|
|
, postRepoDevsR
|
|
|
|
, getRepoDevNewR
|
|
|
|
, getRepoDevR
|
|
|
|
, deleteRepoDevR
|
|
|
|
, postRepoDevR
|
2019-09-09 00:27:45 +00:00
|
|
|
, getRepoTeamR
|
2019-05-27 13:28:57 +00:00
|
|
|
|
|
|
|
, getHighlightStyleR
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
-}
|
2016-02-27 05:41:36 +00:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
2019-09-09 00:27:45 +00:00
|
|
|
import Control.Exception hiding (Handler)
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import Control.Monad
|
2016-05-23 20:46:54 +00:00
|
|
|
import Control.Monad.IO.Class (liftIO)
|
|
|
|
import Control.Monad.Logger (logWarn)
|
2020-07-02 13:21:59 +00:00
|
|
|
import Control.Monad.Trans.Except
|
2019-09-09 00:27:45 +00:00
|
|
|
import Data.Bifunctor
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import Data.Binary.Put
|
2022-09-06 10:52:14 +00:00
|
|
|
import Data.ByteString (ByteString)
|
2022-06-22 06:19:37 +00:00
|
|
|
import Data.Foldable
|
2016-04-09 15:45:00 +00:00
|
|
|
import Data.Git.Graph
|
2016-04-30 20:14:56 +00:00
|
|
|
import Data.Git.Harder
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import Data.Git.Harder.Pack
|
2016-04-12 00:19:04 +00:00
|
|
|
import Data.Git.Named (RefName (..))
|
2016-03-03 08:15:54 +00:00
|
|
|
import Data.Git.Ref (toHex)
|
2016-05-04 11:44:06 +00:00
|
|
|
import Data.Git.Repository
|
2016-05-04 17:17:47 +00:00
|
|
|
import Data.Git.Storage (withRepo)
|
2016-04-12 10:06:21 +00:00
|
|
|
import Data.Git.Storage.Object (Object (..))
|
2019-09-09 00:27:45 +00:00
|
|
|
import Data.Git.Types (Blob (..), Person (..), entName)
|
2016-04-09 15:45:00 +00:00
|
|
|
import Data.Graph.Inductive.Graph (noNodes)
|
|
|
|
import Data.Graph.Inductive.Query.Topsort
|
2016-04-12 23:10:46 +00:00
|
|
|
import Data.List (inits)
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import Data.Maybe
|
|
|
|
import Data.String
|
2016-05-23 20:46:54 +00:00
|
|
|
import Data.Text (Text, unpack)
|
2019-09-09 00:27:45 +00:00
|
|
|
import Data.Text.Encoding
|
2016-03-03 08:15:54 +00:00
|
|
|
import Data.Text.Encoding.Error (lenientDecode)
|
2022-06-22 06:19:37 +00:00
|
|
|
import Data.Time.Clock
|
2016-06-05 21:11:05 +00:00
|
|
|
import Data.Traversable (for)
|
2019-09-09 00:27:45 +00:00
|
|
|
import Database.Persist
|
|
|
|
import Database.Persist.Sql
|
2016-03-03 08:15:54 +00:00
|
|
|
import Data.Hourglass (timeConvert)
|
2016-05-13 19:23:56 +00:00
|
|
|
import Formatting (sformat, stext, (%))
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import Network.Git.Transport.HTTP.Fetch.RefDiscovery
|
|
|
|
import Network.Git.Transport.HTTP.Fetch.UploadRequest
|
|
|
|
import Network.Git.Types
|
|
|
|
import Network.Wai (strictRequestBody)
|
2016-05-13 19:23:56 +00:00
|
|
|
import System.Directory
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import System.FilePath
|
2016-03-03 08:15:54 +00:00
|
|
|
import System.Hourglass (dateCurrent)
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import System.IO
|
|
|
|
import System.Process
|
2016-05-23 20:46:54 +00:00
|
|
|
import Text.Blaze.Html (Html)
|
2019-05-27 13:28:57 +00:00
|
|
|
import Text.Pandoc.Highlighting
|
2022-09-16 10:34:44 +00:00
|
|
|
import Yesod.Auth
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import Yesod.Core hiding (joinPath)
|
2019-05-27 13:28:57 +00:00
|
|
|
import Yesod.Core.Content
|
2016-05-23 20:46:54 +00:00
|
|
|
import Yesod.Core.Handler (lookupPostParam, redirect, notFound)
|
|
|
|
import Yesod.Form.Functions (runFormPost)
|
|
|
|
import Yesod.Form.Types (FormResult (..))
|
2019-12-27 20:44:14 +00:00
|
|
|
import Yesod.Persist.Core
|
2016-03-03 08:15:54 +00:00
|
|
|
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import qualified Data.ByteString as B
|
|
|
|
import qualified Data.ByteString.Lazy as BL
|
|
|
|
import qualified Data.ByteString.Lazy.Internal as BLI
|
2016-05-23 20:46:54 +00:00
|
|
|
import qualified Data.CaseInsensitive as CI (foldedCase)
|
2016-04-09 15:45:00 +00:00
|
|
|
import qualified Data.DList as D
|
2016-04-12 00:19:04 +00:00
|
|
|
import qualified Data.Set as S (member)
|
2019-09-09 00:27:45 +00:00
|
|
|
import qualified Data.Text as T
|
2016-04-12 10:06:21 +00:00
|
|
|
import qualified Data.Text.Lazy.Encoding as L (decodeUtf8With)
|
2019-09-09 00:27:45 +00:00
|
|
|
import qualified Database.Esqueleto as E
|
|
|
|
|
|
|
|
import Data.MediaType
|
2022-06-22 06:19:37 +00:00
|
|
|
import Database.Persist.JSON
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import Development.PatchMediaType
|
2019-10-20 09:19:49 +00:00
|
|
|
import Network.FedURI
|
2019-09-09 00:27:45 +00:00
|
|
|
import Yesod.ActivityPub
|
|
|
|
import Yesod.FedURI
|
|
|
|
import Yesod.Hashids
|
|
|
|
import Yesod.MonadSite
|
|
|
|
import Yesod.RenderSource
|
|
|
|
|
|
|
|
import qualified Web.ActivityPub as AP
|
2016-04-09 15:45:00 +00:00
|
|
|
|
2016-03-03 08:15:54 +00:00
|
|
|
import Data.ByteString.Char8.Local (takeLine)
|
2019-09-09 00:27:45 +00:00
|
|
|
import Data.Either.Local
|
2016-05-04 17:17:47 +00:00
|
|
|
import Data.Git.Local
|
2019-09-09 00:27:45 +00:00
|
|
|
import Database.Persist.Local
|
2016-04-17 17:55:23 +00:00
|
|
|
import Text.FilePath.Local (breakExt)
|
2022-09-16 10:34:44 +00:00
|
|
|
import Yesod.Form.Local
|
2019-09-09 00:27:45 +00:00
|
|
|
import Yesod.Persist.Local
|
|
|
|
|
|
|
|
import qualified Data.Git.Local as G (createRepo)
|
|
|
|
import qualified Darcs.Local.Repository as D (createRepo)
|
|
|
|
|
2022-09-08 12:00:14 +00:00
|
|
|
import Vervis.Access
|
2019-09-09 00:27:45 +00:00
|
|
|
import Vervis.API
|
2022-09-06 10:52:14 +00:00
|
|
|
import Vervis.Federation.Auth
|
2022-09-08 12:00:14 +00:00
|
|
|
import Vervis.Federation.Collab
|
2022-09-06 10:52:14 +00:00
|
|
|
import Vervis.FedURI
|
2022-09-16 10:34:44 +00:00
|
|
|
import Vervis.Form.Repo
|
2016-03-03 08:15:54 +00:00
|
|
|
import Vervis.Foundation
|
|
|
|
import Vervis.Path
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
import Vervis.Model
|
2016-05-23 20:46:54 +00:00
|
|
|
import Vervis.Model.Ident
|
2016-05-13 08:49:19 +00:00
|
|
|
import Vervis.Paginate
|
2016-04-13 16:17:34 +00:00
|
|
|
import Vervis.Readme
|
2022-09-06 10:52:14 +00:00
|
|
|
import Vervis.Recipient
|
2016-03-03 08:15:54 +00:00
|
|
|
import Vervis.Settings
|
2016-05-05 07:29:19 +00:00
|
|
|
import Vervis.SourceTree
|
2016-04-12 14:44:43 +00:00
|
|
|
import Vervis.Style
|
2022-09-06 10:52:14 +00:00
|
|
|
import Vervis.Web.Actor
|
2022-09-16 11:41:58 +00:00
|
|
|
import Vervis.Web.Darcs
|
|
|
|
import Vervis.Web.Git
|
2016-02-27 05:41:36 +00:00
|
|
|
|
2022-09-16 10:34:44 +00:00
|
|
|
import qualified Vervis.Client as C
|
2016-05-23 20:46:54 +00:00
|
|
|
import qualified Vervis.Formatting as F
|
2019-09-09 00:27:45 +00:00
|
|
|
import qualified Vervis.Hook as H
|
2016-05-04 11:44:06 +00:00
|
|
|
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
getRepoR :: KeyHashid Repo -> Handler TypedContent
|
|
|
|
getRepoR repoHash = do
|
|
|
|
repoID <- decodeKeyHashid404 repoHash
|
|
|
|
(repo, actor) <- runDB $ do
|
|
|
|
r <- get404 repoID
|
|
|
|
(r,) <$> getJust (repoActor r)
|
|
|
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
let repoAP = AP.Repo
|
|
|
|
{ AP.repoActor = AP.Actor
|
|
|
|
{ AP.actorLocal = AP.ActorLocal
|
|
|
|
{ AP.actorId = encodeRouteLocal $ RepoR repoHash
|
|
|
|
, AP.actorInbox = encodeRouteLocal $ RepoInboxR repoHash
|
|
|
|
, AP.actorOutbox =
|
|
|
|
Just $ encodeRouteLocal $ RepoOutboxR repoHash
|
|
|
|
, AP.actorFollowers =
|
|
|
|
Just $ encodeRouteLocal $ RepoFollowersR repoHash
|
|
|
|
, AP.actorFollowing = Nothing
|
|
|
|
, AP.actorPublicKeys =
|
|
|
|
[ Left $ encodeRouteLocal ActorKey1R
|
|
|
|
, Left $ encodeRouteLocal ActorKey2R
|
|
|
|
]
|
|
|
|
, AP.actorSshKeys = []
|
|
|
|
}
|
|
|
|
, AP.actorDetail = AP.ActorDetail
|
|
|
|
{ AP.actorType = AP.ActorTypeRepo
|
|
|
|
, AP.actorUsername = Nothing
|
|
|
|
, AP.actorName = Just $ actorName actor
|
|
|
|
, AP.actorSummary = Just $ actorDesc actor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
, AP.repoTeam = Nothing
|
|
|
|
, AP.repoVcs = repoVcs repo
|
|
|
|
}
|
|
|
|
|
|
|
|
next =
|
|
|
|
case repoVcs repo of
|
|
|
|
VCSDarcs -> RepoSourceR repoHash
|
|
|
|
VCSGit -> RepoBranchSourceR repoHash $ repoMainBranch repo
|
|
|
|
provideHtmlAndAP repoAP $ redirect $ next []
|
|
|
|
|
|
|
|
getRepoInboxR :: KeyHashid Repo -> Handler TypedContent
|
|
|
|
getRepoInboxR = getInbox RepoInboxR repoActor
|
|
|
|
|
2022-09-06 10:52:14 +00:00
|
|
|
postRepoInboxR :: KeyHashid Repo -> Handler ()
|
|
|
|
postRepoInboxR recipRepoHash =
|
|
|
|
postInbox $ handleRobotInbox (LocalActorRepo recipRepoHash) handle
|
|
|
|
where
|
|
|
|
handle
|
2022-09-08 12:00:14 +00:00
|
|
|
:: UTCTime
|
|
|
|
-> RemoteAuthor
|
|
|
|
-> ActivityBody
|
2022-09-06 10:52:14 +00:00
|
|
|
-> Maybe (RecipientRoutes, ByteString)
|
|
|
|
-> LocalURI
|
|
|
|
-> AP.SpecificActivity URIMode
|
|
|
|
-> ExceptT Text Handler (Text, Maybe (ExceptT Text Worker Text))
|
2022-09-08 12:00:14 +00:00
|
|
|
handle now author body mfwd luActivity specific =
|
2022-09-06 10:52:14 +00:00
|
|
|
case specific of
|
2022-09-08 12:00:14 +00:00
|
|
|
AP.AcceptActivity accept ->
|
|
|
|
repoAcceptF now recipRepoHash author body mfwd luActivity accept
|
2022-09-06 10:52:14 +00:00
|
|
|
{-
|
|
|
|
ApplyActivity (AP.Apply uObject uTarget) ->
|
|
|
|
repoApplyF now shrRecip rpRecip remoteAuthor body mfwd luActivity uObject uTarget
|
|
|
|
AddActivity (AP.Add obj target) ->
|
|
|
|
case obj of
|
|
|
|
Right (AddBundle patches) ->
|
|
|
|
repoAddBundleF now shrRecip rpRecip remoteAuthor body mfwd luActivity patches target
|
|
|
|
_ -> return ("Unsupported add object type for repos", Nothing)
|
|
|
|
CreateActivity (Create obj mtarget) ->
|
|
|
|
case obj of
|
|
|
|
CreateNote _ note ->
|
|
|
|
(,Nothing) <$> repoCreateNoteF now shrRecip rpRecip remoteAuthor body mfwd luActivity note
|
|
|
|
CreateTicket _ ticket ->
|
|
|
|
(,Nothing) <$> repoCreateTicketF now shrRecip rpRecip remoteAuthor body mfwd luActivity ticket mtarget
|
|
|
|
_ -> error "Unsupported create object type for repos"
|
|
|
|
FollowActivity follow ->
|
|
|
|
(,Nothing) <$> repoFollowF shrRecip rpRecip now remoteAuthor body mfwd luActivity follow
|
2022-09-08 12:00:14 +00:00
|
|
|
-}
|
|
|
|
AP.InviteActivity invite ->
|
|
|
|
topicInviteF now (GrantResourceRepo recipRepoHash) author body mfwd luActivity invite
|
|
|
|
{-
|
2022-09-06 10:52:14 +00:00
|
|
|
OfferActivity (Offer obj target) ->
|
|
|
|
case obj of
|
|
|
|
OfferTicket ticket ->
|
|
|
|
(,Nothing) <$> repoOfferTicketF now shrRecip rpRecip remoteAuthor body mfwd luActivity ticket target
|
|
|
|
OfferDep dep ->
|
|
|
|
repoOfferDepF now shrRecip rpRecip remoteAuthor body mfwd luActivity dep target
|
|
|
|
_ -> return ("Unsupported offer object type for repos", Nothing)
|
|
|
|
ResolveActivity resolve ->
|
|
|
|
(,Nothing) <$> repoResolveF now shrRecip rpRecip remoteAuthor body mfwd luActivity resolve
|
|
|
|
UndoActivity undo->
|
|
|
|
(,Nothing) <$> repoUndoF shrRecip rpRecip now remoteAuthor body mfwd luActivity undo
|
|
|
|
-}
|
|
|
|
_ -> return ("Unsupported activity type for repos", Nothing)
|
2016-02-27 05:41:36 +00:00
|
|
|
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
getRepoOutboxR :: KeyHashid Repo -> Handler TypedContent
|
|
|
|
getRepoOutboxR = getOutbox RepoOutboxR repoActor
|
|
|
|
|
|
|
|
getRepoOutboxItemR
|
|
|
|
:: KeyHashid Repo -> KeyHashid OutboxItem -> Handler TypedContent
|
|
|
|
getRepoOutboxItemR = getOutboxItem RepoOutboxItemR repoActor
|
|
|
|
|
|
|
|
getRepoFollowersR :: KeyHashid Repo -> Handler TypedContent
|
|
|
|
getRepoFollowersR = getActorFollowersCollection RepoFollowersR repoActor
|
|
|
|
|
|
|
|
getDarcsDownloadR :: KeyHashid Repo -> [Text] -> Handler TypedContent
|
|
|
|
getDarcsDownloadR repoHash dir = do
|
|
|
|
repoPath <- askRepoDir repoHash
|
|
|
|
let filePath = repoPath </> "_darcs" </> joinPath (map T.unpack dir)
|
|
|
|
exists <- liftIO $ doesFileExist filePath
|
|
|
|
if exists
|
|
|
|
then sendFile typeOctet filePath
|
|
|
|
else notFound
|
|
|
|
|
|
|
|
getGitRefDiscoverR :: KeyHashid Repo -> Handler TypedContent
|
|
|
|
getGitRefDiscoverR repoHash = do
|
|
|
|
let typ = "application/x-git-upload-pack-advertisement"
|
|
|
|
path <- askRepoDir repoHash
|
|
|
|
let pathG = fromString path
|
|
|
|
seemsThere <- liftIO $ isRepo pathG
|
|
|
|
if seemsThere
|
|
|
|
then do
|
|
|
|
rq <- getRequest
|
|
|
|
case reqGetParams rq of
|
|
|
|
[("service", serv)] ->
|
|
|
|
if serv == "git-upload-pack"
|
|
|
|
then do
|
|
|
|
let settings =
|
|
|
|
( proc "git"
|
|
|
|
[ "upload-pack"
|
|
|
|
, "--stateless-rpc"
|
|
|
|
, "--advertise-refs"
|
|
|
|
, path
|
|
|
|
]
|
|
|
|
)
|
|
|
|
{ std_out = CreatePipe
|
|
|
|
}
|
|
|
|
(_, mh, _, _) <-
|
|
|
|
liftIO $ createProcess settings
|
|
|
|
let h = fromJust mh
|
|
|
|
refs <- liftIO $ B.hGetContents h
|
|
|
|
let content = runPut $ do
|
|
|
|
putService UploadPack
|
|
|
|
putByteString refs
|
|
|
|
setHeader "Cache-Control" "no-cache"
|
|
|
|
return $ TypedContent typ $ toContent content
|
|
|
|
else permissionDenied "Service not supported"
|
|
|
|
_ -> notFound
|
|
|
|
else notFound
|
|
|
|
|
|
|
|
postGitUploadRequestR :: KeyHashid Repo -> Handler TypedContent
|
|
|
|
postGitUploadRequestR repoHash = do
|
|
|
|
let typ = "application/x-git-upload-pack-result"
|
|
|
|
path <- askRepoDir repoHash
|
|
|
|
let pathG = fromString path
|
|
|
|
seemsThere <- liftIO $ isRepo pathG
|
|
|
|
if seemsThere
|
|
|
|
then do
|
|
|
|
getBody <- strictRequestBody <$> waiRequest
|
|
|
|
body <- liftIO getBody
|
|
|
|
let settings =
|
|
|
|
( proc "git"
|
|
|
|
[ "upload-pack"
|
|
|
|
, "--stateless-rpc"
|
|
|
|
, path
|
|
|
|
]
|
|
|
|
)
|
|
|
|
{ std_in = CreatePipe
|
|
|
|
, std_out = CreatePipe
|
|
|
|
}
|
|
|
|
(mhin, mhout, _, _) <- liftIO $ createProcess settings
|
|
|
|
let hin = fromJust mhin
|
|
|
|
hout = fromJust mhout
|
|
|
|
liftIO $ BL.hPut hin body >> hClose hin
|
|
|
|
setHeader "Cache-Control" "no-cache"
|
|
|
|
let loop = do
|
|
|
|
b <- liftIO $ B.hGet hout BLI.defaultChunkSize
|
|
|
|
unless (B.null b) $ do
|
|
|
|
sendChunkBS b
|
|
|
|
loop
|
|
|
|
respondSource typ loop
|
|
|
|
else notFound
|
|
|
|
|
|
|
|
getRepoSourceR :: KeyHashid Repo -> [Text] -> Handler Html
|
|
|
|
getRepoSourceR repoHash path = do
|
|
|
|
repoID <- decodeKeyHashid404 repoHash
|
|
|
|
repo <- runDB $ get404 repoID
|
|
|
|
case repoVcs repo of
|
|
|
|
VCSDarcs -> error "Temporarily disabled"
|
|
|
|
--getDarcsRepoSource repo repoHash path
|
|
|
|
VCSGit -> notFound
|
|
|
|
|
|
|
|
getRepoBranchSourceR :: KeyHashid Repo -> Text -> [Text] -> Handler Html
|
|
|
|
getRepoBranchSourceR repoHash branch path = do
|
|
|
|
repoID <- decodeKeyHashid404 repoHash
|
|
|
|
repo <- runDB $ get404 repoID
|
|
|
|
case repoVcs repo of
|
|
|
|
VCSDarcs -> notFound
|
|
|
|
VCSGit -> error "Temporarily disabled"
|
|
|
|
--getGitRepoSource repo repoHash branch dir
|
|
|
|
|
|
|
|
getRepoCommitsR :: KeyHashid Repo -> Handler TypedContent
|
|
|
|
getRepoCommitsR repoHash = do
|
|
|
|
repoID <- decodeKeyHashid404 repoHash
|
|
|
|
repo <- runDB $ get404 repoID
|
|
|
|
case repoVcs repo of
|
|
|
|
VCSDarcs ->
|
|
|
|
error "Temporarily disabled"
|
|
|
|
--getDarcsRepoHeadChanges repoHash
|
|
|
|
VCSGit ->
|
|
|
|
error "Temporarily disabled"
|
|
|
|
--getGitRepoHeadChanges repo repoHash
|
|
|
|
|
|
|
|
getRepoBranchCommitsR :: KeyHashid Repo -> Text -> Handler TypedContent
|
|
|
|
getRepoBranchCommitsR repoHash branch = do
|
|
|
|
repoID <- decodeKeyHashid404 repoHash
|
|
|
|
repo <- runDB $ get404 repoID
|
|
|
|
case repoVcs repo of
|
|
|
|
VCSDarcs ->
|
|
|
|
error "Temporarily disabled"
|
|
|
|
--getDarcsRepoChanges repoHash branch
|
|
|
|
VCSGit ->
|
|
|
|
error "Temporarily disabled"
|
|
|
|
--getGitRepoChanges repoHash branch
|
|
|
|
|
|
|
|
getRepoCommitR :: KeyHashid Repo -> Text -> Handler TypedContent
|
|
|
|
getRepoCommitR repoHash ref = do
|
|
|
|
repoID <- decodeKeyHashid404 repoHash
|
|
|
|
repo <- runDB $ get404 repoID
|
|
|
|
case repoVcs repo of
|
|
|
|
VCSDarcs -> getDarcsPatch repoHash ref
|
|
|
|
VCSGit -> getGitPatch repoHash ref
|
|
|
|
|
|
|
|
getRepoNewR :: Handler Html
|
|
|
|
getRepoNewR = do
|
2022-09-16 10:34:44 +00:00
|
|
|
((_result, widget), enctype) <- runFormPost newRepoForm
|
|
|
|
defaultLayout $(widgetFile "repo/new")
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
|
|
|
|
postRepoNewR :: Handler Html
|
|
|
|
postRepoNewR = do
|
2022-09-16 10:34:44 +00:00
|
|
|
(NewRepo name desc vcs, _widget, _enctype) <-
|
|
|
|
runFormPostRedirect RepoNewR newRepoForm
|
|
|
|
|
|
|
|
personEntity@(Entity personID person) <- requireAuth
|
|
|
|
personHash <- encodeKeyHashid personID
|
|
|
|
(maybeSummary, audience, detail) <- C.createRepo personHash name desc
|
|
|
|
actor <- runDB $ getJust $ personActor person
|
|
|
|
result <-
|
|
|
|
runExceptT $ createRepositoryC personEntity actor maybeSummary audience detail vcs Nothing Nothing
|
|
|
|
|
2016-02-27 05:41:36 +00:00
|
|
|
case result of
|
2022-09-16 10:34:44 +00:00
|
|
|
Left e -> do
|
|
|
|
setMessage $ toHtml e
|
|
|
|
redirect RepoNewR
|
|
|
|
Right createID -> do
|
|
|
|
maybeRepoID <- runDB $ getKeyBy $ UniqueRepoCreate createID
|
|
|
|
case maybeRepoID of
|
|
|
|
Nothing -> error "Can't find the newly created repo"
|
|
|
|
Just repoID -> do
|
|
|
|
repoHash <- encodeKeyHashid repoID
|
|
|
|
setMessage "New repository created"
|
|
|
|
redirect $ RepoR repoHash
|
2016-02-27 05:41:36 +00:00
|
|
|
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
postRepoDeleteR :: KeyHashid Repo -> Handler Html
|
|
|
|
postRepoDeleteR repoHash = do
|
|
|
|
error "Temporarily disabled"
|
|
|
|
{-
|
|
|
|
runDB $ do
|
|
|
|
Entity sid _s <- getBy404 $ UniqueSharer shar
|
|
|
|
Entity rid _r <- getBy404 $ UniqueRepo repo sid
|
|
|
|
delete rid
|
|
|
|
path <- askRepoDir shar repo
|
|
|
|
exists <- liftIO $ doesDirectoryExist path
|
|
|
|
if exists
|
|
|
|
then liftIO $ removeDirectoryRecursive path
|
|
|
|
else
|
|
|
|
$logWarn $ sformat
|
|
|
|
( "Deleted repo " % F.sharer % "/" % F.repo
|
|
|
|
% " from DB but repo dir doesn't exist"
|
|
|
|
)
|
|
|
|
shar repo
|
|
|
|
setMessage "Repo deleted."
|
|
|
|
redirect HomeR
|
|
|
|
-}
|
2016-05-05 16:30:30 +00:00
|
|
|
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
getRepoEditR :: KeyHashid Repo -> Handler Html
|
|
|
|
getRepoEditR repoHash = do
|
|
|
|
error "Temporarily disabled"
|
|
|
|
{-
|
|
|
|
(sid, er) <- runDB $ do
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
er <- getBy404 $ UniqueRepo rp sid
|
|
|
|
return (sid, er)
|
|
|
|
((_result, widget), enctype) <- runFormPost $ editRepoForm sid er
|
|
|
|
defaultLayout $(widgetFile "repo/edit")
|
|
|
|
-}
|
2016-05-05 07:29:19 +00:00
|
|
|
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
postRepoEditR :: KeyHashid Repo -> Handler Html
|
|
|
|
postRepoEditR repoHash = do
|
|
|
|
error "Temporarily disabled"
|
|
|
|
{-
|
2016-06-05 21:11:05 +00:00
|
|
|
mer <- runDB $ do
|
|
|
|
Entity sid _ <- getBy404 $ UniqueSharer shr
|
|
|
|
er@(Entity rid r) <- getBy404 $ UniqueRepo rp sid
|
|
|
|
mwiki <- for (repoProject r) $ \ jid -> do
|
|
|
|
project <- getJust jid
|
|
|
|
return $ (== rid) <$> projectWiki project
|
|
|
|
return $ case mwiki of
|
|
|
|
Just (Just True) -> Nothing
|
2019-01-29 22:24:32 +00:00
|
|
|
_ -> Just (sid, er)
|
2016-06-05 21:11:05 +00:00
|
|
|
case mer of
|
|
|
|
Nothing -> do
|
|
|
|
setMessage "Repo used as a wiki, can't move between projects."
|
|
|
|
redirect $ RepoR shr rp
|
2019-01-29 22:24:32 +00:00
|
|
|
Just (sid, er@(Entity rid _)) -> do
|
|
|
|
((result, widget), enctype) <- runFormPost $ editRepoForm sid er
|
2016-06-05 21:11:05 +00:00
|
|
|
case result of
|
|
|
|
FormSuccess repository' -> do
|
|
|
|
runDB $ replace rid repository'
|
|
|
|
setMessage "Repository updated."
|
|
|
|
redirect $ RepoR shr rp
|
|
|
|
FormMissing -> do
|
|
|
|
setMessage "Field(s) missing."
|
|
|
|
defaultLayout $(widgetFile "repo/edit")
|
|
|
|
FormFailure _l -> do
|
|
|
|
setMessage "Repository update failed, see errors below."
|
|
|
|
defaultLayout $(widgetFile "repo/edit")
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
postRepoFollowR :: KeyHashid Repo -> Handler ()
|
|
|
|
postRepoFollowR _ = error "Temporarily disabled"
|
|
|
|
|
|
|
|
postRepoUnfollowR :: KeyHashid Repo -> Handler ()
|
|
|
|
postRepoUnfollowR _ = error "Temporarily disabled"
|
|
|
|
|
|
|
|
postPostReceiveR :: Handler Text
|
|
|
|
postPostReceiveR = do
|
|
|
|
error "Temporarily disabled"
|
|
|
|
{-
|
|
|
|
push <- requireCheckJsonBody
|
|
|
|
(pushAP, shr, rp) <- push2ap push
|
|
|
|
user <- runDB $ do
|
|
|
|
p <- getJustEntity $ toSqlKey $ H.pushUser push
|
|
|
|
s <- getJust $ personIdent $ entityVal p
|
|
|
|
return (p, s)
|
|
|
|
let shrUser = sharerIdent $ snd user
|
|
|
|
summary <- do
|
|
|
|
let mbranch = H.pushBranch push
|
|
|
|
total = pushCommitsTotal pushAP
|
|
|
|
lasts = pushCommitsLast pushAP
|
|
|
|
rest firsts = total - length firsts - length lasts
|
|
|
|
hashText (Hash b) = decodeUtf8 b
|
|
|
|
commitW c =
|
|
|
|
[hamlet|
|
|
|
|
<a href=@{RepoCommitR shr rp $ hashText $ commitHash c}>
|
|
|
|
#{commitTitle c}
|
|
|
|
|]
|
|
|
|
withUrlRenderer
|
|
|
|
[hamlet|
|
|
|
|
<p>
|
|
|
|
<a href=@{SharerR shrUser}>#{shr2text shrUser}
|
|
|
|
\ pushed #{total} #
|
|
|
|
\ #{commitsText mbranch total} to repo #
|
|
|
|
<a href=@{RepoR shr rp}>#{rp2text rp}</a>^{branchText shr rp mbranch}:
|
|
|
|
<ul>
|
|
|
|
$maybe firsts <- pushCommitsFirst pushAP
|
|
|
|
$forall c <- firsts
|
|
|
|
<li>^{commitW c}
|
|
|
|
<li>#{rest firsts}
|
|
|
|
$forall c <- lasts
|
|
|
|
<li>^{commitW c}
|
|
|
|
|]
|
|
|
|
eid <- runExceptT $ pushCommitsC user summary pushAP shr rp
|
|
|
|
case eid of
|
|
|
|
Left e -> liftIO $ throwIO $ userError $ T.unpack e
|
|
|
|
Right obiid -> do
|
|
|
|
renderUrl <- askUrlRender
|
|
|
|
obikhid <- encodeKeyHashid obiid
|
|
|
|
return $
|
|
|
|
"Push activity published: " <>
|
|
|
|
renderUrl (SharerOutboxItemR shrUser obikhid)
|
|
|
|
where
|
|
|
|
push2ap (H.Push secret _ sharer repo mbranch mbefore after early mlate) = do
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
let shr = text2shr sharer
|
|
|
|
rp = text2rp repo
|
|
|
|
commit2ap' = commit2ap shr rp
|
|
|
|
(commitsLast, commitsFirst) <-
|
|
|
|
runDB $ case mlate of
|
|
|
|
Nothing -> (,) <$> traverse commit2ap' early <*> pure Nothing
|
|
|
|
Just (_omitted, late) ->
|
|
|
|
(,) <$> traverse commit2ap' late
|
|
|
|
<*> (Just <$> traverse commit2ap' early)
|
|
|
|
return
|
|
|
|
( Push
|
|
|
|
{ pushCommitsLast = commitsLast
|
|
|
|
, pushCommitsFirst = commitsFirst
|
|
|
|
, pushCommitsTotal =
|
|
|
|
case mlate of
|
|
|
|
Nothing -> length early
|
|
|
|
Just (omitted, late) ->
|
|
|
|
length early + omitted + length late
|
|
|
|
, pushTarget =
|
|
|
|
encodeRouteLocal $
|
|
|
|
case mbranch of
|
|
|
|
Nothing -> RepoR shr rp
|
|
|
|
Just b -> RepoBranchR shr rp b
|
|
|
|
, pushContext = encodeRouteLocal $ RepoR shr rp
|
|
|
|
, pushHashBefore = mbefore
|
|
|
|
, pushHashAfter = after
|
|
|
|
}
|
|
|
|
, shr
|
|
|
|
, rp
|
|
|
|
)
|
|
|
|
where
|
|
|
|
commit2ap shr rp (H.Commit (wauthor, wtime) mcommitted hash title desc) = do
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
|
|
|
author <- authorByEmail wauthor
|
|
|
|
mcommitter <- traverse (authorByEmail . fst) mcommitted
|
|
|
|
return Commit
|
|
|
|
{ commitId = encodeRouteLocal $ RepoCommitR shr rp hash
|
|
|
|
, commitRepository = encodeRouteLocal $ RepoR shr rp
|
|
|
|
, commitAuthor = second (encodeRouteHome . SharerR) author
|
|
|
|
, commitCommitter =
|
|
|
|
second (encodeRouteHome . SharerR) <$> mcommitter
|
|
|
|
, commitTitle = title
|
|
|
|
, commitHash = Hash $ encodeUtf8 hash
|
|
|
|
, commitDescription =
|
|
|
|
if T.null desc
|
|
|
|
then Nothing
|
|
|
|
else Just desc
|
|
|
|
, commitWritten = wtime
|
|
|
|
, commitCommitted = snd <$> mcommitted
|
|
|
|
}
|
|
|
|
where
|
|
|
|
authorByEmail (H.Author name email) = do
|
|
|
|
mperson <- getValBy $ UniquePersonEmail email
|
|
|
|
case mperson of
|
|
|
|
Nothing -> return $ Left $ Author name email
|
|
|
|
Just person ->
|
|
|
|
Right . sharerIdent <$> getJust (personIdent person)
|
|
|
|
commitsText :: Maybe a -> Int -> Text
|
|
|
|
commitsText Nothing n =
|
|
|
|
if n > 1
|
|
|
|
then "patches"
|
|
|
|
else "patch"
|
|
|
|
commitsText (Just _) n =
|
|
|
|
if n > 1
|
|
|
|
then "commits"
|
|
|
|
else "commit"
|
|
|
|
--branchText :: ShrIdent -> RpIdent -> Maybe Text -> HtmlUrl (Route App)
|
|
|
|
branchText _ _ Nothing = const mempty
|
|
|
|
branchText shr rp (Just branch) =
|
|
|
|
[hamlet|
|
|
|
|
, branch #
|
|
|
|
<a href=@{RepoBranchR shr rp branch}>#{branch}
|
|
|
|
|]
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-05 21:11:05 +00:00
|
|
|
|
2016-05-13 19:23:56 +00:00
|
|
|
|
|
|
|
|
2016-06-05 21:11:05 +00:00
|
|
|
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{-
|
|
|
|
getReposR :: ShrIdent -> Handler Html
|
|
|
|
getReposR user = do
|
|
|
|
repos <- runDB $ E.select $ E.from $ \ (sharer, repo) -> do
|
|
|
|
E.where_ $
|
|
|
|
sharer E.^. SharerIdent E.==. E.val user E.&&.
|
|
|
|
sharer E.^. SharerId E.==. repo E.^. RepoSharer
|
|
|
|
E.orderBy [E.asc $ repo E.^. RepoIdent]
|
|
|
|
return $ repo E.^. RepoIdent
|
|
|
|
defaultLayout $(widgetFile "repo/list")
|
|
|
|
|
|
|
|
selectRepo :: ShrIdent -> RpIdent -> AppDB (Maybe (Sharer, Project, Workflow, Sharer), Repo)
|
|
|
|
selectRepo shar repo = do
|
|
|
|
Entity sid _s <- getBy404 $ UniqueSharer shar
|
|
|
|
Entity _rid r <- getBy404 $ UniqueRepo repo sid
|
|
|
|
mj <- for (repoProject r) $ \ jid -> do
|
|
|
|
j <- get404 jid
|
|
|
|
s <- get404 $ projectSharer j
|
|
|
|
w <- get404 $ projectWorkflow j
|
|
|
|
sw <- get404 $ workflowSharer w
|
|
|
|
return (s, j, w, sw)
|
|
|
|
return (mj, r)
|
2016-05-05 16:30:30 +00:00
|
|
|
|
2019-08-28 15:31:40 +00:00
|
|
|
getRepoBranchR :: ShrIdent -> RpIdent -> Text -> Handler TypedContent
|
|
|
|
getRepoBranchR shar repo ref = do
|
2019-12-27 20:44:14 +00:00
|
|
|
(_, repository) <- runDB $ selectRepo shar repo
|
2019-08-28 15:31:40 +00:00
|
|
|
case repoVcs repository of
|
|
|
|
VCSDarcs -> notFound
|
|
|
|
VCSGit -> getGitRepoBranch shar repo ref
|
|
|
|
|
2016-05-29 14:13:25 +00:00
|
|
|
getRepoDevsR :: ShrIdent -> RpIdent -> Handler Html
|
2016-05-31 01:52:04 +00:00
|
|
|
getRepoDevsR shr rp = do
|
|
|
|
devs <- runDB $ do
|
|
|
|
rid <- do
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
Entity r _ <- getBy404 $ UniqueRepo rp s
|
|
|
|
return r
|
2022-06-22 06:19:37 +00:00
|
|
|
E.select $ E.from $ \ (topic `E.InnerJoin` recip `E.InnerJoin` person `E.InnerJoin` sharer `E.LeftOuterJoin` (crole `E.InnerJoin` role)) -> do
|
|
|
|
E.on $ crole E.?. CollabRoleLocalRole E.==. role E.?. RoleId
|
|
|
|
E.on $ E.just (recip E.^. CollabRecipLocalCollab) E.==. crole E.?. CollabRoleLocalCollab
|
|
|
|
E.on $ person E.^. PersonIdent E.==. sharer E.^. SharerId
|
|
|
|
E.on $ recip E.^. CollabRecipLocalPerson E.==. person E.^. PersonId
|
|
|
|
E.on $ topic E.^. CollabTopicLocalRepoCollab E.==. recip E.^. CollabRecipLocalCollab
|
|
|
|
E.where_ $ topic E.^. CollabTopicLocalRepoRepo E.==. E.val rid
|
2019-09-09 00:27:45 +00:00
|
|
|
return (sharer, role E.?. RoleIdent)
|
2016-05-31 01:52:04 +00:00
|
|
|
defaultLayout $(widgetFile "repo/collab/list")
|
2016-05-29 14:13:25 +00:00
|
|
|
|
|
|
|
postRepoDevsR :: ShrIdent -> RpIdent -> Handler Html
|
2016-05-31 01:52:04 +00:00
|
|
|
postRepoDevsR shr rp = do
|
2022-06-22 06:19:37 +00:00
|
|
|
(sid, mjid, obid, rid) <- runDB $ do
|
2016-05-31 01:52:04 +00:00
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
2016-06-05 13:59:48 +00:00
|
|
|
Entity r repository <- getBy404 $ UniqueRepo rp s
|
2022-06-22 06:19:37 +00:00
|
|
|
return (s, repoProject repository, repoOutbox repository, r)
|
2016-06-06 17:29:54 +00:00
|
|
|
((result, widget), enctype) <- runFormPost $ newRepoCollabForm sid mjid rid
|
2016-05-31 01:52:04 +00:00
|
|
|
case result of
|
|
|
|
FormSuccess nc -> do
|
2022-06-22 06:19:37 +00:00
|
|
|
now <- liftIO getCurrentTime
|
|
|
|
host <- asksSite siteInstanceHost
|
2016-05-31 01:52:04 +00:00
|
|
|
runDB $ do
|
2022-06-22 06:19:37 +00:00
|
|
|
obiid <-
|
|
|
|
insert $
|
|
|
|
OutboxItem
|
|
|
|
obid
|
|
|
|
(persistJSONObjectFromDoc $ Doc host emptyActivity)
|
|
|
|
now
|
|
|
|
cid <- insert Collab
|
|
|
|
for_ (ncRole nc) $ \ rlid -> insert_ $ CollabRoleLocal cid rlid
|
|
|
|
insert_ $ CollabTopicLocalRepo cid rid
|
|
|
|
insert_ $ CollabSenderLocal cid obiid
|
|
|
|
insert_ $ CollabRecipLocal cid (ncPerson nc)
|
2016-05-31 01:52:04 +00:00
|
|
|
setMessage "Collaborator added."
|
|
|
|
redirect $ RepoDevsR shr rp
|
|
|
|
FormMissing -> do
|
|
|
|
setMessage "Field(s) missing"
|
|
|
|
defaultLayout $(widgetFile "repo/collab/new")
|
|
|
|
FormFailure _l -> do
|
|
|
|
setMessage "Operation failed, see errors below"
|
|
|
|
defaultLayout $(widgetFile "repo/collab/new")
|
2016-05-29 14:13:25 +00:00
|
|
|
|
|
|
|
getRepoDevNewR :: ShrIdent -> RpIdent -> Handler Html
|
2016-05-31 01:52:04 +00:00
|
|
|
getRepoDevNewR shr rp = do
|
2016-06-06 17:29:54 +00:00
|
|
|
(sid, mjid, rid) <- runDB $ do
|
2016-05-31 01:52:04 +00:00
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
2016-06-05 13:59:48 +00:00
|
|
|
Entity r repository <- getBy404 $ UniqueRepo rp s
|
2016-06-06 17:29:54 +00:00
|
|
|
return (s, repoProject repository, r)
|
2016-06-05 13:59:48 +00:00
|
|
|
((_result, widget), enctype) <-
|
2016-06-06 17:29:54 +00:00
|
|
|
runFormPost $ newRepoCollabForm sid mjid rid
|
2016-05-31 01:52:04 +00:00
|
|
|
defaultLayout $(widgetFile "repo/collab/new")
|
2016-05-29 14:13:25 +00:00
|
|
|
|
|
|
|
getRepoDevR :: ShrIdent -> RpIdent -> ShrIdent -> Handler Html
|
2016-05-31 01:52:04 +00:00
|
|
|
getRepoDevR shr rp dev = do
|
2019-01-29 22:24:32 +00:00
|
|
|
mrl <- runDB $ do
|
2016-05-31 01:52:04 +00:00
|
|
|
rid <- do
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
Entity r _ <- getBy404 $ UniqueRepo rp s
|
|
|
|
return r
|
|
|
|
pid <- do
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer dev
|
|
|
|
Entity p _ <- getBy404 $ UniquePersonIdent s
|
|
|
|
return p
|
2022-06-22 06:19:37 +00:00
|
|
|
l <- E.select $ E.from $ \ (topic `E.InnerJoin` recip) -> do
|
|
|
|
E.on $ topic E.^. CollabTopicLocalRepoCollab E.==. recip E.^. CollabRecipLocalCollab
|
|
|
|
E.where_ $
|
|
|
|
topic E.^. CollabTopicLocalRepoRepo E.==. E.val rid E.&&.
|
|
|
|
recip E.^. CollabRecipLocalPerson E.==. E.val pid
|
|
|
|
return $ recip E.^. CollabRecipLocalCollab
|
|
|
|
cid <-
|
|
|
|
case l of
|
|
|
|
[] -> notFound
|
|
|
|
[E.Value cid] -> return cid
|
|
|
|
_ -> error "Multiple collabs for repo+person"
|
|
|
|
mcrole <- getValBy $ UniqueCollabRoleLocal cid
|
|
|
|
for mcrole $
|
|
|
|
\ (CollabRoleLocal _cid rlid) -> roleIdent <$> getJust rlid
|
2016-05-31 01:52:04 +00:00
|
|
|
defaultLayout $(widgetFile "repo/collab/one")
|
2016-05-29 14:13:25 +00:00
|
|
|
|
|
|
|
deleteRepoDevR :: ShrIdent -> RpIdent -> ShrIdent -> Handler Html
|
2016-05-30 14:32:20 +00:00
|
|
|
deleteRepoDevR shr rp dev = do
|
|
|
|
runDB $ do
|
|
|
|
rid <- do
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
|
|
|
Entity r _ <- getBy404 $ UniqueRepo rp s
|
|
|
|
return r
|
|
|
|
pid <- do
|
|
|
|
Entity s _ <- getBy404 $ UniqueSharer dev
|
|
|
|
Entity p _ <- getBy404 $ UniquePersonIdent s
|
|
|
|
return p
|
2022-06-22 06:19:37 +00:00
|
|
|
collabs <- E.select $ E.from $ \ (recip `E.InnerJoin` topic) -> do
|
|
|
|
E.on $ recip E.^. CollabRecipLocalCollab E.==. topic E.^. CollabTopicLocalRepoCollab
|
|
|
|
E.where_ $
|
|
|
|
recip E.^. CollabRecipLocalPerson E.==. E.val pid E.&&.
|
|
|
|
topic E.^. CollabTopicLocalRepoRepo E.==. E.val rid
|
|
|
|
return
|
|
|
|
( recip E.^. CollabRecipLocalId
|
|
|
|
, topic E.^. CollabTopicLocalRepoId
|
|
|
|
, recip E.^. CollabRecipLocalCollab
|
|
|
|
)
|
|
|
|
(E.Value crid, E.Value ctid, E.Value cid) <-
|
|
|
|
case collabs of
|
|
|
|
[] -> notFound
|
|
|
|
[c] -> return c
|
|
|
|
_ -> error "More than 1 collab for repo+person"
|
|
|
|
deleteWhere [CollabRoleLocalCollab ==. cid]
|
|
|
|
delete ctid
|
|
|
|
deleteWhere [CollabSenderLocalCollab ==. cid]
|
|
|
|
deleteWhere [CollabSenderRemoteCollab ==. cid]
|
|
|
|
delete crid
|
2016-05-30 14:32:20 +00:00
|
|
|
delete cid
|
|
|
|
setMessage "Collaborator removed."
|
|
|
|
redirect $ RepoDevsR shr rp
|
2016-05-29 14:13:25 +00:00
|
|
|
|
|
|
|
postRepoDevR :: ShrIdent -> RpIdent -> ShrIdent -> Handler Html
|
2016-05-30 14:32:20 +00:00
|
|
|
postRepoDevR shr rp dev = do
|
|
|
|
mmethod <- lookupPostParam "_method"
|
|
|
|
case mmethod of
|
|
|
|
Just "DELETE" -> deleteRepoDevR shr rp dev
|
|
|
|
_ -> notFound
|
2019-05-27 13:28:57 +00:00
|
|
|
|
2019-09-09 00:27:45 +00:00
|
|
|
getRepoTeamR :: ShrIdent -> RpIdent -> Handler TypedContent
|
|
|
|
getRepoTeamR shr rp = do
|
|
|
|
memberShrs <- runDB $ do
|
|
|
|
sid <- getKeyBy404 $ UniqueSharer shr
|
|
|
|
_rid <- getKeyBy404 $ UniqueRepo rp sid
|
|
|
|
id_ <-
|
|
|
|
requireEitherAlt
|
|
|
|
(getKeyBy $ UniquePersonIdent sid)
|
|
|
|
(getKeyBy $ UniqueGroup sid)
|
|
|
|
"Found sharer that is neither person nor group"
|
|
|
|
"Found sharer that is both person and group"
|
|
|
|
case id_ of
|
|
|
|
Left pid -> return [shr]
|
|
|
|
Right gid -> do
|
|
|
|
pids <-
|
|
|
|
map (groupMemberPerson . entityVal) <$>
|
|
|
|
selectList [GroupMemberGroup ==. gid] []
|
|
|
|
sids <-
|
|
|
|
map (personIdent . entityVal) <$>
|
|
|
|
selectList [PersonId <-. pids] []
|
|
|
|
map (sharerIdent . entityVal) <$>
|
|
|
|
selectList [SharerId <-. sids] []
|
|
|
|
|
|
|
|
let here = RepoTeamR shr rp
|
|
|
|
|
|
|
|
encodeRouteLocal <- getEncodeRouteLocal
|
|
|
|
encodeRouteHome <- getEncodeRouteHome
|
|
|
|
let team = Collection
|
|
|
|
{ collectionId = encodeRouteLocal here
|
|
|
|
, collectionType = CollectionTypeUnordered
|
|
|
|
, collectionTotalItems = Just $ length memberShrs
|
|
|
|
, collectionCurrent = Nothing
|
|
|
|
, collectionFirst = Nothing
|
|
|
|
, collectionLast = Nothing
|
|
|
|
, collectionItems = map (encodeRouteHome . SharerR) memberShrs
|
|
|
|
}
|
|
|
|
provideHtmlAndAP team $ redirectToPrettyJSON here
|
|
|
|
|
|
|
|
getRepoFollowersR :: ShrIdent -> RpIdent -> Handler TypedContent
|
|
|
|
getRepoFollowersR shr rp = getFollowersCollection here getFsid
|
|
|
|
where
|
|
|
|
here = RepoFollowersR shr rp
|
|
|
|
getFsid = do
|
|
|
|
sid <- getKeyBy404 $ UniqueSharer shr
|
|
|
|
r <- getValBy404 $ UniqueRepo rp sid
|
|
|
|
return $ repoFollowers r
|
|
|
|
|
2019-05-27 19:54:11 +00:00
|
|
|
getHighlightStyleR :: Text -> Handler TypedContent
|
|
|
|
getHighlightStyleR styleName =
|
|
|
|
case lookup (unpack styleName) highlightingStyles of
|
2019-05-27 18:30:48 +00:00
|
|
|
Nothing -> notFound
|
|
|
|
Just style ->
|
|
|
|
return $ TypedContent typeCss $ toContent $ styleToCss style
|
Switch to new actor layout
This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:
- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
I haven't tested them yet on a read DB so there may be errors there; I'll fix
them in the next patches if I find any (probably going to test on the main
instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
removed, I haven't removed them; that's because I wonder if at some point
users can have a tree of inboxes much like in email; I don't have an excuse
for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
they already look like user@host/repo regardless of who "controls" that repo
2022-08-15 13:57:42 +00:00
|
|
|
-}
|