-
Notifications
You must be signed in to change notification settings - Fork 34
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
Never delete the root gitignore file #51
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -212,6 +212,7 @@ String getWorkItemTexts(List<WorkItem> workItems) { | |||
|
|||
private void gitCommit(PersonIdent ident, String comment) { | |||
try { | |||
initRootGitignore(rootDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you do this by accident? Shouldnt it have been by then already initialized through GitMigrator#init?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -313,13 +314,18 @@ private void handleJazzignores(Set<String> relativeFileNames) { | |||
String gitignoreFile = matcher.group(1).concat(".gitignore"); | |||
if (jazzIgnore.exists()) { | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.