Skip to content

Commit

Permalink
Squashed 'manage_externals/' changes from 39ad53263..a3b3a0373
Browse files Browse the repository at this point in the history
a3b3a0373 Merge pull request #162 from ESMCI/fischer/python3
d4f1b1e8d Change shebang lines to python3
2fd941abc Merge pull request #158 from billsacks/modified_solution
de08dc2ee Add another option for when an external is in a modified state
e954582d0 Merge pull request #156 from billsacks/onbranch_show_hash
952e44d51 Change output: put tag/hash before branch name
10288430f Fix pre-existing pylint issues
01b13f78f When on a branch, show tag/hash, too

git-subtree-dir: manage_externals
git-subtree-split: a3b3a0373c36aa422994f2514a4d7d3d90f7da99
  • Loading branch information
billsacks committed Nov 29, 2021
1 parent 5552425 commit 218d21f
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion checkout_externals
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Main driver wrapper around the manic/checkout utility.
Expand Down
13 changes: 9 additions & 4 deletions manic/checkout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""
Tool to assemble repositories represented in a model-description file.
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion manic/externals_description.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Model description
Expand Down Expand Up @@ -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.
"""
Expand Down
29 changes: 14 additions & 15 deletions manic/repository_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,34 @@ 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()
if hash_found:
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 = ''
Expand Down
2 changes: 1 addition & 1 deletion manic/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Common public utilities for manic package
Expand Down
3 changes: 1 addition & 2 deletions test/test_sys_checkout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Unit test driver for checkout_externals
Expand Down Expand Up @@ -38,7 +38,6 @@
import os
import os.path
import shutil
import sys
import unittest

from manic.externals_description import ExternalsDescription
Expand Down
2 changes: 1 addition & 1 deletion test/test_sys_repository_git.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion test/test_unit_externals_description.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Unit test driver for checkout_externals
Expand Down
2 changes: 1 addition & 1 deletion test/test_unit_externals_status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Unit test driver for the manic external status reporting module.
Expand Down
2 changes: 1 addition & 1 deletion test/test_unit_repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Unit test driver for checkout_externals
Expand Down
4 changes: 2 additions & 2 deletions test/test_unit_repository_git.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Unit test driver for checkout_externals
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion test/test_unit_repository_svn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Unit test driver for checkout_externals
Expand Down
2 changes: 1 addition & 1 deletion test/test_unit_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""Unit test driver for checkout_externals
Expand Down

0 comments on commit 218d21f

Please sign in to comment.