mirror of
https://github.com/atom/atom.git
synced 2026-01-27 07:47:58 -05:00
isPathNew
This commit is contained in:
@@ -91,7 +91,7 @@ fdescribe "GitRepositoryAsync", ->
|
||||
|
||||
beforeEach ->
|
||||
workingDirPath = copyRepository()
|
||||
repo = new GitRepositoryAsync.open(workingDirPath)
|
||||
repo = GitRepositoryAsync.open(workingDirPath)
|
||||
filePath = path.join(workingDirPath, 'a.txt')
|
||||
newPath = path.join(workingDirPath, 'new-path.txt')
|
||||
fs.writeFileSync(newPath, "i'm new here")
|
||||
@@ -136,22 +136,31 @@ fdescribe "GitRepositoryAsync", ->
|
||||
runs ->
|
||||
expect(onSuccess.mostRecentCall.args[0]).toBeFalsy()
|
||||
|
||||
xdescribe ".isPathNew(path)", ->
|
||||
describe ".isPathNew(path)", ->
|
||||
[filePath, newPath] = []
|
||||
|
||||
beforeEach ->
|
||||
workingDirPath = copyRepository()
|
||||
repo = new GitRepository(workingDirPath)
|
||||
repo = GitRepositoryAsync.open(workingDirPath)
|
||||
filePath = path.join(workingDirPath, 'a.txt')
|
||||
newPath = path.join(workingDirPath, 'new-path.txt')
|
||||
fs.writeFileSync(newPath, "i'm new here")
|
||||
|
||||
xdescribe "when the path is unstaged", ->
|
||||
describe "when the path is unstaged", ->
|
||||
it "returns true if the path is new", ->
|
||||
expect(repo.isPathNew(newPath)).toBeTruthy()
|
||||
onSuccess = jasmine.createSpy('onSuccess')
|
||||
waitsForPromise ->
|
||||
repo.isPathNew(newPath).then(onSuccess)
|
||||
runs ->
|
||||
expect(onSuccess.mostRecentCall.args[0]).toBeTruthy()
|
||||
|
||||
it "returns false if the path isn't new", ->
|
||||
expect(repo.isPathNew(filePath)).toBeFalsy()
|
||||
onSuccess = jasmine.createSpy('onSuccess')
|
||||
waitsForPromise ->
|
||||
repo.isPathModified(newPath).then(onSuccess)
|
||||
runs ->
|
||||
expect(onSuccess.mostRecentCall.args[0]).toBeFalsy()
|
||||
|
||||
|
||||
xdescribe ".checkoutHead(path)", ->
|
||||
[filePath] = []
|
||||
|
||||
@@ -37,16 +37,32 @@ module.exports = class GitRepositoryAsync {
|
||||
})
|
||||
}
|
||||
|
||||
isPathModified(_path) {
|
||||
_filterStatusesByPath(_path) {
|
||||
// Surely I'm missing a built-in way to do this
|
||||
var basePath = null
|
||||
return this.repoPromise.then( (repo) => {
|
||||
basePath = repo.workdir()
|
||||
return repo.getStatus()
|
||||
}).then( (statuses) => {
|
||||
console.log(statuses.map(function(x){return x.path()}));
|
||||
return statuses.filter(function (status) {
|
||||
return _path == path.join(basePath, status.path())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
isPathModified(_path) {
|
||||
return this._filterStatusesByPath(_path).then(function(statuses) {
|
||||
ret = statuses.filter((status)=> {
|
||||
return _path == path.join(basePath, status.path()) && (status.isModified() || status.isDeleted())
|
||||
return status.isModified() || status.isDeleted()
|
||||
}).length > 0
|
||||
return Promise.resolve(ret)
|
||||
})
|
||||
}
|
||||
|
||||
isPathNew(_path) {
|
||||
return this._filterStatusesByPath(_path).then(function(statuses) {
|
||||
ret = statuses.filter((status)=> {
|
||||
return status.isNew()
|
||||
}).length > 0
|
||||
return Promise.resolve(ret)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user