From 1b10014246b57c8aa382108556e963b30e48123a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 2 Sep 2008 09:28:12 -0700 Subject: [PATCH] Add a tiny "jgit version" program Displays the current version of the JAR. This is probably the same as the library code since they are currently packaged together but may in the future represent only the version of the CLI (.pgm). Signed-off-by: Shawn O. Pearce Signed-off-by: Robin Rosenberg --- .../services/org.spearce.jgit.pgm.TextBuiltin | 1 + .../src/org/spearce/jgit/pgm/Version.java | 52 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java diff --git a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin index 39ae6644..e2e7938f 100644 --- a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin +++ b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin @@ -12,6 +12,7 @@ org.spearce.jgit.pgm.RevList org.spearce.jgit.pgm.Rm org.spearce.jgit.pgm.ShowRev org.spearce.jgit.pgm.Tag +org.spearce.jgit.pgm.Version org.spearce.jgit.pgm.debug.MakeCacheTree org.spearce.jgit.pgm.debug.ReadDirCache diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java new file mode 100644 index 00000000..e4cd7079 --- /dev/null +++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2008, Google Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * - Neither the name of the Git Development Community nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.spearce.jgit.pgm; + +@Command(common = true, usage = "Display the version of jgit") +class Version extends TextBuiltin { + @Override + protected void run() throws Exception { + final Package pkg = getClass().getPackage(); + if (pkg == null || pkg.getImplementationVersion() == null) + throw die("Cannot read package information."); + + out.print("jgit version "); + out.print(pkg.getImplementationVersion()); + out.println(); + } +} -- 2.11.4.GIT