From 6f9fa4a252cc7d1271cdb56a3591d6744197d4d3 Mon Sep 17 00:00:00 2001
From: Mark Harrison <mark@omniti.com>
Date: Mon, 19 May 2008 19:08:57 +0000
Subject: [PATCH] Adding a SIMPLESVN subversion check for use on bluestreak
 servers that has fewer requirements than the FRESHSVN module.

git-svn-id: https://labs.omniti.com/resmon/trunk@100 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
---
 lib/Resmon/Module/SIMPLESVN.pm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 lib/Resmon/Module/SIMPLESVN.pm

diff --git a/lib/Resmon/Module/SIMPLESVN.pm b/lib/Resmon/Module/SIMPLESVN.pm
new file mode 100644
index 0000000..5ebccc9
--- /dev/null
+++ b/lib/Resmon/Module/SIMPLESVN.pm
@@ -0,0 +1,32 @@
+package Resmon::Module::SIMPLESVN;
+use Resmon::ExtComm qw/cache_command/;
+use vars qw/@ISA/;
+@ISA = qw/Resmon::Module/;
+
+# A 'simple' subversion checkout freshness check. Unlike FRESHSVN, this check
+# doesn't have a grace period, nor does it check for the correct URL being
+# checked out. Because of this, this module can be used with an older version
+# of subversion that doesn't have support for 'svn info' on remote URLs.
+#
+# Example config:
+#
+# SIMPLESVN {
+#   /path/to/working/copy : noop
+# }
+
+sub handler {
+    my $arg = shift;
+    my $os = $arg->fresh_status();
+    return $os if $os;
+    my $wc = $arg->{'object'};
+    my $output = cache_command("svn st -u -q $wc", 60);
+    my @lines = grep { $_ !~ /^\?/ } split(/\n/, $output);
+    my $status = scalar(@lines)>1 ? "BAD" : "OK";
+    my $revision = 0;
+    if($lines[-1] =~ /^Status against revision:\s+(\d+)/) {
+      $revision = $1;
+    }
+    return $status, "rev:$revision";
+}
+
+1;
-- 
GitLab