From 997a0150e9a8a72cefb28565e36bb6ed1ea5c0b4 Mon Sep 17 00:00:00 2001 From: Zachary Wade Date: Thu, 7 Jun 2018 10:53:00 -0400 Subject: [PATCH] added the Object.TYPE enum as well as fixed typos on Object.type2String and Object.string2Type --- types/nodegit/diff-binary-file.d.ts | 4 +++- types/nodegit/object.d.ts | 29 ++++++++++++++++++++++------- types/nodegit/odb-expand-id.d.ts | 3 ++- types/nodegit/odb.d.ts | 3 ++- types/nodegit/reference.d.ts | 2 +- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/types/nodegit/diff-binary-file.d.ts b/types/nodegit/diff-binary-file.d.ts index 46b67f406e..362e1a63fc 100644 --- a/types/nodegit/diff-binary-file.d.ts +++ b/types/nodegit/diff-binary-file.d.ts @@ -1,5 +1,7 @@ +import { Object } from './object'; + export class DiffBinaryFile { - type: number; + type: Object.TYPE; data: string; datalen: number; inflatedlen: number; diff --git a/types/nodegit/object.d.ts b/types/nodegit/object.d.ts index 4ec5a19b6c..be7e879b95 100644 --- a/types/nodegit/object.d.ts +++ b/types/nodegit/object.d.ts @@ -3,20 +3,35 @@ import { Repository } from './repository'; import { Buf } from './buf'; export class Object { - static size(type: number): number; - static lookup(repo: Repository, id: Oid, type: number): Promise; - static lookupPrefix(repo: Repository, id: Oid, len: number, type: number): Promise; - static string2type(str: string): number; - static type2string(type: number): string; - static typeisloose(type: number): number; + static size(type: Object.TYPE): number; + static lookup(repo: Repository, id: Oid, type: Object.TYPE): Promise; + static lookupPrefix(repo: Repository, id: Oid, len: number, type: Object.TYPE): Promise; + static string2Type(str: string): Object.TYPE; + static type2String(type: Object.TYPE): string; + static typeisloose(type: Object.TYPE): number; dup(): Promise; free(): void; id(): Oid; - lookupByPath(path: string, type: number): Promise; + lookupByPath(path: string, type: Object.TYPE): Promise; owner(): Repository; peel(targetType: number): Promise; shortId(): Promise; type(): number; } + +export namespace Object { + const enum TYPE { + ANY = -2, + BAD = -1, + EXT1 = 0, + COMMIT = 1, + TREE = 2, + BLOB = 3, + TAG = 4, + EXT2 = 5, + OFS_DELTA = 6, + REF_DELTA = 7 + } +} diff --git a/types/nodegit/odb-expand-id.d.ts b/types/nodegit/odb-expand-id.d.ts index d4fe264c3a..5576fbad58 100644 --- a/types/nodegit/odb-expand-id.d.ts +++ b/types/nodegit/odb-expand-id.d.ts @@ -1,7 +1,8 @@ import { Oid } from './oid'; +import { Object } from './object'; export class OdbExpandId { id: Oid; length: number; - type: number; + type: Object.TYPE; } diff --git a/types/nodegit/odb.d.ts b/types/nodegit/odb.d.ts index db0aacda61..e5348d088f 100644 --- a/types/nodegit/odb.d.ts +++ b/types/nodegit/odb.d.ts @@ -1,6 +1,7 @@ import { Oid } from './oid'; import { OdbObject } from './odb-object'; import { OdbExpandId } from './odb-expand-id'; +import { Object } from './object'; export namespace Odb { const enum STREAM { @@ -17,6 +18,6 @@ export class Odb { free(): void; read(id: Oid): Promise; - write(data: Buffer, len: number, type: number): Promise; + write(data: Buffer, len: number, type: Object.TYPE): Promise; expandIds(ids: OdbExpandId, count: number): number; } diff --git a/types/nodegit/reference.d.ts b/types/nodegit/reference.d.ts index 80e16c9350..cc6cb90e28 100644 --- a/types/nodegit/reference.d.ts +++ b/types/nodegit/reference.d.ts @@ -41,7 +41,7 @@ export class Reference { isTag(): number; name(): string; owner(): Repository; - peel(type: number): Promise; + peel(type: Object.TYPE): Promise; rename(newName: string, force: number, logMessage: string): Promise; resolve(): Promise; setTarget(id: Oid, logMessage: string): Promise;