Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions services/datalad/datalad_service/common/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ async def git_commit(
sentry_sdk.capture_exception(e)
logger.error(f'Failed to read index after git-annex add: {e}')
raise OpenNeuroGitError(f'Failed to read index: {e}') from e
# Ensure non-annexed files are smudged, e.g., update end-of-lines
# but do not "fix" unrelated paths
repo.index.add_all(file_paths)
return await git_commit_index(repo, author, message, parents)


Expand All @@ -173,10 +176,14 @@ async def git_commit_index(
committer = pygit2.Signature(COMMITTER_NAME, COMMITTER_EMAIL)
if not author:
author = committer
if parents is None:
parent_commits = [str(repo.head.target)]
else:
parent_commits = parents

parent_commits = [repo.head.target] if parents is None else parents
if len(parent_commits) == 1 and not any(
repo.index.diff_to_tree(repo.get(parent_commits[0]).tree)
):
# No changes to commit
return

tree = repo.index.write_tree()
commit = repo.create_commit(
'refs/heads/main', author, committer, message, tree, parent_commits
Expand Down