Compare commits

..

3 Commits

Author SHA1 Message Date
aada468916 upload: Return correct tuple values in _ProcessResults
Incorrect tuple values were returned with http://go/grev/440221 -
instead of returning (Project, ReviewableBranch), _ProcessResults was
returning (int, ReviewableBranch).

R=jojwang@google.com

Bug: 376731172
Change-Id: I75205f42fd23f5ee6bd8d0c15b18066189b42bd9
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/441121
Reviewed-by: Sam Saccone <samccone@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Tested-by: Josip Sokcevic <sokcevic@google.com>
2024-10-31 21:18:53 +00:00
1d5098617e worktree: Do not try to fix relative paths
--worktree was broken with incorrect paths in the .git files
whenever the local copy of git populated gitdir with relative paths
instead of absoulte paths.

Bug: 376251410
Change-Id: Id32dc1576315218967de2a9bfe43bf7a5a0e7aa6
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/440801
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Tested-by: Allen Webb <allenwebb@google.com>
2024-10-30 17:03:57 +00:00
e219c78fe5 forall: Fix returning results early
rc should be returned only after all results are processed.

R=jojwang@google.com

Bug: b/376454189
Change-Id: I8200b9954240dd3e8e9f2ab82494779a3cb38627
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/440901
Tested-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Joanna Wang <jojwang@google.com>
2024-10-30 16:11:04 +00:00
3 changed files with 28 additions and 23 deletions

View File

@ -3375,20 +3375,25 @@ class Project:
setting = fp.read() setting = fp.read()
assert setting.startswith("gitdir:") assert setting.startswith("gitdir:")
git_worktree_path = setting.split(":", 1)[1].strip() git_worktree_path = setting.split(":", 1)[1].strip()
# `gitdir` maybe be either relative or absolute depending on the
# behavior of the local copy of git, so only convert the path to
# relative if it needs to be converted.
if os.path.isabs(git_worktree_path):
# Some platforms (e.g. Windows) won't let us update dotgit in situ # Some platforms (e.g. Windows) won't let us update dotgit in situ
# because of file permissions. Delete it and recreate it from scratch # because of file permissions. Delete it and recreate it from
# to avoid. # scratch to avoid.
platform_utils.remove(dotgit) platform_utils.remove(dotgit)
# Use relative path from checkout->worktree & maintain Unix line endings # Use relative path from checkout->worktree & maintain Unix line
# on all OS's to match git behavior. # endings on all OS's to match git behavior.
with open(dotgit, "w", newline="\n") as fp: with open(dotgit, "w", newline="\n") as fp:
print( print(
"gitdir:", "gitdir:",
os.path.relpath(git_worktree_path, self.worktree), os.path.relpath(git_worktree_path, self.worktree),
file=fp, file=fp,
) )
# Use relative path from worktree->checkout & maintain Unix line endings # Use relative path from worktree->checkout & maintain Unix line
# on all OS's to match git behavior. # endings on all OS's to match git behavior.
with open( with open(
os.path.join(git_worktree_path, "gitdir"), "w", newline="\n" os.path.join(git_worktree_path, "gitdir"), "w", newline="\n"
) as fp: ) as fp:

View File

@ -298,7 +298,7 @@ without iterating through the remaining projects.
) )
except (KeyboardInterrupt, WorkerKeyboardInterrupt): except (KeyboardInterrupt, WorkerKeyboardInterrupt):
# Catch KeyboardInterrupt raised inside and outside of workers # Catch KeyboardInterrupt raised inside and outside of workers
rc = rc or errno.EINTR rc = errno.EINTR
except Exception as e: except Exception as e:
# Catch any other exceptions raised # Catch any other exceptions raised
logger.error( logger.error(
@ -306,7 +306,7 @@ without iterating through the remaining projects.
type(e).__name__, type(e).__name__,
e, e,
) )
rc = rc or getattr(e, "errno", 1) rc = getattr(e, "errno", 1)
if rc != 0: if rc != 0:
sys.exit(rc) sys.exit(rc)

View File

@ -737,8 +737,8 @@ Gerrit Code Review: https://www.gerritcodereview.com/
pending = [] pending = []
for result in results: for result in results:
project_idx, avail = result project_idx, avail = result
if avail is None:
project = projects[project_idx] project = projects[project_idx]
if avail is None:
logger.error( logger.error(
'repo: error: %s: Unable to upload branch "%s". ' 'repo: error: %s: Unable to upload branch "%s". '
"You might be able to fix the branch by running:\n" "You might be able to fix the branch by running:\n"
@ -748,7 +748,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
project.manifest.branch, project.manifest.branch,
) )
elif avail: elif avail:
pending.append(result) pending.append((project, avail))
return pending return pending
with self.ParallelContext(): with self.ParallelContext():