Skip to content

Commit f577ed6

Browse files
committed
Updates to git commands
1 parent 66c0af5 commit f577ed6

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ requirements.txt
3131
search/
3232
uv.lock
3333
docs/_build/
34+
config/wagtail/wagtail_settings.py

django_mongodb_cli/repo.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,16 @@ def status(repo, ctx, repo_names, all_repos, reset):
444444
repos, url_pattern, _, _ = get_repos("pyproject.toml")
445445
if repo_names:
446446
for repo_name in repo_names:
447+
not_found = set()
447448
for repo_entry in repos:
448449
if (
449450
os.path.basename(url_pattern.search(repo_entry).group(0))
450451
== repo_name
451452
):
452453
repo_status(repo_entry, url_pattern, repo, reset=reset)
453-
click.echo(f"Repository '{repo_name}' not found.")
454+
else:
455+
not_found.add(repo_name)
456+
click.echo(f"Repository '{not_found.pop()}' not found.")
454457
return
455458

456459
if all_repos:

django_mongodb_cli/utils.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import click
2-
import django_mongodb_backend
32
import git
43
import os
54
import shutil
@@ -82,6 +81,7 @@ def get_management_command(command=None):
8281

8382
def get_databases(app):
8483
"""Get the databases configuration for the specified app."""
84+
import django_mongodb_backend
8585

8686
DATABASE_URL = os.environ.get(
8787
"MONGODB_URI", f"mongodb://localhost:27017/{app}_tests"
@@ -210,6 +210,8 @@ def repo_update(repo_entry, url_pattern, repo):
210210
click.echo(click.style(repo.git.pull(), fg="blue"))
211211
except git.exc.NoSuchPathError:
212212
click.echo("Not a valid Git repository.")
213+
except git.exc.GitCommandError:
214+
click.echo(click.style(f"Failed to update {repo_name}", fg="red"))
213215
else:
214216
click.echo(f"Skipping {repo_name}: Repository not found at {clone_path}")
215217

@@ -225,13 +227,26 @@ def repo_status(repo_entry, url_pattern, repo, reset=False):
225227
clone_path = os.path.join(repo.home, repo_name)
226228

227229
if os.path.exists(clone_path):
228-
click.echo(f"Status of {repo_name}...")
229230
try:
230231
repo = git.Repo(clone_path)
232+
click.echo(click.style(f"Status for {repo_name}:", fg="blue"))
231233
if reset:
232234
click.echo(click.style(repo.git.reset("--hard"), fg="blue"))
233235
else:
236+
click.echo()
237+
click.echo(
238+
click.style(
239+
"".join(
240+
[f"{remote.name}:{remote.url}" for remote in repo.remotes]
241+
),
242+
fg="blue",
243+
)
244+
)
245+
click.echo()
234246
click.echo(click.style(repo.git.status(), fg="blue"))
247+
click.echo()
248+
click.echo()
249+
click.echo()
235250
except git.exc.NoSuchPathError:
236251
click.echo("Not a valid Git repository.")
237252
else:

0 commit comments

Comments
 (0)