Skip to main content

torii_lib/platforms/sourcehut/
pr.rs

1//! Sourcehut — pr client.
2
3use crate::error::{Result, ToriiError};
4use crate::platforms::pr::*;
5
6pub struct SourcehutPrClient;
7
8impl SourcehutPrClient {
9    pub fn new() -> Result<Self> {
10        Ok(Self)
11    }
12}
13
14fn srht_pr_unsupported() -> ToriiError {
15    ToriiError::Unsupported(
16        "Sourcehut doesn't have server-side pull requests — \
17         contributions are sent as `git format-patch` style emails to \
18         the project's `*-devel@lists.sr.ht` mailing list. Use \
19         `torii patch export <range>` to produce the .patch files and \
20         mail them with `git send-email` (or your MUA). The maintainer \
21         applies them with `torii patch apply`."
22            .to_string(),
23    )
24}
25
26impl PrClient for SourcehutPrClient {
27    fn create(&self, _o: &str, _r: &str, _opts: CreatePrOptions) -> Result<PullRequest> {
28        Err(srht_pr_unsupported())
29    }
30    fn list(&self, _o: &str, _r: &str, _state: &str) -> Result<Vec<PullRequest>> {
31        Err(srht_pr_unsupported())
32    }
33    fn get(&self, _o: &str, _r: &str, _n: u64) -> Result<PullRequest> {
34        Err(srht_pr_unsupported())
35    }
36    fn merge(&self, _o: &str, _r: &str, _n: u64, _m: MergeMethod) -> Result<()> {
37        Err(srht_pr_unsupported())
38    }
39    fn close(&self, _o: &str, _r: &str, _n: u64) -> Result<()> {
40        Err(srht_pr_unsupported())
41    }
42    fn update(&self, _o: &str, _r: &str, _n: u64, _opts: UpdatePrOptions) -> Result<()> {
43        Err(srht_pr_unsupported())
44    }
45    fn delete_branch(&self, _o: &str, _r: &str, _b: &str) -> Result<()> {
46        Err(srht_pr_unsupported())
47    }
48    fn checkout_branch(&self, pr: &PullRequest) -> String {
49        pr.head.clone()
50    }
51}
52
53// ============================================================================
54// Radicle (peer-to-peer, via `rad patch` CLI)
55// ============================================================================
56//
57// Radicle calls "pull requests" *patches*. They're stored as refs
58// inside the project's collaborative space (`refs/cobs/xyz.radicle.patch`)
59// and synchronised peer-to-peer. There is no HTTP API; everything goes
60// through the local `rad` binary.