Skip to content

Commit 5ad7a45

Browse files
committed
Omit "cd $dir" message if $dir is "."
1 parent 373dda3 commit 5ad7a45

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

mypy/git.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,27 @@ def warn_extra_files(dir) -> None:
8181
print("and add & commit your new files.", file=sys.stderr)
8282

8383

84+
def chdir_prefix(dir) -> str:
85+
"""Return the command to change to the target directory, plus '&&'."""
86+
if os.path.relpath(dir) != ".":
87+
return "cd " + pipes.quote(dir) + " && "
88+
else:
89+
return ""
90+
91+
8492
def error_submodule_not_initialized(name: str, dir: str) -> None:
8593
print("Submodule '{}' not initialized.".format(name), file=sys.stderr)
8694
print("Please run:", file=sys.stderr)
87-
print(" cd {}".format(pipes.quote(dir)), file=sys.stderr)
88-
print(" git submodule init {}".format(name), file=sys.stderr)
95+
print(" {}git submodule update --init {}".format(
96+
chdir_prefix(dir), name), file=sys.stderr)
8997

9098

9199
def error_submodule_not_updated(name: str, dir: str) -> None:
92100
print("Submodule '{}' not updated.".format(name), file=sys.stderr)
93101
print("Please run:", file=sys.stderr)
94-
print(" cd {}".format(pipes.quote(dir)), file=sys.stderr)
95-
print(" git submodule update {}".format(name), file=sys.stderr)
96-
print("(If you got this message because you updated {}".format(name), file=sys.stderr)
102+
print(" {}git submodule update {}".format(
103+
chdir_prefix(dir), name), file=sys.stderr)
104+
print("(If you got this message because you updated {} yourself".format(name), file=sys.stderr)
97105
print(" then run \"git add {}\" to silence this check)".format(name), file=sys.stderr)
98106

99107

0 commit comments

Comments
 (0)