repository-provider
Version:
abstract interface to git repository providers like github, bitbucket and gitlab
275 lines (274 loc) • 9.23 kB
text/typescript
/**
* Abstract repository
*
* @property {RepositoryOwner} owner
* @property {string} name without (#branch)
* @property {string} [description] from options.description
* @property {string} [id] from options.id
* @property {Map<string,Branch>} branches
* @property {Map<string,Tag>} tags
* @property {Map<string,PullRequest>} pullRequests
* @property {Map<string,Milestone>} milestones
*/
export class Repository extends OwnedObject {
static defaultBranchName: string;
/**
* options
*/
static get attributes(): {
url: import("pacc").AttributeDefinition;
/**
* The name of the default branch
* @return {string}
*/
defaultBranchName: {
default: string;
type: string;
isKey: boolean;
writable: boolean;
mandatory: boolean;
private?: boolean;
depends?: string;
additionalAttributes: string[];
description?: string;
set?: Function;
get?: Function;
env?: string[] | string;
};
cloneURL: import("pacc").AttributeDefinition;
isArchived: import("pacc").AttributeDefinition;
isLocked: import("pacc").AttributeDefinition;
isDisabled: import("pacc").AttributeDefinition;
isTemplate: import("pacc").AttributeDefinition;
isFork: import("pacc").AttributeDefinition;
id: import("pacc").AttributeDefinition;
name: import("pacc").AttributeDefinition;
description: import("pacc").AttributeDefinition;
};
/**
* @param {RepositoryOwner} owner
* @param {string} name (#branch) will be removed
* @param {Object} [options]
* @param {string} [options.description] human readable description
* @param {string} [options.id] internal id
* @param {Object} [options]
* @param {string} [options.id]
* @param {string} [options.description]
* @param {Object} [additionalProperties]
*/
constructor(owner: typeof RepositoryOwner, name: string, options?: {
description?: string;
id?: string;
}, additionalProperties?: any);
get defaultBranchName(): string;
/**
* Lookup entries form the head of the default branch.
* {@link Branch#entry}
* @return {Promise<ContentEntry>}
*/
entry(name: any): Promise<ContentEntry>;
/**
* List entries of the default branch.
* @param {string[]|string} [patterns]
* @return {AsyncIterable<ContentEntry>} all matching entries in the branch
*/
entries(patterns?: string[] | string): AsyncIterable<ContentEntry>;
/**
* Get exactly one matching entry by name or undefined if no such entry is found.
* @param {string} name
* @return {Promise<ContentEntry|undefined>}
*/
maybeEntry(name: string): Promise<ContentEntry | undefined>;
/**
* List commits of the default branch.
* @param {Object} [options]
* @return {AsyncIterable<Commit>} all matching commits in the repository
*/
commits(options?: any): AsyncIterable<Commit>;
/**
* The url used for cloning the repo.
* @return {string}
*/
get cloneURL(): string;
/**
* By default we are not a template.
* @return {boolean} false
*/
get isTemplate(): boolean;
/**
* Delete the repository from the {@link Provider}.
* {@link Provider#deleteRepository}
* @return {Promise<any>}
*/
delete(): Promise<any>;
/**
* Lookup the default branch.
* @return {Promise<Branch|undefined>} branch named after defaultBranchName
*/
get defaultBranch(): Promise<Branch | undefined>;
/**
* Lookup branch by name.
* @param {string} name
* @return {Promise<Branch|undefined>}
*/
branch(name: string): Promise<Branch | undefined>;
/**
* @return {boolean} true if there is at least one branch
*/
get hasBranches(): boolean;
/**
* @param {string[]|string} [patterns]
* @return {AsyncGenerator<Branch>} of all branches
*/
branches(patterns?: string[] | string): AsyncGenerator<Branch>;
/**
* Create a new {@link Branch} by cloning a given source branch.
* @param {string} name of the new branch
* @param {Branch} source branch defaults to the defaultBranch
* @param {Object} [options]
* @return {Promise<Branch>} newly created branch (or already present old one with the same name)
*/
createBranch(name: string, source: Branch, options?: any): Promise<Branch>;
/**
* Add a new {@link Branch}.
* Internal branch creation does not call repository.initialize()
* @param {string} name of the new branch
* @param {Object} [options] to be passed to the branch
* @return {Branch} newly created branch or already present one for the given name
*/
addBranch(name: string, options?: any): Branch;
_addBranch(branch: any): void;
/**
* Delete a {@link Branch}.
* @param {string} name of the branch
* @return {Promise<any>}
*/
deleteBranch(name: string): Promise<any>;
/**
* Get a Tag.
* @param {string} name
* @return {Promise<Tag>}
*/
tag(name: string): Promise<Tag>;
/**
* @param {string[]|string} [patterns]
* @return {AsyncGenerator<Tag>} of all tags
*/
tags(patterns?: string[] | string): AsyncGenerator<Tag>;
/**
* Add a new {@link Tag}.
* Internal tag creation does not call repository.initialize()
* @param {string} name of the new tag
* @param {Object} [options]
* @return {Tag} newly created tag
*/
addTag(name: string, options?: any): Tag;
_addTag(tag: any): void;
/**
* Create a pull request (or deliver an already present for the given name).
* @param {string} name of the pr
* @param {Branch} source branch
* @param {Object} [options]
* @return {Promise<PullRequest>}
*/
createPullRequest(name: string, source: Branch, options?: any): Promise<PullRequest>;
/**
* Add a pull request.
* @param {string} name
* @param {Branch} source
* @param {Object} [options]
* @return {PullRequest}
*/
addPullRequest(name: string, source: Branch, options?: any): PullRequest;
_addPullRequest(pr: any): void;
/**
* Deliver all {@link PullRequest}s.
* @return {AsyncGenerator<PullRequest>} of all pull requests
*/
pullRequests(): AsyncGenerator<PullRequest>;
/**
* The @see {@link PullRequest} for a given name.
* @param {string} name
* @return {Promise<PullRequest|undefined>}
*/
pullRequest(name: string): Promise<PullRequest | undefined>;
/**
* Delete a {@link PullRequest}.
* @param {string} name
* @return {Promise<any>}
*/
deletePullRequest(name: string): Promise<any>;
/**
* Add a new {@link Hook}.
* @param {string} name of the new hoook name
* @param {Object} [options]
* @return {Hook} newly created hook
*/
addHook(name: string, options?: any): Hook;
_addHook(hook: any): void;
/**
* Add a new Hook.
* @param {Hook} hook
*/
createHook(hook: Hook): Promise<void>;
/**
* List hooks.
* @return {AsyncGenerator<Hook>} all hooks of the repository
*/
hooks(): AsyncGenerator<Hook>;
/**
* Get a Hook.
* @param {string|number} id
* @return {Promise<Hook|undefined>} for the given id
*/
hook(id: string | number): Promise<Hook | undefined>;
_addMilestone(milestone: any): void;
/**
* Get a Milestone.
* @param {string} name
* @return {Promise<Milestone|undefined>} for the given name
*/
milestone(name: string): Promise<Milestone | undefined>;
_addProject(project: any): void;
/**
* Get a Project.
* @param {string} name
* @return {Promise<Project|undefined>} for the given name
*/
project(name: string): Promise<Project | undefined>;
_addApplication(application: any): void;
/**
* Get an Application.
* @param {string} name
* @return {Promise<Application|undefined>} for the given name
*/
application(name: string): Promise<Application | undefined>;
/**
* Get type of the repository.
* @return {string} 'git'
*/
get type(): string;
/**
* Get sha of a ref.
* @param {string} ref
* @return {Promise<string|undefined>} sha of the ref
*/
refId(ref: string): Promise<string | undefined>;
initialize(): void;
initializeHooks(): void;
initializeBranches(): void;
initializeTags(): void;
initializePullRequests(): Promise<void>;
#private;
}
import { OwnedObject } from "./owned-object.mjs";
import { ContentEntry } from "content-entry";
import { Commit } from "./commit.mjs";
import { Branch } from "./branch.mjs";
import { Tag } from "./tag.mjs";
import { PullRequest } from "./pull-request.mjs";
import { Hook } from "./hook.mjs";
import { Milestone } from "./milestone.mjs";
import { Project } from "./project.mjs";
import { Application } from "./application.mjs";
import { RepositoryOwner } from "./repository-owner.mjs";