Skip to content

Commit 51aaae3

Browse files
committed
fix!: remove lore from being a public module
`lore` was originally intended to serve as a library. However, in kworkflow#128, it was decided to package it as a separate project instead of sideloading alongside the `patch-hub` crate. Additionally, `Patch::new` was detected as unused code and was removed. Signed-off-by: Ivin Joel Abraham <[email protected]>
1 parent 42f88c9 commit 51aaae3

File tree

13 files changed

+101
-81
lines changed

13 files changed

+101
-81
lines changed

src/app.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
use crate::infrastructure::logging::Logger;
2+
use crate::lore::{
3+
lore_api_client::BlockingLoreAPIClient,
4+
lore_session,
5+
patch::{Author, Patch},
6+
};
27
use crate::{
38
infrastructure::logging,
49
log_on_error,
@@ -8,11 +13,6 @@ use ansi_to_tui::IntoText;
813
use color_eyre::eyre::bail;
914
use config::Config;
1015
use cover_renderer::render_cover;
11-
use patch_hub::lore::{
12-
lore_api_client::BlockingLoreAPIClient,
13-
lore_session,
14-
patch::{Author, Patch},
15-
};
1616
use patch_renderer::{render_patch_preview, PatchRenderer};
1717
use ratatui::text::Text;
1818
use screens::{

src/app/screens/bookmarked.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use patch_hub::lore::patch::Patch;
1+
use crate::lore::patch::Patch;
22

33
pub struct BookmarkedPatchsets {
44
pub bookmarked_patchsets: Vec<Patch>,

src/app/screens/details_actions.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
use crate::app::config::{Config, KernelTree};
2-
3-
use super::CurrentScreen;
4-
use ::patch_hub::lore::{lore_api_client::BlockingLoreAPIClient, lore_session, patch::Patch};
51
use color_eyre::eyre::{bail, eyre};
6-
use patch_hub::lore::patch::Author;
72
use ratatui::text::Text;
3+
84
use std::{
95
collections::{HashMap, HashSet},
106
path::Path,
117
process::Command,
128
};
139

10+
use crate::{
11+
app::config::{Config, KernelTree},
12+
lore::{
13+
lore_api_client::BlockingLoreAPIClient,
14+
lore_session,
15+
patch::{Author, Patch},
16+
},
17+
};
18+
19+
use super::CurrentScreen;
20+
1421
pub struct DetailsActions {
1522
pub representative_patch: Patch,
1623
/// Raw patches as plain text files

src/app/screens/latest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use color_eyre::eyre::bail;
22
use derive_getters::Getters;
3-
use patch_hub::lore::{
3+
4+
use crate::lore::{
45
lore_api_client::{BlockingLoreAPIClient, ClientError},
56
lore_session::{LoreSession, LoreSessionError},
67
patch::Patch,

src/app/screens/mail_list.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use color_eyre::eyre::bail;
2-
use patch_hub::lore::{
2+
3+
use crate::lore::{
34
lore_api_client::BlockingLoreAPIClient, lore_session, mailing_list::MailingList,
45
};
56

src/lib.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/lore/lore_session.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
use crate::lore::lore_api_client::{
2-
AvailableListsRequest, ClientError, PatchFeedRequest, PatchHTMLRequest,
3-
};
4-
use crate::lore::mailing_list::MailingList;
5-
use crate::lore::patch::{Patch, PatchFeed, PatchRegex};
61
use derive_getters::Getters;
72
use regex::Regex;
83
use serde_xml_rs::from_str;
9-
use std::collections::{HashMap, HashSet};
10-
use std::io::{BufRead, BufReader};
11-
use std::mem::swap;
12-
use std::path::Path;
13-
use std::process::{Command, Stdio};
14-
use std::sync::LazyLock;
4+
use thiserror::Error;
5+
156
use std::{
7+
collections::{HashMap, HashSet},
168
fs::{self, File},
17-
io,
9+
io::{self, BufRead, BufReader},
10+
mem::swap,
11+
path::Path,
12+
process::{Command, Stdio},
13+
sync::LazyLock,
14+
};
15+
16+
use crate::lore::{
17+
lore_api_client::{AvailableListsRequest, ClientError, PatchFeedRequest, PatchHTMLRequest},
18+
mailing_list::MailingList,
19+
patch::{Patch, PatchFeed, PatchRegex},
1820
};
19-
use thiserror::Error;
2021

2122
#[cfg(test)]
2223
mod tests;
File renamed without changes.

src/lore/patch.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,6 @@ fn default_total_in_series() -> usize {
6262
}
6363

6464
impl Patch {
65-
pub fn new(
66-
title: String,
67-
author: Author,
68-
message_id: MessageID,
69-
in_reply_to: Option<MessageID>,
70-
updated: String,
71-
) -> Patch {
72-
Patch {
73-
title,
74-
author,
75-
version: 1,
76-
number_in_series: 1,
77-
total_in_series: 1,
78-
message_id,
79-
in_reply_to,
80-
updated,
81-
}
82-
}
83-
8465
pub fn version(&self) -> usize {
8566
self.version
8667
}

src/lore/patch/tests.rs

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@ use serde_xml_rs::from_str;
33

44
#[test]
55
fn can_deserialize_patch_without_in_reply_to() {
6-
let expected_patch: Patch = Patch::new(
7-
"[PATCH 0/42] hitchhiker/guide: Complete Collection".to_string(),
8-
Author {
6+
let expected_patch: Patch = {
7+
let title = "[PATCH 0/42] hitchhiker/guide: Complete Collection".to_string();
8+
let author = Author {
99
name: "Foo Bar".to_string(),
1010
email: "[email protected]".to_string(),
11-
},
12-
MessageID {
11+
};
12+
let message_id = MessageID {
1313
href: "http://lore.kernel.org/some-list/[email protected]".to_string(),
14-
},
15-
None,
16-
"2024-07-06T19:15:48Z".to_string(),
17-
);
14+
};
15+
let updated = "2024-07-06T19:15:48Z".to_string();
16+
Patch {
17+
title,
18+
author,
19+
version: 1,
20+
number_in_series: 1,
21+
total_in_series: 1,
22+
message_id,
23+
in_reply_to: None,
24+
updated,
25+
}
26+
};
1827
let serialized_patch: &str = r#"
1928
<entry xmlns:thr="http://purl.org/syndication/thread/1.0">
2029
<author>
@@ -40,20 +49,30 @@ fn can_deserialize_patch_without_in_reply_to() {
4049

4150
#[test]
4251
fn can_deserialize_patch_with_in_reply_to() {
43-
let expected_patch: Patch = Patch::new(
44-
"[PATCH 3/42] hitchhiker/guide: Life, the Universe and Everything".to_string(),
45-
Author {
52+
let expected_patch: Patch = {
53+
let title = "[PATCH 3/42] hitchhiker/guide: Life, the Universe and Everything".to_string();
54+
let author = Author {
4655
name: "Foo Bar".to_string(),
4756
email: "[email protected]".to_string(),
48-
},
49-
MessageID {
57+
};
58+
let message_id = MessageID {
5059
href: "http://lore.kernel.org/some-list/[email protected]".to_string(),
51-
},
52-
Some(MessageID {
60+
};
61+
let in_reply_to = Some(MessageID {
5362
href: "http://lore.kernel.org/some-list/[email protected]".to_string(),
54-
}),
55-
"2024-07-06T19:16:53Z".to_string(),
56-
);
63+
});
64+
let updated = "2024-07-06T19:16:53Z".to_string();
65+
Patch {
66+
title,
67+
author,
68+
version: 1,
69+
number_in_series: 1,
70+
total_in_series: 1,
71+
message_id,
72+
in_reply_to,
73+
updated,
74+
}
75+
};
5776
let serialized_patch: &str = r#"
5877
<entry xmlns:thr="http://purl.org/syndication/thread/1.0">
5978
<author>
@@ -83,20 +102,31 @@ fn can_deserialize_patch_with_in_reply_to() {
83102
#[test]
84103
fn test_update_patch_metadata() {
85104
let patch_regex: PatchRegex = PatchRegex::new();
86-
let mut patch: Patch = Patch::new(
87-
"[RESEND][v7 PATCH 3/42] hitchhiker/guide: Life, the Universe and Everything".to_string(),
88-
Author {
105+
let mut patch: Patch = {
106+
let title = "[RESEND][v7 PATCH 3/42] hitchhiker/guide: Life, the Universe and Everything"
107+
.to_string();
108+
let author = Author {
89109
name: "Foo Bar".to_string(),
90110
email: "[email protected]".to_string(),
91-
},
92-
MessageID {
111+
};
112+
let message_id = MessageID {
93113
href: "http://lore.kernel.org/some-list/[email protected]".to_string(),
94-
},
95-
Some(MessageID {
114+
};
115+
let in_reply_to = Some(MessageID {
96116
href: "http://lore.kernel.org/some-list/[email protected]".to_string(),
97-
}),
98-
"2024-07-06T19:16:53Z".to_string(),
99-
);
117+
});
118+
let updated = "2024-07-06T19:16:53Z".to_string();
119+
Patch {
120+
title,
121+
author,
122+
version: 1,
123+
number_in_series: 1,
124+
total_in_series: 1,
125+
message_id,
126+
in_reply_to,
127+
updated,
128+
}
129+
};
100130

101131
patch.update_patch_metadata(&patch_regex);
102132

0 commit comments

Comments
 (0)