{"id":18355395,"url":"https://github.com/charto/ts-git","last_synced_at":"2025-06-15T06:32:45.821Z","repository":{"id":57380756,"uuid":"55265759","full_name":"charto/ts-git","owner":"charto","description":"Compact high-level JavaScript API for git","archived":false,"fork":false,"pushed_at":"2016-05-19T16:47:19.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-10T22:48:39.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/charto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-01T22:23:00.000Z","updated_at":"2022-12-11T07:31:29.000Z","dependencies_parsed_at":"2022-09-06T05:32:07.235Z","dependency_job_id":null,"html_url":"https://github.com/charto/ts-git","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/charto/ts-git","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fts-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fts-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fts-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fts-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charto","download_url":"https://codeload.github.com/charto/ts-git/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fts-git/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259716492,"owners_count":22900892,"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":[],"created_at":"2024-11-05T22:06:49.688Z","updated_at":"2025-06-15T06:32:45.771Z","avatar_url":"https://github.com/charto.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ts-git\n======\n\n[![build status](https://travis-ci.org/charto/ts-git.svg?branch=master)](http://travis-ci.org/charto/ts-git)\n[![dependency status](https://david-dm.org/charto/ts-git.svg)](https://david-dm.org/charto/ts-git)\n[![npm version](https://img.shields.io/npm/v/ts-git.svg)](https://www.npmjs.com/package/ts-git)\n\nThis is a compact high-level JavaScript API for git. No git installation is needed.\nIt wraps the low-level [js-git](https://github.com/creationix/js-git) API to investigate\nworking copies of repositories stored in the local filesystem, much like the `git`\ncommand line tool is often used.\n\nFeatures\n--------\n\nThe main high-level operations are:\n\n- Get info (hash, message, time and author) for any commit ([`getCommit`](#api-Git-getCommit)).\n- Get logs with commit info working backwards from any commit ([`getLog`](#api-Git-getLog)).\n  - Optionally filtered to only include commits with changes to a particular file (stopping at renames).\n- Check if a particular file in the working tree has changed since the latest commit ([`isDirty`](#api-Git-isDirty)).\n\nAPI\n===\nDocs generated using [`docts`](https://github.com/charto/docts)\n\u003e\n\u003e \u003ca name=\"api-CommitInfo\"\u003e\u003c/a\u003e\n\u003e ### Interface [`CommitInfo`](#api-CommitInfo)\n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L30-L37)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.tree** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.parents** \u003csup\u003e\u003ccode\u003estring[]\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.author** \u003csup\u003e\u003ccode\u003e[UserTimeInfo](#api-UserTimeInfo)\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.committer** \u003csup\u003e\u003ccode\u003e[UserTimeInfo](#api-UserTimeInfo)\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.message** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.hash** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e\n\u003e \u003ca name=\"api-FileInfo\"\u003e\u003c/a\u003e\n\u003e ### Interface [`FileInfo`](#api-FileInfo)\n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L19-L22)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.mode** \u003csup\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.hash** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e\n\u003e \u003ca name=\"api-GetLogOptions\"\u003e\u003c/a\u003e\n\u003e ### Interface [`GetLogOptions`](#api-GetLogOptions)\n\u003e \u003cem\u003eFiltering options for retrieving logs.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L12-L17)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.path**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eOnly match commits where file at path was changed.\u003c/em\u003e  \n\u003e \u003e **.count**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eOnly match up to given number of commits.\u003c/em\u003e  \n\u003e\n\u003e \u003ca name=\"api-Git\"\u003e\u003c/a\u003e\n\u003e ### Class [`Git`](#api-Git)\n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L59-L252)  \n\u003e  \n\u003e Methods:  \n\u003e \u003e **new( )** \u003csup\u003e\u0026rArr; \u003ccode\u003e[Git](#api-Git)\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L60-L68)  \n\u003e \u003e \u0026emsp;\u0026#x25aa; basePath \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.getWorkingHead( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;[HeadInfo](#api-HeadInfo)\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L72-L104)  \n\u003e \u003e \u0026emsp;\u003cem\u003eGet promise resolving to the hash of current working tree HEAD commit.\u003c/em\u003e  \n\u003e \u003e **.getCommit( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;[CommitInfo](#api-CommitInfo)\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L108-L112)  \n\u003e \u003e \u0026emsp;\u003cem\u003eGet info for commit based on its hash.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; commitHash \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.resolve( )** \u003csup\u003e\u0026rArr; \u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L116-L118)  \n\u003e \u003e \u0026emsp;\u003cem\u003eGet absolute path to file inside working copy.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; pathName \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.relative( )** \u003csup\u003e\u0026rArr; \u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L122-L124)  \n\u003e \u003e \u0026emsp;\u003cem\u003eGet path to file inside working copy relative to its root.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; pathName \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.findPath( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;[FileInfo](#api-FileInfo)\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L129-L146)  \n\u003e \u003e \u0026emsp;\u003cem\u003eGet info for file at pathName inside tree. Tree is a hash\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003epointing to the contents of a commit, defined in the commit's info.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; treeHash \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; pathName \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.isDirty( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;boolean\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L151-L184)  \n\u003e \u003e \u0026emsp;\u003cem\u003eGet promise resolving to true if file inside working tree is dirty,\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003efalse otherwise.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; pathName \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.walkLog( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;void\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L189-L237)  \n\u003e \u003e \u0026emsp;\u003cem\u003eWalk the commit log from given hash towards the initial commit,\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003ecalling handler for each commit matching options.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; commitHash \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; options \u003csup\u003e\u003ccode\u003e[GetLogOptions](#api-GetLogOptions)\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; handler \u003csup\u003e\u003ccode\u003e(entry: CommitInfo) =\u0026gt; void\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.getLog( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;[CommitInfo](#api-CommitInfo)[]\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L243-L247)  \n\u003e \u003e \u0026emsp;\u003cem\u003eGet promise resolving to a list of commits matching options,\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003ein reverse topological / chronological order\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003efrom given hash towards the initial commit.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; hash \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25ab; options\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003e[GetLogOptions](#api-GetLogOptions)\u003c/code\u003e\u003c/sup\u003e  \n\u003e\n\u003e \u003ca name=\"api-HeadInfo\"\u003e\u003c/a\u003e\n\u003e ### Interface [`HeadInfo`](#api-HeadInfo)\n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L39-L42)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.branch**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.hash**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e\n\u003e \u003ca name=\"api-UserTimeInfo\"\u003e\u003c/a\u003e\n\u003e ### Interface [`UserTimeInfo`](#api-UserTimeInfo)\n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L24-L28)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.name** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.email** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.date** \u003csup\u003e\u003ccode\u003e{ seconds: number; offset: number; }\u003c/code\u003e\u003c/sup\u003e  \n\u003e\n\u003e \u003ca name=\"api-getHash\"\u003e\u003c/a\u003e\n\u003e ### Function [`getHash`](#api-getHash)\n\u003e \u003cem\u003eGet promise resolving to desired type of hash (eg. sha1) for contents of stream.\u003c/em\u003e  \n\u003e \u003cem\u003eOptionally prefix contents with an arbitrary header before hashing.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L47-L57)  \n\u003e \u003e **getHash( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;string\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L47-L57)  \n\u003e \u003e \u0026emsp;\u0026#x25aa; type \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; dataStream \u003csup\u003e\u003ccode\u003eReadable\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25ab; prefix\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\nLicense\n=======\n\n[The MIT License](https://raw.githubusercontent.com/charto/ts-git/master/LICENSE)\n\nCopyright (c) 2016 BusFaster Ltd\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharto%2Fts-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharto%2Fts-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharto%2Fts-git/lists"}