Skip to content

Commit 1ed94f6

Browse files
committed
Remove feature to fetch upstream
1 parent 90c0fa6 commit 1ed94f6

File tree

3 files changed

+14
-91
lines changed

3 files changed

+14
-91
lines changed

django_mongodb_cli/repo.py

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
get_management_command,
1111
get_repos,
1212
repo_clone,
13-
repo_fetch,
1413
repo_install,
1514
repo_status,
1615
repo_update,
@@ -45,7 +44,7 @@ def repo(ctx, list_repos):
4544
Run Django fork and third-party library tests.
4645
"""
4746
ctx.obj = Repo()
48-
repos, url_pattern, branch_pattern, upstream_pattern = get_repos("pyproject.toml")
47+
repos, url_pattern, branch_pattern = get_repos("pyproject.toml")
4948
if list_repos:
5049
for repo_entry in repos:
5150
click.echo(repo_entry)
@@ -70,7 +69,7 @@ def repo(ctx, list_repos):
7069
@pass_repo
7170
def clone(repo, ctx, repo_names, all_repos, install):
7271
"""Clone repositories from `pyproject.toml`."""
73-
repos, url_pattern, branch_pattern, upstream_pattern = get_repos("pyproject.toml")
72+
repos, url_pattern, branch_pattern = get_repos("pyproject.toml")
7473

7574
if repo_names:
7675
for repo_name in repo_names:
@@ -123,9 +122,7 @@ def install(repo, ctx, repo_names, all_repos):
123122
return
124123

125124
if all_repos:
126-
repos, url_pattern, branch_pattern, upstream_pattern = get_repos(
127-
"pyproject.toml"
128-
)
125+
repos, url_pattern, branch_pattern = get_repos("pyproject.toml")
129126
for repo_entry in repos:
130127
url_match = url_pattern.search(repo_entry)
131128
if url_match:
@@ -140,40 +137,6 @@ def install(repo, ctx, repo_names, all_repos):
140137
click.echo(ctx.get_help())
141138

142139

143-
@repo.command()
144-
@click.argument("repo_names", nargs=-1)
145-
@click.option(
146-
"-a",
147-
"--all-repos",
148-
is_flag=True,
149-
)
150-
@click.pass_context
151-
@pass_repo
152-
def fetch(repo, ctx, repo_names, all_repos):
153-
"""Add and fetch upstream remotes for cloned repositories."""
154-
repos, url_pattern, _, upstream_pattern = get_repos("pyproject.toml")
155-
if repo_names:
156-
for repo_name in repo_names:
157-
click.echo(f"Fetching upstream for {repo_name}...")
158-
for repo_entry in repos:
159-
if (
160-
os.path.basename(url_pattern.search(repo_entry).group(0))
161-
== repo_name
162-
):
163-
repo_fetch(repo_entry, upstream_pattern, url_pattern, repo)
164-
click.echo(f"Repository '{repo_name}' not found.")
165-
return
166-
167-
if all_repos:
168-
click.echo(f"Fetching upstream remotes for {len(repos)} repositories...")
169-
for repo_entry in repos:
170-
repo_fetch(repo_entry, upstream_pattern, url_pattern, repo)
171-
return
172-
173-
if ctx.args == []:
174-
click.echo(ctx.get_help())
175-
176-
177140
@repo.command()
178141
@click.argument("repo_names", nargs=-1)
179142
@click.option(
@@ -218,7 +181,7 @@ def makemigrations(
218181
):
219182
"""Run `makemigrations` for cloned repositories."""
220183

221-
repos, url_pattern, branch_pattern, upstream_pattern = get_repos("pyproject.toml")
184+
repos, url_pattern, branch_pattern = get_repos("pyproject.toml")
222185
if repo_name:
223186
for repo_entry in repos:
224187
url_match = url_pattern.search(repo_entry)
@@ -291,7 +254,7 @@ def test(
291254
"""
292255
Run tests for Django fork and third-party libraries.
293256
"""
294-
repos, url_pattern, branch_pattern, upstream_pattern = get_repos("pyproject.toml")
257+
repos, url_pattern, branch_pattern = get_repos("pyproject.toml")
295258
if repo_name:
296259
# Show test settings
297260
if show:

django_mongodb_cli/utils.py

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def get_repos(pyproject_path):
100100
branch_pattern = re.compile(
101101
r"git\+ssh://git@github\.com/[^/]+/[^@]+@([a-zA-Z0-9_\-\.]+)\b"
102102
)
103-
upstream_pattern = re.compile(r"#\s*upstream:\s*([\w-]+)")
104-
return repos, url_pattern, branch_pattern, upstream_pattern
103+
return repos, url_pattern, branch_pattern
105104

106105

107106
def repo_clone(repo_entry, url_pattern, branch_pattern, repo):
@@ -154,45 +153,6 @@ def repo_install(clone_path):
154153
)
155154

156155

157-
def repo_fetch(repo_entry, upstream_pattern, url_pattern, repo):
158-
"""Helper function to fetch upstream remotes for a repository."""
159-
url_match = url_pattern.search(repo_entry)
160-
upstream_match = upstream_pattern.search(repo_entry)
161-
162-
if not url_match or not upstream_match:
163-
return
164-
165-
repo_url = url_match.group(0)
166-
repo_name = os.path.basename(repo_url)
167-
clone_path = os.path.join(repo.home, repo_name)
168-
169-
if os.path.exists(clone_path):
170-
click.echo(f"Adding upstream remote for {repo_name}...")
171-
remote = f"https://github.com/{upstream_match.group(1)}/{repo_name}"
172-
if os.path.exists(clone_path):
173-
repo = git.Repo(clone_path)
174-
try:
175-
repo.create_remote("upstream", remote)
176-
click.echo(click.style(f"Added remote {remote}", fg="green"))
177-
except git.exc.GitCommandError:
178-
click.echo(
179-
click.style(
180-
f"Remote {repo.remotes.upstream.name} exists! {repo.remotes.upstream.url}",
181-
fg="yellow",
182-
)
183-
)
184-
repo.remotes.upstream.fetch()
185-
try:
186-
repo.git.rebase("upstream/main")
187-
click.echo(click.style(f"Rebased {repo_name}", fg="green"))
188-
except git.exc.GitCommandError:
189-
click.echo(click.style(f"Failed to rebase {repo_name}", fg="red"))
190-
else:
191-
click.echo(click.style(f"Skipping {remote}", fg="yellow"))
192-
else:
193-
click.echo(f"Skipping {repo_name}: Repository not found at {clone_path}")
194-
195-
196156
def repo_update(repo_entry, url_pattern, repo):
197157
"""Helper function to update a single repository."""
198158
url_match = url_pattern.search(repo_entry)

pyproject.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ packages = ["django_mongodb_cli"]
3535
dev = [
3636
"django-allauth @ git+ssh://[email protected]/pennersr/django-allauth@main",
3737
"django-debug-toolbar @ git+ssh://[email protected]/django-commons/django-debug-toolbar@main",
38-
"django-filter @ git+ssh://[email protected]/aclark4life/django-filter@main # upstream: carltongibson",
39-
"django-mongodb-app @ git+ssh://[email protected]/aclark4life/[email protected] # upstream: mongodb-labs",
40-
"django-mongodb-backend @ git+ssh://[email protected]/aclark4life/django-mongodb-backend@main # upstream: mongodb",
41-
"django-mongodb-extensions @ git+ssh://[email protected]/aclark4life/django-mongodb-extensions@main",
42-
"django-mongodb-project @ git+ssh://[email protected]/aclark4life/[email protected] # upstream: mongodb-labs",
38+
"django-filter @ git+ssh://[email protected]/carltongibson/django-filter@main",
39+
"django-mongodb-app @ git+ssh://[email protected]/mongodb-labs/[email protected]",
40+
"django-mongodb-backend @ git+ssh://[email protected]/mongodb/django-mongodb-backend@main",
41+
"django-mongodb-extensions @ git+ssh://[email protected]/mongodb-labs/django-mongodb-extensions@main",
42+
"django-mongodb-project @ git+ssh://[email protected]/mongodb-labs/[email protected]",
4343
"django-mongodb-templates @ git+ssh://[email protected]/aclark4life/django-mongodb-templates@main",
4444
"django-rest-framework @ git+ssh://[email protected]/encode/django-rest-framework@main",
4545
"django @ git+ssh://[email protected]/mongodb-forks/[email protected]",
4646
"docs @ git+ssh://[email protected]/mongodb/docs@master",
4747
"flask-pymongo @ git+ssh://[email protected]/mongodb-labs/flask-pymongo",
4848
"DublinCityCenterPubFinder @ git+ssh://[email protected]/anaiyaraisin/DublinCityCenterPubFinder",
4949
"langchain-mongodb @ git+ssh://[email protected]/langchain-ai/langchain-mongodb@main",
50-
"mongo-python-driver @ git+ssh://[email protected]/aclark4life/mongo-python-driver@master # upstream: mongodb",
51-
"wagtail-mongodb-project @ git+ssh://[email protected]/aclark4life/wagtail-mongodb-project@main",
52-
"wagtail @ git+ssh://[email protected]/aclark4life/wagtail@main # upstream: mongodb-forks",
50+
"mongo-python-driver @ git+ssh://[email protected]/mongodb/mongo-python-driver@master",
51+
"wagtail-mongodb-project @ git+ssh://[email protected]/mongodb-labs/wagtail-mongodb-project@main",
52+
"wagtail @ git+ssh://[email protected]/mongodb-forks/wagtail@main",
5353
"xmlsec @ git+ssh://[email protected]/xmlsec/python-xmlsec@main",
5454
]
5555

0 commit comments

Comments
 (0)