Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
9a2d5afc04 | |||
6404c8342a | |||
b14ae1d8a6 | |||
753bc49c4e |
67
changelog.md
Normal file
67
changelog.md
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-06-23 - 3.1.1 - fix(documentation)
|
||||||
|
Remove outdated changelog entries
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 2024-06-23 - 3.1.0 - gitrepo
|
||||||
|
Enhancements and fixes to GitRepo
|
||||||
|
|
||||||
|
- Enhance GitRepo to include commit date and version information
|
||||||
|
|
||||||
|
## 2024-06-22 - 3.0.3 to 3.0.4 - core & GitRepo
|
||||||
|
General updates and new feature addition
|
||||||
|
|
||||||
|
- Fixed core functionality
|
||||||
|
- Added diff function in GitRepo
|
||||||
|
|
||||||
|
## 2023-11-15 - 3.0.1 to 3.0.2 - core, tsconfig, npmextra
|
||||||
|
Minor updates and fixes
|
||||||
|
|
||||||
|
- Fixed core functionality
|
||||||
|
- Updated tsconfig and npmextra.json
|
||||||
|
|
||||||
|
## 2023-07-10 - 3.0.0 - core
|
||||||
|
Structural changes to organization scheme
|
||||||
|
|
||||||
|
- Switched to a new organizational scheme
|
||||||
|
|
||||||
|
## 2023-07-27 - 3.0.0 to 3.0.1 - core
|
||||||
|
Structural changes and updates
|
||||||
|
|
||||||
|
- Fixed core functionality
|
||||||
|
- Switched to new organizational scheme
|
||||||
|
|
||||||
|
## 2022-07-31 - 2.0.2 to 3.0.0 - core
|
||||||
|
Breaking changes and updates
|
||||||
|
|
||||||
|
- Switching to ESM for core
|
||||||
|
- Fixed core functionality
|
||||||
|
|
||||||
|
## 2021-10-22 - 1.0.18 to 2.0.1 - dependencies, core
|
||||||
|
Breaking changes and updates
|
||||||
|
|
||||||
|
- Switched to isomorphic git dependencies
|
||||||
|
- Fixed core functionality
|
||||||
|
|
||||||
|
## 2020-08-15 - 1.0.14 to 1.0.18 - core
|
||||||
|
Fixes
|
||||||
|
|
||||||
|
- Fixed core functionality in multiple patches
|
||||||
|
|
||||||
|
## 2019-06-18 - 1.0.5 to 1.0.10 - core
|
||||||
|
Fixes
|
||||||
|
|
||||||
|
- Fixed core functionality in multiple patches
|
||||||
|
|
||||||
|
## 2016-06-23 - 0.0.10 to 0.1.11 - gitlab & other fixes
|
||||||
|
Initial implementations and setup
|
||||||
|
|
||||||
|
- Fixed README and merge issues
|
||||||
|
- Updated gitlab.yml and CI settings
|
||||||
|
- Implemented new class approach and other updates
|
||||||
|
- Removed unnecessary imports, postinstall
|
||||||
|
- Added npmextra.json, CI tests, SSH key support
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartgit",
|
"name": "@push.rocks/smartgit",
|
||||||
"version": "3.0.4",
|
"version": "3.1.1",
|
||||||
"description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.",
|
"description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@ -38,6 +38,7 @@
|
|||||||
"@push.rocks/smartpromise": "^4.0.2",
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
"@push.rocks/smartshell": "^3.0.5",
|
"@push.rocks/smartshell": "^3.0.5",
|
||||||
"@push.rocks/smartstring": "^4.0.15",
|
"@push.rocks/smartstring": "^4.0.15",
|
||||||
|
"@push.rocks/smarttime": "^4.0.6",
|
||||||
"@types/diff": "^5.2.1",
|
"@types/diff": "^5.2.1",
|
||||||
"@types/minimatch": "^5.1.2",
|
"@types/minimatch": "^5.1.2",
|
||||||
"diff": "^5.2.0",
|
"diff": "^5.2.0",
|
||||||
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -26,6 +26,9 @@ importers:
|
|||||||
'@push.rocks/smartstring':
|
'@push.rocks/smartstring':
|
||||||
specifier: ^4.0.15
|
specifier: ^4.0.15
|
||||||
version: 4.0.15
|
version: 4.0.15
|
||||||
|
'@push.rocks/smarttime':
|
||||||
|
specifier: ^4.0.6
|
||||||
|
version: 4.0.6
|
||||||
'@types/diff':
|
'@types/diff':
|
||||||
specifier: ^5.2.1
|
specifier: ^5.2.1
|
||||||
version: 5.2.1
|
version: 5.2.1
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartgit',
|
name: '@push.rocks/smartgit',
|
||||||
version: '3.0.4',
|
version: '3.1.1',
|
||||||
description: 'A smart wrapper for nodegit that simplifies Git operations in Node.js.'
|
description: 'A smart wrapper for nodegit that simplifies Git operations in Node.js.'
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,8 @@ export class GitRepo {
|
|||||||
|
|
||||||
// Handle modified files
|
// Handle modified files
|
||||||
if (head !== 0 && workdir !== 0 && head !== workdir) {
|
if (head !== 0 && workdir !== 0 && head !== workdir) {
|
||||||
headContent = await plugins.isomorphicGit.readBlob({
|
headContent = await plugins.isomorphicGit
|
||||||
|
.readBlob({
|
||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
dir: this.repoDir,
|
dir: this.repoDir,
|
||||||
oid: await plugins.isomorphicGit.resolveRef({
|
oid: await plugins.isomorphicGit.resolveRef({
|
||||||
@ -140,19 +141,27 @@ export class GitRepo {
|
|||||||
ref: 'HEAD',
|
ref: 'HEAD',
|
||||||
}),
|
}),
|
||||||
filepath,
|
filepath,
|
||||||
}).then(result => new TextDecoder().decode(result.blob));
|
})
|
||||||
|
.then((result) => new TextDecoder().decode(result.blob));
|
||||||
|
|
||||||
workdirContent = await this.smartgitRef.envDeps.fs.promises.readFile(plugins.path.join(this.repoDir, filepath), 'utf8');
|
workdirContent = await this.smartgitRef.envDeps.fs.promises.readFile(
|
||||||
|
plugins.path.join(this.repoDir, filepath),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle added files
|
// Handle added files
|
||||||
if (head === 0 && workdir !== 0) {
|
if (head === 0 && workdir !== 0) {
|
||||||
workdirContent = await this.smartgitRef.envDeps.fs.promises.readFile(plugins.path.join(this.repoDir, filepath), 'utf8');
|
workdirContent = await this.smartgitRef.envDeps.fs.promises.readFile(
|
||||||
|
plugins.path.join(this.repoDir, filepath),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle deleted files
|
// Handle deleted files
|
||||||
if (head !== 0 && workdir === 0) {
|
if (head !== 0 && workdir === 0) {
|
||||||
headContent = await plugins.isomorphicGit.readBlob({
|
headContent = await plugins.isomorphicGit
|
||||||
|
.readBlob({
|
||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
dir: this.repoDir,
|
dir: this.repoDir,
|
||||||
oid: await plugins.isomorphicGit.resolveRef({
|
oid: await plugins.isomorphicGit.resolveRef({
|
||||||
@ -161,11 +170,17 @@ export class GitRepo {
|
|||||||
ref: 'HEAD',
|
ref: 'HEAD',
|
||||||
}),
|
}),
|
||||||
filepath,
|
filepath,
|
||||||
}).then(result => new TextDecoder().decode(result.blob));
|
})
|
||||||
|
.then((result) => new TextDecoder().decode(result.blob));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headContent || workdirContent) {
|
if (headContent || workdirContent) {
|
||||||
const diff = plugins.diff.createTwoFilesPatch(filepath, filepath, headContent, workdirContent);
|
const diff = plugins.diff.createTwoFilesPatch(
|
||||||
|
filepath,
|
||||||
|
filepath,
|
||||||
|
headContent,
|
||||||
|
workdirContent
|
||||||
|
);
|
||||||
diffs.push(diff);
|
diffs.push(diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,13 +189,40 @@ export class GitRepo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all commit messages
|
* Get all commit messages with their dates and package.json version at each commit
|
||||||
*/
|
*/
|
||||||
public async getAllCommitMessages(): Promise<string[]> {
|
public async getAllCommitMessages(): Promise<
|
||||||
|
{ date: string; version: string; message: string }[]
|
||||||
|
> {
|
||||||
const commits = await plugins.isomorphicGit.log({
|
const commits = await plugins.isomorphicGit.log({
|
||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
dir: this.repoDir,
|
dir: this.repoDir,
|
||||||
});
|
});
|
||||||
return commits.map(commit => commit.commit.message);
|
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
for (const commit of commits) {
|
||||||
|
let version = 'unknown';
|
||||||
|
try {
|
||||||
|
const packageJsonBlob = await plugins.isomorphicGit.readBlob({
|
||||||
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
|
dir: this.repoDir,
|
||||||
|
oid: commit.oid,
|
||||||
|
filepath: 'package.json',
|
||||||
|
});
|
||||||
|
const packageJson = JSON.parse(new TextDecoder().decode(packageJsonBlob.blob));
|
||||||
|
version = packageJson.version;
|
||||||
|
} catch (error) {
|
||||||
|
// If package.json does not exist or any error occurs, leave version as 'unknown'
|
||||||
|
}
|
||||||
|
|
||||||
|
results.push({
|
||||||
|
date: new plugins.smarttime.ExtendedDate(commit.commit.committer.timestamp * 1000).exportToHyphedSortableDate(),
|
||||||
|
version: version,
|
||||||
|
message: commit.commit.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,9 @@ import * as smartfile from '@push.rocks/smartfile';
|
|||||||
import * as smartpath from '@push.rocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
import * as smartpromise from '@push.rocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartstring from '@push.rocks/smartstring';
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
|
import * as smarttime from '@push.rocks/smarttime';
|
||||||
|
|
||||||
export { smartenv, smartfile, smartpath, smartpromise, smartstring };
|
export { smartenv, smartfile, smartpath, smartpromise, smartstring, smarttime };
|
||||||
|
|
||||||
// third party
|
// third party
|
||||||
import * as diff from 'diff';
|
import * as diff from 'diff';
|
||||||
|
Reference in New Issue
Block a user