Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix git_add resource #46

Merged
merged 4 commits into from Sep 9, 2022
Merged

fix git_add resource #46

merged 4 commits into from Sep 9, 2022

Conversation

sebhoss
Copy link
Member

@sebhoss sebhoss commented Sep 9, 2022

This is a breaking change!

  • The all attribute was removed entirely. The git_add resource now always adds files to the index even if those files are deleted.
  • The exact_path and glob_path attributes were merged into add_paths which is a list of strings and accepts both exact paths to files/directories as well as glob patterns or a mixture of them.
  • The id attribute now contains the unix nanoseconds of the last addition.

These changes were necessary because upstream go-git is buggy when it comes to adding 'all' files (see go-git/go-git#223). The workaround implemented here uses worktree.Add instead of worktree.AddWithOptions which seems to work as expected. Acceptance tests with terratest were added that verify the wanted behavior.

Sebastian Hoß added 4 commits September 9, 2022 13:45
Using worktree.AddWithOptions does not work as documented:

1) Setting All to true always adds all added/modified files, even if Path or Glob is specified
2) Setting All to true does not add deleted files even

In order to work around this, worktree.Add is called instead, and we are iterating manually over the current worktree.Status to get all files that somehow changed (including the deleted ones).
@sebhoss sebhoss added the enhancement New feature or request label Sep 9, 2022
@sebhoss sebhoss self-assigned this Sep 9, 2022
@sebhoss sebhoss merged commit 3960cd9 into main Sep 9, 2022
@sebhoss sebhoss deleted the resource_tests branch September 9, 2022 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant