mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-18 23:07:07 -05:00
fix(check_main_sync): fetch an explicit --base before resolving it
main() resolved the base before running --fetch, so an explicit base on a remote that was never fetched failed with "no base ref found" and never fetched. The fetch is now a local helper and runs first when --base is given; the default base still resolves first, then fetches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ce991f1ec2
commit
a70dea62e7
2 files changed
+16
-3
No files matched your search
@@ -97,12 +97,17 @@ if __name__ == "__main__":
|
||||
parser.add_argument("--strict", action="store_true", help="also fail when the branch is behind the base")
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
base = resolve_base(args.repo, args.base)
|
||||
if args.fetch:
|
||||
remote, _, branch = base.partition("/")
|
||||
def fetch(ref):
|
||||
remote, _, branch = ref.partition("/")
|
||||
if not branch:
|
||||
parser.error("--fetch needs a remote-tracking base such as upstream/main")
|
||||
git(args.repo, "fetch", "--quiet", remote, branch)
|
||||
|
||||
if args.fetch and args.base:
|
||||
fetch(args.base)
|
||||
base = resolve_base(args.repo, args.base)
|
||||
if args.fetch and not args.base:
|
||||
fetch(base)
|
||||
data = report(args.repo, base, args.head)
|
||||
except RuntimeError as error:
|
||||
parser.error(str(error))
|
||||
|
||||
@@ -177,6 +177,14 @@ class CheckMainSyncTests(unittest.TestCase):
|
||||
self.assertEqual(result.returncode, 2)
|
||||
self.assertIn("no base ref found", result.stderr)
|
||||
|
||||
def test_explicit_base_is_fetched_before_it_is_resolved(self):
|
||||
with tempfile.TemporaryDirectory() as other:
|
||||
subprocess.run(["git", "clone", "-q", self.directory.name, other], check=True, capture_output=True)
|
||||
self.repo.git("remote", "add", "upstream", other)
|
||||
result = subprocess.run([sys.executable, str(TOOL), "--repo", self.directory.name, "--base", "upstream/main", "--fetch"], capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertIn("merge: clean", result.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user