From: Ask Bjørn Hansen <a...@develooper.com>

---
 Changes        |    2 ++
 lib/Qpsmtpd.pm |   10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

I think this would be useful for deployments from a git clone... Any objections?

 - ask

diff --git a/Changes b/Changes
index f592e37..2ec3dbc 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+  Add git information to version number when running from a git clone
+
   Add rcpt_regexp plugin (Hanno Hecker)
 
   Add notes method to Qpsmtpd::Address objects (Jared Johnson)
diff --git a/lib/Qpsmtpd.pm b/lib/Qpsmtpd.pm
index b386616..a19e264 100644
--- a/lib/Qpsmtpd.pm
+++ b/lib/Qpsmtpd.pm
@@ -9,6 +9,14 @@ use Qpsmtpd::Constants;
 
 $VERSION = "0.80";
 
+my $git;
+
+if (-e ".git") {
+    local $ENV{PATH} = "/usr/bin:/usr/local/bin:/opt/local/bin/";
+    $git = `git describe`;
+    $git && chomp $git;
+}
+
 my $hooks = {};
 my %defaults = (
                  me      => hostname,
@@ -41,7 +49,7 @@ sub DESTROY {
     #warn $_ for DashProfiler->profile_as_text("qpsmtpd");
 }
 
-sub version { $VERSION };
+sub version { $VERSION . ($git ? "/$git" : "") };
 
 sub TRACE_LEVEL { $TraceLevel }; # leave for plugin compatibility
 
-- 
1.6.0.2

Reply via email to