-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,7 @@ SortedSet<String> getExistingIgnoredFiles() { | |
|
||
private void gitCommit(PersonIdent ident, String comment) { | ||
try { | ||
initRootGitignore(rootDir); | ||
// add all untracked files | ||
Status status = git.status().call(); | ||
|
||
|
@@ -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 commentThe 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 commentThe 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" |
||
List<String> ignoreContent = JazzignoreTranslator.toGitignore(jazzIgnore); | ||
Files.writeLines(new File(rootDir, gitignoreFile), ignoreContent, getCharset(), false); | ||
additionalNames.add(gitignoreFile); | ||
} | ||
} else { | ||
// delete case | ||
new File(rootDir, gitignoreFile).delete(); | ||
// delete case except for root git ignore file | ||
if (!".gitignore".equals(gitignoreFile)) { | ||
new File(rootDir, gitignoreFile).delete(); | ||
additionalNames.add(gitignoreFile); | ||
} | ||
} | ||
additionalNames.add(gitignoreFile); | ||
} | ||
} | ||
// add additional modified name | ||
|
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.