diff --git a/checkout_externals b/checkout_externals index a0698baef0..48bce24010 100755 --- a/checkout_externals +++ b/checkout_externals @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Main driver wrapper around the manic/checkout utility. diff --git a/manic/checkout.py b/manic/checkout.py index 8dd1798d7a..2223b1f0d8 100755 --- a/manic/checkout.py +++ b/manic/checkout.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Tool to assemble repositories represented in a model-description file. @@ -392,7 +392,7 @@ def main(args): # exit gracefully msg = """The external repositories labeled with 'M' above are not in a clean state. -The following are three options for how to proceed: +The following are four options for how to proceed: (1) Go into each external that is not in a clean state and issue either a 'git status' or an 'svn status' command (depending on whether the external is managed by git or @@ -412,12 +412,17 @@ def main(args): {program_name}. Excluding externals labeled with 'M' will allow {program_name} to update the other, non-excluded externals. +(4) As a last resort, if you are confident that there is no work that needs to be saved + from a given external, you can remove that external (via "rm -rf [directory]") and + then rerun the {program_name} tool. This option is mainly useful as a workaround for + issues with this tool (such as https://github.com/ESMCI/manage_externals/issues/157). + The external repositories labeled with '?' above are not under version control using the expected protocol. If you are sure you want to switch protocols, and you don't have any work you need to save from this -directory, then run "rm -rf [directory]" before re-running the -checkout_externals tool. +directory, then run "rm -rf [directory]" before rerunning the +{program_name} tool. """.format(program_name=program_name, config_file=args.externals) printlog('-' * 70) diff --git a/manic/externals_description.py b/manic/externals_description.py index 918d616e37..6a54935935 100644 --- a/manic/externals_description.py +++ b/manic/externals_description.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Model description @@ -193,6 +193,9 @@ def parse_submodules_desc_section(section_items, file_path): def read_gitmodules_file(root_dir, file_name): # pylint: disable=deprecated-method # Disabling this check because the method is only used for python2 + # pylint: disable=too-many-locals + # pylint: disable=too-many-branches + # pylint: disable=too-many-statements """Read a .gitmodules file and convert it to be compatible with an externals description. """ diff --git a/manic/repository_git.py b/manic/repository_git.py index f986051001..3a6a0f1716 100644 --- a/manic/repository_git.py +++ b/manic/repository_git.py @@ -109,27 +109,21 @@ def _clone_repo(self, base_dir_path, repo_dir_name, verbosity): def _current_ref(self): """Determine the *name* associated with HEAD. - If we're on a branch, then returns the branch name; otherwise, - if we're on a tag, then returns the tag name; otherwise, returns + If we're on a tag, then returns the tag name; otherwise, returns the current hash. Returns an empty string if no reference can be determined (e.g., if we're not actually in a git repository). + + If we're on a branch, then the branch name is also included in + the returned string (in addition to the tag / hash). """ ref_found = False - # If we're on a branch, then use that as the current ref - branch_found, branch_name = self._git_current_branch() - if branch_found: - current_ref = branch_name + # If we're exactly at a tag, use that as the current ref + tag_found, tag_name = self._git_current_tag() + if tag_found: + current_ref = tag_name ref_found = True - if not ref_found: - # Otherwise, if we're exactly at a tag, use that as the - # current ref - tag_found, tag_name = self._git_current_tag() - if tag_found: - current_ref = tag_name - ref_found = True - if not ref_found: # Otherwise, use current hash as the current ref hash_found, hash_name = self._git_current_hash() @@ -137,7 +131,12 @@ def _current_ref(self): current_ref = hash_name ref_found = True - if not ref_found: + if ref_found: + # If we're on a branch, include branch name in current ref + branch_found, branch_name = self._git_current_branch() + if branch_found: + current_ref = "{} (branch {})".format(current_ref, branch_name) + else: # If we still can't find a ref, return empty string. This # can happen if we're not actually in a git repo current_ref = '' diff --git a/manic/utils.py b/manic/utils.py index f57f43930c..9c63ffe65e 100644 --- a/manic/utils.py +++ b/manic/utils.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Common public utilities for manic package diff --git a/test/test_sys_checkout.py b/test/test_sys_checkout.py index 118bee5308..b13e96a17d 100644 --- a/test/test_sys_checkout.py +++ b/test/test_sys_checkout.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit test driver for checkout_externals @@ -38,7 +38,6 @@ import os import os.path import shutil -import sys import unittest from manic.externals_description import ExternalsDescription diff --git a/test/test_sys_repository_git.py b/test/test_sys_repository_git.py index f6dbf84284..29d5433b95 100644 --- a/test/test_sys_repository_git.py +++ b/test/test_sys_repository_git.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Tests of some of the functionality in repository_git.py that actually interacts with git repositories. diff --git a/test/test_unit_externals_description.py b/test/test_unit_externals_description.py index 0b1248f670..30e5288499 100644 --- a/test/test_unit_externals_description.py +++ b/test/test_unit_externals_description.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit test driver for checkout_externals diff --git a/test/test_unit_externals_status.py b/test/test_unit_externals_status.py index f8e953f756..f019514e9e 100644 --- a/test/test_unit_externals_status.py +++ b/test/test_unit_externals_status.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit test driver for the manic external status reporting module. diff --git a/test/test_unit_repository.py b/test/test_unit_repository.py index 5b9c242fd3..1b93861834 100644 --- a/test/test_unit_repository.py +++ b/test/test_unit_repository.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit test driver for checkout_externals diff --git a/test/test_unit_repository_git.py b/test/test_unit_repository_git.py index 4a0a334bb1..a6ad9f1003 100644 --- a/test/test_unit_repository_git.py +++ b/test/test_unit_repository_git.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit test driver for checkout_externals @@ -101,7 +101,7 @@ def test_ref_branch(self): True, 'feature3') self._repo._git_current_tag = self._git_current_tag(True, 'foo_tag') self._repo._git_current_hash = self._git_current_hash(True, 'abc123') - expected = 'feature3' + expected = 'foo_tag (branch feature3)' result = self._repo._current_ref() self.assertEqual(result, expected) diff --git a/test/test_unit_repository_svn.py b/test/test_unit_repository_svn.py index 7ff31c4218..41b173bf3d 100644 --- a/test/test_unit_repository_svn.py +++ b/test/test_unit_repository_svn.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit test driver for checkout_externals diff --git a/test/test_unit_utils.py b/test/test_unit_utils.py index c994e58ebe..80e1636649 100644 --- a/test/test_unit_utils.py +++ b/test/test_unit_utils.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit test driver for checkout_externals