Conversation
The root git ignore file has additional default items not to be deleted even though the corresponding aka the root jazz ignore file is deleted.
There was a problem hiding this comment.
Thank you @verhasi for your pull request 👍
See my comments, It looks like this change prevents deletion from any .gitignore, not just the root. Is my assumption wrong?
Would be cool if you could demonstrate your fix, by writing tests.
|
|
||
| private void gitCommit(PersonIdent ident, String comment) { | ||
| try { | ||
| initRootGitignore(rootDir); |
There was a problem hiding this comment.
Did you do this by accident? Shouldnt it have been by then already initialized through GitMigrator#init?
There was a problem hiding this comment.
It is intentional. Actually, the initRootGitignore rebuilds the content of the root .gitignore file based on the defaults and the .jazzignore in the root if it exists. It is easier to handle the changes, if any, here than in handleJazzignores function. In case the .jazzignore is deleted it results in a change of the .gitignore but in handleJazzignores function, you cannot add .gitignore to toAdd list as it was called with toRestore and can return files to be added to the toRemove list only.
| // change/add case | ||
| List<String> ignoreContent = JazzignoreTranslator.toGitignore(jazzIgnore); | ||
| Files.writeLines(new File(rootDir, gitignoreFile), ignoreContent, getCharset(), false); | ||
| if (!".gitignore".equals(gitignoreFile)) { |
There was a problem hiding this comment.
Can you extract this check into a method and extract .gitignore into a constant and replace it where its used like this as standalone string.
There was a problem hiding this comment.
The relativeFileNames contains not only the name of the file but also the path starting from the sandbox root. This guarantees that only in the root of the sandbox will the relativeFilename be ".gitignore"
To extract is a good idea. I was brave to be lazy as I found the similar string usage just in initRootGitignore method as well.
I am going to create the tests as you proposed.
The root git ignore file has additional default items not to be deleted even though the corresponding aka the root jazz ignore file is deleted.