[snowpatch] [PATCH] Fix --series option

Andrew Donnellan andrew.donnellan at au1.ibm.com
Tue Jul 31 16:38:17 AEST 2018


Somewhere along the way, we completely broke the --series option and failed
to notice.

It appears we try to retrieve a Project over the Patchwork API and pass an
entirely invalid URL. As it turns out we can just use the Project already
retrieved as part of the Patch that we already retrieve, so use that
instead.

(This is why we need tests, which we ironically don't yet have...)

Reported-by: Russell Currey <ruscur at russell.cc>
Closes: #43 ("Fix --series")
Signed-off-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
---
 src/main.rs      | 6 ++----
 src/patchwork.rs | 4 ----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index eb7ffc1ee36d..3102cf82e972 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -370,10 +370,8 @@ fn main() {
         let patch = patchwork
             .get_patch_by_url(&series.patches.last().unwrap().url)
             .unwrap();
-        // We have to do it this way since there's no project field on Series
-        let project = patchwork.get_project(&patch.project.name).unwrap();
-        match settings.projects.get(&project.link_name) {
-            None => panic!("Couldn't find project {}", &project.link_name),
+        match settings.projects.get(&patch.project.link_name) {
+            None => panic!("Couldn't find project {}", &patch.project.link_name),
             Some(project) => {
                 let dependencies = patchwork.get_patch_dependencies(&patch);
                 let mbox = patchwork.get_patches_mbox(dependencies);
diff --git a/src/patchwork.rs b/src/patchwork.rs
index 378c6ca9de70..c9c335472496 100644
--- a/src/patchwork.rs
+++ b/src/patchwork.rs
@@ -284,10 +284,6 @@ impl PatchworkServer {
         Ok(resp.status())
     }
 
-    pub fn get_project(&self, url: &str) -> Result<Project, serde_json::Error> {
-        serde_json::from_str(&self.get_url_string(url).unwrap())
-    }
-
     pub fn get_patch(&self, patch_id: &u64) -> Result<Patch, serde_json::Error> {
         let url = format!(
             "{}{}/patches/{}{}",
-- 
2.11.0



More information about the snowpatch mailing list