Skip to content

Commit

Permalink
refactor: refactor git handler follow object oriented programming
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhenjia Zhou committed Nov 22, 2023
1 parent 606a1a0 commit 1da5c9a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/git/gitOperator.ts → src/git/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SimpleGit, StatusResult } from 'simple-git';
import {IGitHandler} from "./interface";

export class GitOperator {
export class GitHandler implements IGitHandler{
private git: SimpleGit;

constructor(git: SimpleGit) {
Expand Down
2 changes: 2 additions & 0 deletions src/git/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { IGitHandler } from './interface';
export {GitHandler } from './handler';
7 changes: 7 additions & 0 deletions src/git/interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {StatusResult} from "simple-git";

export interface IGitHandler {
checkForChanges(): Promise<StatusResult | null>;
commitChanges(status: StatusResult): Promise<void>;
pushChanges(): Promise<void>;
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {HexoIntegrationSettings} from "./types";
import {DEFAULT_SETTINGS} from "./constants";
import HexoIntegrationSettingsTab from "./settings/hexoIntegrationSettingsTab";
import {simpleGit, SimpleGit} from 'simple-git';
import {checkForChanges, commitChanges, pushChanges} from "./git/gitOperator";
import {checkForChanges, commitChanges, pushChanges} from "./git/handler";
import {createSystemSpecificSymlink, validateSymlink} from "./symlinks/symlinkOperation";

export default class HexoIntegrationPlugin extends Plugin {
Expand Down

0 comments on commit 1da5c9a

Please sign in to comment.