-
Notifications
You must be signed in to change notification settings - Fork 637
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
remove unused imports, make clicktests more reliable, fix git rev-parse with bare repositories, fix crash when directory gets deleted #1263
Changes from 5 commits
6eef1cf
3ab0146
2c7b43e
35be732
4a90cb0
dba7f02
efcebf5
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 |
---|---|---|
|
@@ -10,7 +10,6 @@ const gitPromise = require('./git-promise'); | |
const fs = require('./utils/fs-async'); | ||
const ignore = require('ignore'); | ||
const Bluebird = require('bluebird'); | ||
const crypto = require('crypto'); | ||
|
||
const isMac = /^darwin/.test(process.platform); | ||
const isWindows = /^win/.test(process.platform); | ||
|
@@ -72,7 +71,8 @@ exports.registerApi = (env) => { | |
}); | ||
} | ||
}).then(() => { | ||
socket.watcher.push(fs.watch(pathToWatch, options || {}, (event, filename) => { | ||
const watcher = fs.watch(pathToWatch, options || {}); | ||
watcher.on('change', (event, filename) => { | ||
if (!filename) return; | ||
const filePath = path.join(subfolderPath, filename); | ||
winston.debug(`File change: ${filePath}`); | ||
|
@@ -81,7 +81,11 @@ exports.registerApi = (env) => { | |
emitGitDirectoryChanged(socket.watcherPath); | ||
emitWorkingTreeChanged(socket.watcherPath); | ||
} | ||
})); | ||
}); | ||
watcher.on('error', (err) => { | ||
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. Listening for watcher errors is required otherwise the ungit process crashes when errors occur. Steps to reproduce (on windows at least I got a permission error):
|
||
winston.warn(`Error watching ${pathToWatch}: `, JSON.stringify(err)); | ||
}); | ||
socket.watcher.push(watcher); | ||
}); | ||
}; | ||
|
||
|
@@ -556,7 +560,7 @@ exports.registerApi = (env) => { | |
.then((baseRepoPath) => { | ||
return { path: path.resolve(baseRepoPath.trim()) }; | ||
}).catch((e) => { | ||
if (e.errorCode === 'not-a-repository') { | ||
if (e.errorCode === 'not-a-repository' || e.errorCode === 'must-be-in-working-tree') { | ||
return {}; | ||
campersau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
throw e; | ||
|
@@ -717,13 +721,11 @@ exports.registerApi = (env) => { | |
app.post(`${exports.pathPrefix}/testing/git`, ensureAuthenticated, (req, res) => { | ||
jsonResultOrFailProm(res, gitPromise(req.body.command, req.body.repo)) | ||
}); | ||
app.post(`${exports.pathPrefix}/testing/cleanup`, ensureAuthenticated, (req, res) => { | ||
//winston.info('Cleaned up: ' + JSON.stringify(cleaned)); | ||
res.json({ result: temp.cleanup() }); | ||
}); | ||
app.post(`${exports.pathPrefix}/testing/shutdown`, ensureAuthenticated, (req, res) => { | ||
res.json({}); | ||
process.exit(); | ||
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. Exiting the process during a request / response can result in connection reset errors on the client which can make tests fail. |
||
app.post(`${exports.pathPrefix}/testing/cleanup`, (req, res) => { | ||
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. Removed 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. Are these endpoints still available when running ungit outside of tests? 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. |
||
temp.cleanup((err, cleaned) => { | ||
winston.info('Cleaned up: ' + JSON.stringify(cleaned)); | ||
res.json({ result: cleaned }); | ||
}); | ||
}); | ||
} | ||
}; |
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.
Instead of exiting the process from inside, the child process gets killed from the outside. (See above for reasons.)