2023-07-27 11:45:48 +00:00
|
|
|
import { tap, expect } from '@push.rocks/tapbundle';
|
2022-07-31 13:14:18 +00:00
|
|
|
import * as smartgit from '../ts/index.js';
|
2016-06-12 14:46:59 +00:00
|
|
|
|
2023-07-27 11:45:48 +00:00
|
|
|
import * as smartpath from '@push.rocks/smartpath';
|
2019-06-20 12:10:42 +00:00
|
|
|
import * as path from 'path';
|
|
|
|
|
2021-10-21 17:09:14 +00:00
|
|
|
let testSmartgitInstance: smartgit.Smartgit;
|
2024-06-22 00:44:19 +00:00
|
|
|
const packageDir = path.join(smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
|
|
|
const testRepoDir = path.join(packageDir, './.nogit/testrepo');
|
|
|
|
const testRepoDirSmartfile = path.join(packageDir, './.nogit/pushrocks_smartfile');
|
2021-10-21 17:09:14 +00:00
|
|
|
|
|
|
|
tap.test('should create a valid smartgit instance', async () => {
|
|
|
|
testSmartgitInstance = new smartgit.Smartgit();
|
|
|
|
await testSmartgitInstance.init();
|
2022-07-31 13:14:18 +00:00
|
|
|
expect(testSmartgitInstance).toBeInstanceOf(smartgit.Smartgit);
|
2022-07-31 13:18:04 +00:00
|
|
|
});
|
2019-06-20 12:10:42 +00:00
|
|
|
|
|
|
|
tap.test('should create a new repo at .nogit', async () => {
|
2021-10-21 17:09:14 +00:00
|
|
|
const gitRepo = await testSmartgitInstance.createRepoByOpen(testRepoDir);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should clone a repo', async () => {
|
2022-07-31 13:18:04 +00:00
|
|
|
const gitRepo = await testSmartgitInstance.createRepoByClone(
|
2023-07-27 11:45:48 +00:00
|
|
|
'https://gitlab.com/push.rocks/smartfile.git',
|
2022-07-31 13:18:04 +00:00
|
|
|
testRepoDirSmartfile
|
|
|
|
);
|
2020-08-15 13:46:56 +00:00
|
|
|
});
|
2019-06-20 12:10:42 +00:00
|
|
|
|
2024-06-22 00:44:19 +00:00
|
|
|
tap.test('should open a repo', async () => {
|
|
|
|
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir);
|
|
|
|
const diff = await gitRepo.getUncommittedDiff([
|
|
|
|
'pnpm-lock.yaml',
|
|
|
|
]);
|
|
|
|
console.log(diff);
|
|
|
|
});
|
|
|
|
|
2024-06-22 08:01:15 +00:00
|
|
|
tap.test('should get the diff to HEAD', async () => {
|
|
|
|
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir);
|
|
|
|
const diff = await gitRepo.getUncommittedDiff([
|
|
|
|
'pnpm-lock.yaml',
|
|
|
|
]);
|
|
|
|
console.log(diff);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should print all commit messages', async () => {
|
|
|
|
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir);
|
|
|
|
const commitMessages = await gitRepo.getAllCommitMessages();
|
|
|
|
console.log(commitMessages);
|
|
|
|
});
|
|
|
|
|
2023-11-15 14:15:18 +00:00
|
|
|
await tap.start();
|