added some tests

This commit is contained in:
2016-11-22 22:22:24 +01:00
parent 29d176bafa
commit 15c331690b
9 changed files with 99 additions and 36 deletions

View File

@ -24,7 +24,8 @@ export let createRepoFromClone = (fromArg: string, toArg: string) => {
export let createRepoFromInit = (destinationDirArg: string) => {
let done = q.defer<GitRepo>()
plugins.smartfile.fs.ensureDir(destinationDirArg)
plugins.shelljs.exec(`cd destinationDirArg && git init`)
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`)
let newRepo = new GitRepo(destinationDirArg)
done.resolve(newRepo)
return done.promise
}

View File

@ -8,17 +8,16 @@ export class GitRepo {
repoBase: string
constructor(repoBaseArg: string) {
this.repoBase = repoBaseArg
if (!this.check()) {
throw new Error('no valid git repo')
}
}
/**
* checks if the Repo is valid
*/
check(): boolean {
try {
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
} catch (err) {
return false
}
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
}
/**
@ -58,10 +57,10 @@ export class GitRepo {
/**
* list remotes for a Gip
*/
remoteList(dirPathArg) {
remoteList() {
let done = q.defer()
let remotes = {}
plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`)
plugins.shelljs.exec(`cd ${this.repoBase} && git remote -v`)
done.resolve(remotes)
return done.promise
};