[v2] Allow use of the --project flag in polling mode, not just with --mbox
diff mbox

Message ID 20161122005413.20327-1-andrew.donnellan@au1.ibm.com
State Accepted
Headers show

Commit Message

Andrew Donnellan Nov. 22, 2016, 12:54 a.m. UTC
A user may want to run snowpatch in normal patchwork polling mode, but only
test one particular project. Expand the --project flag so it can be used
for this case.

Closes: #22 ("Allow use of --project switch in normal mode, not just with --mbox")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

---

V1->V2:
* Fix build
---
 src/main.rs | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Andrew Donnellan Nov. 22, 2016, 1:09 a.m. UTC | #1
On 22/11/16 11:54, Andrew Donnellan wrote:
> A user may want to run snowpatch in normal patchwork polling mode, but only
> test one particular project. Expand the --project flag so it can be used
> for this case.
>
> Closes: #22 ("Allow use of --project switch in normal mode, not just with --mbox")
> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

Applied to master: 2378f94b5928f6286ea371df3816cd6409aaff23

Patch
diff mbox

diff --git a/src/main.rs b/src/main.rs
index e1f1885..3d1428c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -64,8 +64,8 @@  mod utils;
 
 static USAGE: &'static str = "
 Usage:
-  snowpatch <config-file> [--count=<count> | --series <id>]
-  snowpatch <config-file> --mbox=<mbox> --project=<name>
+  snowpatch <config-file> [--count=<count> | --series <id>] [--project <name>]
+  snowpatch <config-file> --mbox <mbox> --project <name>
   snowpatch -v | --version
   snowpatch -h | --help
 
@@ -74,8 +74,8 @@  By default, snowpatch runs as a long-running daemon.
 Options:
   --count <count>           Run tests on <count> recent series.
   --series <id>             Run tests on the given Patchwork series.
-  --mbox <mbox>             Run tests on the given mbox file...
-  --project <name>          ...as if it were sent to project <name>.
+  --mbox <mbox>             Run tests on the given mbox file. Requires --project
+  --project <name>          Test patches for the given project.
   -v, --version             Output version information.
   -h, --help                Output this help text.
 ";
@@ -325,6 +325,13 @@  fn main() {
                 continue;
             }
 
+            // Skip if we're using -p and it's the wrong project
+            if args.flag_project != "" && series.project.linkname != args.flag_project {
+                debug!("Skipping series {} ({}) (wrong project: {})",
+                       series.name, series.id, series.project.linkname);
+                continue;
+            }
+
             match settings.projects.get(&series.project.linkname) {
                 None => {
                     debug!("Project {} not configured for series {} ({})",