Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
98d1f8aea2 | |||
1f542367e6 | |||
201a5014ed | |||
6cc245ae7e | |||
1377fb6eb7 | |||
daf8c80513 | |||
46fce49356 | |||
8616613a95 | |||
352e4d8e96 | |||
c2105ce78f | |||
2864fc5507 |
@ -1,5 +1,5 @@
|
|||||||
# gitzone ci_default
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@ -50,22 +50,10 @@ testLTS:
|
|||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install lts
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
"coverageTreshold": 71
|
"coverageTreshold": 71
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"npmAccessLevel": "public"
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"module": {
|
"module": {
|
||||||
|
401
package-lock.json
generated
401
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartgit",
|
"name": "@pushrocks/smartgit",
|
||||||
"version": "1.0.7",
|
"version": "1.0.13",
|
||||||
"description": "smart wrapper for nodegit",
|
"description": "smart wrapper for nodegit",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
@ -24,20 +24,20 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^7.0.2",
|
"@pushrocks/smartfile": "^7.0.4",
|
||||||
"@pushrocks/smartpath": "^4.0.1",
|
"@pushrocks/smartpath": "^4.0.1",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@pushrocks/smartshell": "^2.0.23",
|
"@pushrocks/smartshell": "^2.0.23",
|
||||||
"@pushrocks/smartstring": "^3.0.10",
|
"@pushrocks/smartstring": "^3.0.10",
|
||||||
"@types/minimatch": "^3.0.3",
|
"@types/minimatch": "^3.0.3",
|
||||||
"@types/nodegit": "^0.24.8",
|
"@types/nodegit": "^0.24.10",
|
||||||
"nodegit": "^0.24.3"
|
"nodegit": "^0.25.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"@pushrocks/tapbundle": "^3.0.9",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"tslint": "^5.17.0",
|
"tslint": "^5.19.0",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import * as smartgit from '../ts/index';
|
import * as smartgit from '../ts/index';
|
||||||
|
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
const testRepoDir = path.join(__dirname, '../.nogit/testrepo');
|
||||||
|
|
||||||
|
tap.test('should create a new repo at .nogit', async () => {
|
||||||
|
const gitRepo = await smartgit.GitRepo.fromCreatingRepoInDir(testRepoDir);
|
||||||
|
})
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -8,7 +8,7 @@ export class GitRepo {
|
|||||||
/**
|
/**
|
||||||
* creates a new GitRepo Instance after cloning a project
|
* creates a new GitRepo Instance after cloning a project
|
||||||
*/
|
*/
|
||||||
public static async createRepoFromClone(fromArg: string, toArg: string): Promise<GitRepo> {
|
public static async fromCloningIntoDir(fromArg: string, toArg: string): Promise<GitRepo> {
|
||||||
const dirArg = plugins.path.resolve(toArg);
|
const dirArg = plugins.path.resolve(toArg);
|
||||||
const ngRespository = await plugins.nodegit.Clone.clone(fromArg, toArg, {
|
const ngRespository = await plugins.nodegit.Clone.clone(fromArg, toArg, {
|
||||||
bare: 0,
|
bare: 0,
|
||||||
@ -17,13 +17,13 @@ export class GitRepo {
|
|||||||
return new GitRepo(ngRespository);
|
return new GitRepo(ngRespository);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async createNewRepoInDir(dirArg: string): Promise<GitRepo> {
|
public static async fromCreatingRepoInDir(dirArg: string): Promise<GitRepo> {
|
||||||
dirArg = plugins.path.resolve(dirArg);
|
dirArg = plugins.path.resolve(dirArg);
|
||||||
const ngRepository = await plugins.nodegit.Repository.init(dirArg, 0);
|
const ngRepository = await plugins.nodegit.Repository.init(dirArg, 0);
|
||||||
return new GitRepo(ngRepository);
|
return new GitRepo(ngRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async openRepoAt(dirArg: string) {
|
public static async fromOpeningRepoDir(dirArg: string) {
|
||||||
dirArg = plugins.path.resolve(dirArg);
|
dirArg = plugins.path.resolve(dirArg);
|
||||||
const ngRepository = await plugins.nodegit.Repository.open(dirArg);
|
const ngRepository = await plugins.nodegit.Repository.open(dirArg);
|
||||||
return new GitRepo(ngRepository);
|
return new GitRepo(ngRepository);
|
||||||
@ -43,12 +43,32 @@ export class GitRepo {
|
|||||||
return this.nodegitRepo.getRemotes();
|
return this.nodegitRepo.getRemotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ensures the existance of a remote within a repository
|
||||||
|
* @param remoteNameArg
|
||||||
|
* @param remoteUrlArg
|
||||||
|
*/
|
||||||
|
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
|
||||||
|
const existingUrl = await this.getUrlForRemote(remoteNameArg);
|
||||||
|
if (existingUrl === remoteUrlArg) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (existingUrl) {
|
||||||
|
await plugins.nodegit.Remote.delete(this.nodegitRepo, remoteNameArg);
|
||||||
|
}
|
||||||
|
await plugins.nodegit.Remote.create(this.nodegitRepo, remoteNameArg, remoteUrlArg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the url for a specific remote
|
* gets the url for a specific remote
|
||||||
*/
|
*/
|
||||||
public async getUrlForRemote(remoteName: string) {
|
public async getUrlForRemote(remoteName: string): Promise<string> {
|
||||||
const ngRemote = await this.nodegitRepo.getRemote(remoteName);
|
const ngRemote = await this.nodegitRepo.getRemote(remoteName);
|
||||||
return ngRemote.url;
|
if (ngRemote) {
|
||||||
|
return ngRemote.url();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pushBranchToRemote(branchName: string, remoteName: string) {
|
public async pushBranchToRemote(branchName: string, remoteName: string) {
|
||||||
|
@ -11,6 +11,6 @@ import * as smartstring from '@pushrocks/smartstring';
|
|||||||
export { smartfile, smartpath, smartpromise, smartstring };
|
export { smartfile, smartpath, smartpromise, smartstring };
|
||||||
|
|
||||||
// third party
|
// third party
|
||||||
import * as nodegit from 'nodegit';
|
import nodegit from 'nodegit';
|
||||||
|
|
||||||
export { nodegit };
|
export { nodegit };
|
||||||
|
Reference in New Issue
Block a user