← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~harlowja/cloud-init/cloud-init-git-tarball-make into lp:cloud-init

 

Joshua Harlow has proposed merging lp:~harlowja/cloud-init/cloud-init-git-tarball-make into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/cloud-init-git-tarball-make/+merge/271394

Make tools/make-tarball work under existence of a .git directory (or a .bzr one).
-- 
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/cloud-init-git-tarball-make into lp:cloud-init.
=== modified file 'tools/make-tarball'
--- tools/make-tarball	2014-02-28 21:19:19 +0000
+++ tools/make-tarball	2015-09-16 22:03:26 +0000
@@ -1,4 +1,5 @@
 #!/bin/sh
+
 set -e
 
 find_root() {
@@ -18,22 +19,33 @@
     exit 1;
 fi
 
-REVNO=$(bzr revno "$ROOT_DIR")
+if [ -d "$ROOT_DIR/.git" ]; then
+    VERSION=$(cd $ROOT_DIR && python setup.py --version)
+    REVPOSTFIX=""
+else
+    REVNO=$(bzr revno "$ROOT_DIR")
+    REVPOSTFIX="~bzr$REVNO"
+    VERSION=$("$ROOT_DIR/tools/read-version")
+fi
 
 if [ ! -z "$1" ]; then
     ARCHIVE_FN="$1"
 else
-    VERSION=$("$ROOT_DIR/tools/read-version")
-    ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz"
-fi
-
-export_uncommitted=""
-if [ "${UNCOMMITTED:-0}" != "0" ]; then
-   export_uncommitted="--uncommitted"
-fi
-
-bzr export ${export_uncommitted} \
-   --format=tgz --root="cloud-init-$VERSION~bzr$REVNO" \
-    "--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"
+    ARCHIVE_FN="$PWD/cloud-init-${VERSION}${REVPOSTFIX}.tar.gz"
+fi
+
+if [ -d "$ROOT_DIR/.git" ]; then
+    git_hash=$(cd $ROOT_DIR &&  git log --pretty=format:'%h' -n 1)
+    cd $ROOT_DIR && git archive -o "$ARCHIVE_FN" \
+                    --prefix="cloud-init-${VERSION}${REVPOSTFIX}/" "$git_hash"
+else
+    export_uncommitted=""
+    if [ "${UNCOMMITTED:-0}" != "0" ]; then
+       export_uncommitted="--uncommitted"
+    fi
+    bzr export ${export_uncommitted} \
+       --format=tgz --root="cloud-init-${VERSION}${REVPOSTFIX}" \
+        "--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"
+fi
 
 echo "$ARCHIVE_FN"


Follow ups