open-index/open-npm huggingface dataset:
npm package: @google-automations/git-file-utils
Description: Utilities for github file operation
Author: Jeff Ching
Latest version: 3.0.1

# git-file-utils

This is a small library for handling git files. Currently it only provides
`RepositoryFileCache` which is a read-through cache for a single branch. Because
this library uses GIt Data API, it can fetch files up to 100 MB of size.

## Install

```bash
npm i @google-automations/git-file-utils
```

## Fetch a file

```typescript
import {Octokit} from '@octokit/rest';
import {
  FileNotFoundError,
  RepositoryFileCache
} from '@google-automations/git-file-utils';

const octokit = new Octokit();
const cache = new RepositoryFileCache(
  octokit,
  {
    owner: "googleapis",
    repo: "repo-automation-bots",
  });
try {
  const contents = await cache.getFileContents("README.md", "main");
  console.log(`content: ${contents.parsedContent}`);
} catch (e) {
  if (e instanceof FileNotFoundError) {
    console.log(`file not found`);
  } else {
    // rethrow
    throw e;
  }
}
```
npm package: @google-automations/label-utils
Description: Utilities for github labels
Author: Takashi Matsuo
Latest version: 6.1.1

# Utility for syncing bot labels

This is a small utility for syncing bot specific labels.

## Usage

### Install

```bash
npm i @google-automations/label-utils
```

### Usage

`syncLabels` will automatically create or update the labels.  The
color is determined by its name and should be consistent among
repositories.

Here is a simple example with cron:
```typescript
import {syncLabels} from '@google-automations/label-utils';
const myLabels = [
  {
    name: 'my-bot:my-label',
    description: 'label description'
  },
];

  app.on('schedule.repository' as '*', async context => {
    const owner = context.payload.organization.login;
    const repo = context.payload.repository.name;
    await syncLabels(context.octokit, owner, repo, myLabels);
  });

```

The cron.yaml:
```yaml
cron:
  - name: my-bot-sync-label
    schedule: 0 3 * * *
    description: my-bot syncing labels
    params:
      cron_type: "repository"
```

Here is another example for syncing the label in
`installation_repositories.added` event:

```typescript
interface Repo {
  full_name: string;
}

const myLabels = [
  {
    name: 'my-bot:my-label',
    description: 'label description'
  },
];

export = (app: Probot) => {
  app.on('installation_repositories.added', async context => {
    await Promise.all(
      context.payload.repositories_added.map((r: Repo) => {
        const [owner, repo] = r.full_name.split('/');
        return syncLabels(
          context.octokit,
          owner,
          repo,
          myLabels
        );
      })
    );
  });
}
```