Add remote branch to .buckversion.
Summary:
Allow us to specify a buckversion with a remote branch.
diff --git a/bin/buck_common b/bin/buck_common
index 026a5ca..9bb02b0 100755
--- a/bin/buck_common
+++ b/bin/buck_common
@@ -33,11 +33,18 @@
echo >&2 "::: '.nobuckcheck' file is present. Not updating buck"
echo >&2 ":::"
elif [ -e "${PROJECT_ROOT}/.buckversion" ]; then
- BUCK_REQUIRED_VERSION=`cat ${PROJECT_ROOT}/.buckversion`
+ BUCK_COMMIT_HASH_AND_BRANCH=`cat ${PROJECT_ROOT}/.buckversion`
+
+ BUCK_REQUIRED_VERSION=`echo ${BUCK_COMMIT_HASH_AND_BRANCH} | awk -F':' '{print $1}'`
+ BUCK_REQUIRED_BRANCH=`echo ${BUCK_COMMIT_HASH_AND_BRANCH} | awk -F':' '{print $2}'`
# If the hash is in not in the user's repository, do a `git fetch`.
if ! git cat-file -e "$BUCK_REQUIRED_VERSION"; then
- git fetch --all
+ if [ -e "${BUCK_REQUIRED_BRANCH}" ]; then
+ git fetch --all
+ else
+ git fetch origin $BUCK_REQUIRED_BRANCH
+ fi
fi
diff --git a/docs/concept/buckversion.soy b/docs/concept/buckversion.soy
index 89fe53c..9beb646 100644
--- a/docs/concept/buckversion.soy
+++ b/docs/concept/buckversion.soy
@@ -10,8 +10,25 @@
<div class="{css overview}">
If the root of your project contains a file named <code>.buckversion</code>,
-then Buck will expect that file to contain a Git hash that specifies the
-version of Buck that should be used to build your project.
+then Buck will expect that file to contain a Git hash and an optional branch
+that specifies the version of Buck that should be used to build your project.
+
+<p>
+
+The contents of <code>.buckversion</code> are expected to be in the format
+
+{literal}<pre>
+[Buck git hash]:[Optional Remote branch]
+{/literal}</pre>
+
+<p>
+
+For example, the following would both be valid <code>.buckversion</code> files:
+
+<ul>
+ <li><code>abcdef1234567890</code>
+ <li><code>abcdef1234567890:refs/releases/release-01-10-2013</code>
+</ul>
<p>
@@ -19,8 +36,8 @@
compare the value in <code>.buckversion</code> with the value of
{sp}<code>git rev-parse HEAD</code> in the directory where you checked out
Buck from Git. If the values differ, then Buck will update itself to the
-revision that you specified (using <code>git fetch</code> and
-{sp}<code>git checkout</code>), and then rebuild itself.
+revision that you specified (using <code>git fetch</code>, tracking the remote
+branch if needed, and <code>git checkout</code>), and then rebuild itself.
<p>