Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix git_add resource handling wrt. deleted files
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).
- Loading branch information
Showing
13 changed files
with
673 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
# add single file | ||
resource "git_add" "file" { | ||
resource "git_add" "single_file" { | ||
directory = "/path/to/git/repository" | ||
exact_path = "path/to/file/in/repository" | ||
add_paths = ["path/to/file/in/repository"] | ||
} | ||
|
||
# add all files in directory and its subdirectory recursively | ||
resource "git_add" "directory" { | ||
resource "git_add" "single_directory" { | ||
directory = "/path/to/git/repository" | ||
exact_path = "path/to/directory/in/repository" | ||
add_paths = ["path/to/directory/in/repository"] | ||
} | ||
|
||
# add files matching pattern | ||
resource "git_add" "glob" { | ||
resource "git_add" "glob_pattern" { | ||
directory = "/path/to/git/repository" | ||
glob_path = "path/*/in/repo*" | ||
add_paths = ["path/*/in/repo*"] | ||
} | ||
|
||
# add all modified files | ||
resource "git_add" "all" { | ||
# mix exact paths and glob patterns | ||
resource "git_add" "glob_pattern" { | ||
directory = "/path/to/git/repository" | ||
all = true | ||
add_paths = [ | ||
"path/*/in/repo*", | ||
"another/path/to/file/here", | ||
"this/could/be/a/directory", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.