From 7ec191ce0b82827013485a98db84cd66aa2ca1b4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 31 May 2016 10:44:01 -0400 Subject: 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. --- lib/spack/spack/cmd/bootstrap.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lib') 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,9 +39,14 @@ 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, @@ -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) -- cgit v1.2.3-60-g2f50