Skip to content

Commit e89f1da

Browse files
committed
Central github structs
1 parent 94a0707 commit e89f1da

File tree

15 files changed

+35
-703
lines changed

15 files changed

+35
-703
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rfd-api/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ pub struct GitHubConfig {
156156
pub owner: String,
157157
pub path: String,
158158
pub repo: String,
159+
pub default_branch: String,
159160
}
160161

161162
#[derive(Debug, Deserialize)]

rfd-api/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ impl ApiContext {
336336
services.github.owner,
337337
services.github.repo,
338338
services.github.path,
339+
services.github.default_branch,
339340
)
340341
.await?,
341342
})
@@ -2083,6 +2084,7 @@ pub(crate) mod test_mocks {
20832084
owner: String::new(),
20842085
repo: String::new(),
20852086
path: String::new(),
2087+
default_branch: String::new(),
20862088
auth: GitHubAuthConfig::User {
20872089
token: String::default(),
20882090
},

rfd-github/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
use std::{
6-
borrow::Cow,
7-
collections::HashMap,
8-
fmt::Debug,
9-
future::Future,
10-
pin::Pin,
11-
str::{from_utf8, Utf8Error},
6+
borrow::Cow, collections::HashMap, fmt::Debug, future::Future, pin::Pin, str::{from_utf8, Utf8Error}
127
};
138

149
use base64::{prelude::BASE64_STANDARD, DecodeError, Engine};
@@ -75,10 +70,11 @@ impl GitHubRfdRepo {
7570
owner: String,
7671
repo: String,
7772
path: String,
73+
default_branch: String
7874
) -> Result<Self, GitHubError> {
7975
Ok(Self {
8076
client: client.clone(),
81-
default_branch: client.repos().get(&owner, &repo).await?.body.default_branch,
77+
default_branch,
8278
owner,
8379
repo,
8480
path,

rfd-processor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ reqwest-middleware = { workspace = true }
2828
reqwest-retry = { workspace = true }
2929
reqwest-tracing = { workspace = true }
3030
rfd-data = { path = "../rfd-data" }
31+
rfd-github = { path = "../rfd-github" }
3132
rfd-model = { path = "../rfd-model" }
3233
rsa = { workspace = true }
3334
serde = { workspace = true }

rfd-processor/src/content/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{borrow::Cow, env, io, path::PathBuf, str::Utf8Error, string::FromUtf8E
77
use async_trait::async_trait;
88
use base64::DecodeError;
99
use octorust::Client;
10+
use rfd_github::{GitHubError, GitHubRfdLocation};
1011
use rfd_data::{
1112
content::{RfdAsciidoc, RfdContent, RfdDocument, RfdMarkdown},
1213
RfdNumber,
@@ -19,7 +20,6 @@ use tracing::instrument;
1920
use uuid::Uuid;
2021

2122
use crate::{
22-
github::{GitHubError, GitHubRfdLocation},
2323
pdf::RfdPdf,
2424
util::{decode_base64, write_file, FileIoError},
2525
};

rfd-processor/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use octorust::{
1616
Client as GitHubClient, ClientError,
1717
};
1818
use reqwest::Error as ReqwestError;
19+
use rfd_github::{GitHubError, GitHubRfdRepo};
1920
use rfd_model::{schema_ext::PdfSource, storage::postgres::PostgresStore};
2021
use rsa::{
2122
pkcs1::{DecodeRsaPrivateKey, EncodeRsaPrivateKey},
@@ -26,7 +27,6 @@ use thiserror::Error;
2627
use tracing::instrument;
2728

2829
use crate::{
29-
github::{GitHubError, GitHubRfdRepo},
3030
pdf::{PdfFileLocation, PdfStorage, RfdPdf, RfdPdfError},
3131
search::RfdSearchIndex,
3232
updater::{BoxedAction, RfdUpdateMode, RfdUpdaterError},
@@ -130,6 +130,7 @@ impl Context {
130130
config.source.owner.clone(),
131131
config.source.repo.clone(),
132132
config.source.path.clone(),
133+
config.source.default_branch.clone(),
133134
)
134135
.await?;
135136

rfd-processor/src/github/ext.rs

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)