{"id":13395467,"url":"https://github.com/Brooooooklyn/simple-git","last_synced_at":"2025-03-13T21:31:43.906Z","repository":{"id":40447959,"uuid":"469437290","full_name":"Brooooooklyn/simple-git","owner":"Brooooooklyn","description":"Simple and fast git helper functions.","archived":false,"fork":false,"pushed_at":"2024-10-18T22:43:39.000Z","size":9534,"stargazers_count":157,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-21T04:36:29.060Z","etag":null,"topics":["libgit2","libgit2-library","napi","napi-rs"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Brooooooklyn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Brooooooklyn"]}},"created_at":"2022-03-13T17:04:22.000Z","updated_at":"2024-10-18T22:43:42.000Z","dependencies_parsed_at":"2023-12-05T08:23:57.924Z","dependency_job_id":"5cef6aaa-914e-486d-a9f1-cc62ff3025d6","html_url":"https://github.com/Brooooooklyn/simple-git","commit_stats":{"total_commits":78,"total_committers":2,"mean_commits":39.0,"dds":0.3205128205128205,"last_synced_commit":"f021e2a332100ff0a3277e7ded3cddfff6fc8c54"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brooooooklyn%2Fsimple-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brooooooklyn%2Fsimple-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brooooooklyn%2Fsimple-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brooooooklyn%2Fsimple-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Brooooooklyn","download_url":"https://codeload.github.com/Brooooooklyn/simple-git/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221332835,"owners_count":16799526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["libgit2","libgit2-library","napi","napi-rs"],"created_at":"2024-07-30T17:02:00.604Z","updated_at":"2024-10-25T09:30:21.121Z","avatar_url":"https://github.com/Brooooooklyn.png","language":"Rust","readme":"# `@napi-rs/simple-git`\n\n![https://github.com/Brooooooklyn/simple-git/actions](https://github.com/Brooooooklyn/simple-git/workflows/CI/badge.svg)\n![](https://img.shields.io/npm/dm/@napi-rs/simple-git.svg?sanitize=true)\n[![Install size](https://packagephobia.com/badge?p=@napi-rs/simple-git)](https://packagephobia.com/result?p=@napi-rs/simple-git)\n\n## `Repository`\n\n### Usage\n\n```ts\nimport { Repository } from '@napi-rs/simple-git'\n\nRepository.init('/path/to/repo') // init a git repository\n\nconst repo = new Repository('/path/to/repo') // Open an existed repo\n\nconst timestamp = new Date(repo.getFileLatestModifiedDate('build.rs')) // get the latest modified timestamp of a `build.rs`\nconsole.log(timestamp) // 2022-03-13T12:47:47.920Z\n\nconst timestampFromAsync = new Date(await repo.getFileLatestModifiedDateAsync('build.rs')) // Async version of `getFileLatestModifiedDate`\n\nconsole.log(timestamp) // 2022-03-13T12:47:47.920Z\n```\n\n### API\n\n```ts\nexport class Repository {\n  static init(p: string): Repository\n  constructor(gitDir: string)\n  /** Retrieve and resolve the reference pointed at by HEAD. */\n  head(): Reference\n  getFileLatestModifiedDate(filepath: string): number\n  getFileLatestModifiedDateAsync(filepath: string, signal?: AbortSignal | undefined | null): Promise\u003cunknown\u003e\n}\n```\n\n## `Reference`\n\n### Usage\n\n```ts\nimport { Repository } from '@napi-rs/simple-git'\n\nconst repo = new Repository('/path/to/repo') // Open an existed repo\n\nconst headReference = repo.head()\n\nheadReference.shorthand() // 'main'\nheadReference.name() // 'refs/heads/main'\nheadReference.target() // 7a1256e2f847f395219980bc06c6dadf0148f18d\n```\n\n### API\n\n```ts\n/** An enumeration of all possible kinds of references. */\nexport const enum ReferenceType {\n  /** A reference which points at an object id. */\n  Direct = 0,\n  /** A reference which points at another reference. */\n  Symbolic = 1,\n  Unknown = 2\n}\nexport class Reference {\n  /**\n   * Ensure the reference name is well-formed.\n   *\n   * Validation is performed as if [`ReferenceFormat::ALLOW_ONELEVEL`]\n   * was given to [`Reference.normalize_name`]. No normalization is\n   * performed, however.\n   *\n   * ```ts\n   * import { Reference } from '@napi-rs/simple-git'\n   *\n   * console.assert(Reference.is_valid_name(\"HEAD\"));\n   * console.assert(Reference.is_valid_name(\"refs/heads/main\"));\n   *\n   * // But:\n   * console.assert(!Reference.is_valid_name(\"main\"));\n   * console.assert(!Reference.is_valid_name(\"refs/heads/*\"));\n   * console.assert(!Reference.is_valid_name(\"foo//bar\"));\n   * ```\n   */\n  static isValidName(name: string): boolean\n  /** Check if a reference is a local branch. */\n  isBranch(): boolean\n  /** Check if a reference is a note. */\n  isNote(): boolean\n  /** Check if a reference is a remote tracking branch */\n  isRemote(): boolean\n  /** Check if a reference is a tag */\n  isTag(): boolean\n  kind(): ReferenceType\n  /**\n   * Get the full name of a reference.\n   *\n   * Returns `None` if the name is not valid utf-8.\n   */\n  name(): string | undefined | null\n  /**\n   * Get the full shorthand of a reference.\n   *\n   * This will transform the reference name into a name \"human-readable\"\n   * version. If no shortname is appropriate, it will return the full name.\n   *\n   * Returns `None` if the shorthand is not valid utf-8.\n   */\n  shorthand(): string | undefined | null\n  /**\n   * Get the OID pointed to by a direct reference.\n   *\n   * Only available if the reference is direct (i.e. an object id reference,\n   * not a symbolic one).\n   */\n  target(): string | undefined | null\n  /**\n   * Return the peeled OID target of this reference.\n   *\n   * This peeled OID only applies to direct references that point to a hard\n   * Tag object: it is the result of peeling such Tag.\n   */\n  targetPeel(): string | undefined | null\n  /**\n   * Get full name to the reference pointed to by a symbolic reference.\n   *\n   * May return `None` if the reference is either not symbolic or not a\n   * valid utf-8 string.\n   */\n  symbolicTarget(): string | undefined | null\n}\n```\n\n## Performance\n\nCompared with the `exec` function, which gets the file's latest modified date by spawning a child process. Getting the latest modified date from the file 1000 times:\n\n```\nChild process took 1.9s\n@napi-rs/simple-git took 65ms\n```\n","funding_links":["https://github.com/sponsors/Brooooooklyn"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBrooooooklyn%2Fsimple-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBrooooooklyn%2Fsimple-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBrooooooklyn%2Fsimple-git/lists"}