Check git fsck output when importing projects
This is a sanity check to properly log when repos are corrupt and not able to be imported into Gerrit. The import will fail either way but at least with this change in place we will get more direct logging of the reason for the import failure. Change-Id: Ibb1839329065e5d4a9747f95ff21029148801874
This commit is contained in:
parent
42b1cc8850
commit
533faad18d
|
@ -457,6 +457,16 @@ def update_local_copy(repo_path, track_upstream, git_opts, ssh_env):
|
|||
git_command(repo_path, "checkout -B master origin/master")
|
||||
|
||||
|
||||
def fsck_repo(repo_path):
|
||||
rc, out = git_command_output(repo_path, 'fsck --full')
|
||||
# Check for non zero return code or warnings which should
|
||||
# be treated as errors. In this case zeroPaddedFilemodes
|
||||
# will not be accepted by Gerrit/jgit but are accepted by C git.
|
||||
if rc != 0 or 'zeroPaddedFilemode' in out:
|
||||
log.error('git fsck of %s failed:\n%s' % (repo_path, out))
|
||||
raise Exception('git fsck failed not importing')
|
||||
|
||||
|
||||
def push_to_gerrit(repo_path, project, push_string, remote_url, ssh_env):
|
||||
try:
|
||||
git_command(repo_path, push_string % remote_url, env=ssh_env)
|
||||
|
@ -650,6 +660,8 @@ def main():
|
|||
update_local_copy(
|
||||
repo_path, track_upstream, git_opts, ssh_env)
|
||||
|
||||
fsck_repo(repo_path)
|
||||
|
||||
description = (
|
||||
find_description_override(repo_path) or description)
|
||||
|
||||
|
|
Loading…
Reference in New Issue