Skip to content

Commit 1d94d6d

Browse files
authored
Pull changes from a specific remote defaults to origin (#118)
1 parent c130719 commit 1d94d6d

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

migration_fixer/management/commands/makemigrations.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ def add_arguments(self, parser):
4646
help="The name of the default branch.",
4747
default="main",
4848
)
49+
parser.add_argument(
50+
"-r",
51+
"--remote",
52+
help="Git remote.",
53+
default="origin",
54+
)
4955
parser.add_argument(
5056
"-f",
5157
"--force-update",
@@ -60,6 +66,7 @@ def handle(self, *app_labels, **options):
6066
self.fix = options["fix"]
6167
self.force_update = options["force_update"]
6268
self.default_branch = options["default_branch"]
69+
self.remote = options["remote"]
6370

6471
if self.fix:
6572
try:
@@ -105,17 +112,17 @@ def handle(self, *app_labels, **options):
105112
)
106113

107114
if current_branch == self.default_branch: # pragma: no cover
108-
for remote in self.repo.remotes:
109-
remote.pull(
110-
self.default_branch,
111-
force=self.force_update,
112-
)
115+
remote = self.repo.remotes[self.remote]
116+
remote.pull(
117+
self.default_branch,
118+
force=self.force_update,
119+
)
113120
else:
114-
for remote in self.repo.remotes:
115-
remote.fetch(
116-
f"{self.default_branch}:{self.default_branch}",
117-
force=self.force_update,
118-
)
121+
remote = self.repo.remotes[self.remote]
122+
remote.fetch(
123+
f"{self.default_branch}:{self.default_branch}",
124+
force=self.force_update,
125+
)
119126

120127
if self.verbosity >= 2:
121128
self.stdout.write(

0 commit comments

Comments
 (0)