Files
atom/src/git-repository-async.js
Daniel Hengeveld bc3e8f02ad isPathIgnored
2015-10-15 17:00:47 +02:00

39 lines
892 B
JavaScript

"use babel";
const Git = require('nodegit')
module.exports = class GitRepositoryAsync {
static open(path) {
// QUESTION: Should this wrap Git.Repository and reject with a nicer message?
return new GitRepositoryAsync(Git.Repository.open(path))
}
constructor (openPromise) {
this.repo = null
// this could be replaced with a function
this._opening = true
// Do I use this outside of tests?
openPromise.then( (repo) => {
this.repo = repo
this._opening = false
}).catch( (e) => {
this._opening = false
})
this.repoPromise = openPromise
}
getPath () {
return this.repoPromise.then( (repo) => {
return Promise.resolve(repo.path().replace(/\/$/, ''))
})
}
isPathIgnored(_path) {
return this.repoPromise.then( (repo) => {
return Promise.resolve(Git.Ignore.pathIsIgnored(repo, _path))
})
}
}