Skip to content

Commit e15942e

Browse files
authored
Merge pull request #78 from ESMCI/py38_compatibility_better_warnings
py 3.8 compatibility
2 parents 01e2975 + 5d3af80 commit e15942e

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

git_fleximod/cli.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
22
import argparse, os, sys
3-
from importlib.resources import files
43
from git_fleximod import utils
54

65
__version__ = "1.0.1"
@@ -12,8 +11,8 @@ def print_help(self, file=None):
1211

1312
# Then append the contents of README.md
1413
candidate_paths = [
15-
os.path.join(sys.prefix, "share", "your-package", "README.md"),
16-
os.path.join(os.path.dirname(__file__), "..", "README.md") # fallback for dev
14+
Path(sys.prefix) / "share" / "git_fleximod" / "README.md",
15+
Path(__file__).resolve().parent.parent / "README.md", # fallback for dev
1716
]
1817
for path in candidate_paths:
1918
if os.path.exists(path):
@@ -25,26 +24,21 @@ def print_help(self, file=None):
2524
def find_root_dir(filename=".gitmodules"):
2625
""" finds the highest directory in tree
2726
which contains a file called filename """
28-
try:
29-
root = utils.execute_subprocess(["git","rev-parse", "--show-toplevel"],
30-
output_to_caller=True ).rstrip()
31-
except:
32-
d = Path.cwd()
33-
root = Path(d.root)
34-
dirlist = []
35-
dl = d
36-
while dl != root:
37-
dirlist.append(dl)
38-
dl = dl.parent
39-
dirlist.append(root)
40-
dirlist.reverse()
41-
42-
for dl in dirlist:
43-
attempt = dl / filename
44-
if attempt.is_file():
45-
return str(dl)
46-
return None
47-
return Path(root)
27+
d = Path.cwd()
28+
root = Path(d.root)
29+
dirlist = []
30+
dl = d
31+
while dl != root:
32+
dirlist.append(dl)
33+
dl = dl.parent
34+
dirlist.append(root)
35+
dirlist.reverse()
36+
37+
for dl in dirlist:
38+
attempt = dl / filename
39+
if attempt.is_file():
40+
return str(dl)
41+
return None
4842

4943
def get_parser():
5044
description = """

git_fleximod/gitinterface.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ def _git_operation_command(self, operation, args):
6060

6161
# pylint: disable=unused-argument
6262
def git_operation(self, operation, *args, **kwargs):
63-
command = self._git_operation_command(operation, args)
63+
newargs = []
64+
for a in args:
65+
# Do not use ssh interface
66+
if isinstance(a, str):
67+
a = a.replace("[email protected]:", "https://github.com/")
68+
newargs.append(a)
69+
70+
command = self._git_command(operation, *newargs)
6471
if isinstance(command, list):
6572
try:
6673
status, output = utils.execute_subprocess(command, status_to_caller=True, output_to_caller=True)

git_fleximod/submodule.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ def status(self):
119119
atag = atag[:-1]
120120
if atag == self.fxtag:
121121
break
122-
123122
recurse = False
124123
if rurl != self.url:
125124
remote = self._add_remote(git)

0 commit comments

Comments
 (0)