summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2016-05-31 10:44:01 -0400
committerBen Boeckel <ben.boeckel@kitware.com>2016-06-29 14:49:19 -0400
commit7ec191ce0b82827013485a98db84cd66aa2ca1b4 (patch)
treedbde6cb156de73ee9ce921b95fa1d49b9ec13ddb /lib
parent6f69c01915aad8bb2d4b242ab7e5b185adf08b7d (diff)
downloadspack-7ec191ce0b82827013485a98db84cd66aa2ca1b4.tar.gz
spack-7ec191ce0b82827013485a98db84cd66aa2ca1b4.tar.bz2
spack-7ec191ce0b82827013485a98db84cd66aa2ca1b4.tar.xz
spack-7ec191ce0b82827013485a98db84cd66aa2ca1b4.zip
bootstrap: use the currently checked out branch
The `master` branch is not really where Spack development happens, so default to it, but use the user's current branch if it's there.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/bootstrap.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/spack/spack/cmd/bootstrap.py b/lib/spack/spack/cmd/bootstrap.py
index 9fd428e6b1..16808b30b8 100644
--- a/lib/spack/spack/cmd/bootstrap.py
+++ b/lib/spack/spack/cmd/bootstrap.py
@@ -39,10 +39,15 @@ def setup_parser(subparser):
subparser.add_argument('prefix', help="names of prefix where we should install spack")
-def get_origin_url():
+def get_origin_info():
git_dir = join_path(spack.prefix, '.git')
git = which('git', required=True)
try:
+ branch = git('symbolic-ref', '--short', 'HEAD', output=str)
+ except ProcessError:
+ branch = 'develop'
+ tty.warn('No branch found; using default branch: %s' % branch)
+ try:
origin_url = git(
'--git-dir=%s' % git_dir,
'config', '--get', 'remote.origin.url',
@@ -51,11 +56,11 @@ def get_origin_url():
origin_url = _SPACK_UPSTREAM
tty.warn('No git repository found; '
'using default upstream URL: %s' % origin_url)
- return origin_url.strip()
+ return (origin_url.strip(), branch.strip())
def bootstrap(parser, args):
- origin_url = get_origin_url()
+ origin_url, branch = get_origin_info()
prefix = args.prefix
tty.msg("Fetching spack from origin: %s" % origin_url)
@@ -81,8 +86,9 @@ def bootstrap(parser, args):
git = which('git', required=True)
git('init', '--shared', '-q')
git('remote', 'add', 'origin', origin_url)
- git('fetch', 'origin', 'master:refs/remotes/origin/master', '-n', '-q')
- git('reset', '--hard', 'origin/master', '-q')
+ git('fetch', 'origin', '%s:refs/remotes/origin/%s' % (branch, branch),
+ '-n', '-q')
+ git('reset', '--hard', 'origin/%s' % branch, '-q')
tty.msg("Successfully created a new spack in %s" % prefix,
"Run %s/bin/spack to use this installation." % prefix)