How to use isomorphic-git - 10 common examples

To help you get started, weโ€™ve selected a few isomorphic-git examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github isomorphic-git / isomorphic-git / __tests__ / test-push.js View on Github external
it('push', async () => {
    // Setup
    const { gitdir } = await makeFixture('test-push')
    await config({
      gitdir,
      path: 'remote.karma.url',
      value: `http://${localhost}:8888/test-push-server.git`
    })
    const output = []
    plugins.set(
      'emitter',
      new EventEmitter().on('push.message', output.push.bind(output))
    )
    // Test
    const res = await push({
      gitdir,
      emitterPrefix: 'push.',
      remote: 'karma',
      ref: 'refs/heads/master'
    })
    expect(res).toBeTruthy()
    expect(res.ok).toBeTruthy()
    expect(res.ok[0]).toBe('unpack')
    expect(res.ok[1]).toBe('refs/heads/master')
    expect(output).toMatchSnapshot()
  })
github isomorphic-git / isomorphic-git / __tests__ / test-fetch.js View on Github external
it('shallow fetch (from Github)', async () => {
    const { fs, gitdir } = await makeFixture('test-fetch-cors')
    await config({
      gitdir,
      path: 'http.corsProxy',
      value: `http://${localhost}:9999`
    })
    const output = []
    const progress = []
    plugins.set(
      'emitter',
      new EventEmitter()
        .on('fetch.message', output.push.bind(output))
        .on('fetch.progress', progress.push.bind(progress))
    )
    // Test
    await fetch({
      gitdir,
      emitterPrefix: 'fetch.',
      depth: 1,
      singleBranch: true,
      remote: 'origin',
      ref: 'test-branch-shallow-clone'
    })
    await sleep(1000) // seems to be a problem spot
    expect(await fs.exists(`${gitdir}/shallow`)).toBe(true)
github isomorphic-git / isomorphic-git / __tests__ / test-cores.js View on Github external
it('cores have separate plugins', async () => {
    // Setup
    const { _fs } = await makeFixture('test-cores')
    plugins.set('fs', _fs)
    cores.create('third').set('foo', _fs)
    expect(cores.get('default').has('fs')).toBeTruthy()
    expect(cores.get('default').has('foo')).toBeFalsy()
    expect(cores.get('third').has('fs')).toBeFalsy()
    expect(cores.get('third').get('foo')).toBeTruthy()
  })
  it('plugin schema violation', async () => {
github isomorphic-git / isomorphic-git / __tests__ / test-cores.js View on Github external
it('unrecognized plugin', async () => {
    // Setup
    const { _fs } = await makeFixture('test-cores')
    let error = null
    try {
      plugins.set('fz', _fs)
    } catch (err) {
      error = err
    }
    expect(error).not.toBeNull()
    expect(error.code).toEqual(E.PluginUnrecognized)
  })
})
github isomorphic-git / isomorphic-git / __tests__ / test-cores.js View on Github external
it('plugin schema violation', async () => {
    // Setup
    const fs = {
      readFile () {}
    }
    let error = null
    try {
      plugins.set('fs', fs)
    } catch (err) {
      error = err
    }
    expect(error).not.toBeNull()
    expect(error.code).toEqual(E.PluginSchemaViolation)
  })
  it('unrecognized plugin', async () => {
github isomorphic-git / isomorphic-git / __tests__ / test-commit.js View on Github external
it('pgp plugin signing - backwards compatiblity', async () => {
    // Setup
    const { pgp } = require('@isomorphic-git/pgp-plugin')
    const { gitdir } = await makeFixture('test-commit')
    plugins.set('pgp', pgp)
    // Test
    const { privateKey, publicKey } = require('./__fixtures__/pgp-keys.js')
    await commit({
      gitdir,
      message: 'Initial commit',
      author: {
        name: 'Mr. Test',
        email: 'mrtest@example.com',
        timestamp: 1504842425,
        timezoneOffset: 0
      }
    })
    await sign({
      gitdir,
      privateKeys: privateKey
    })
github isomorphic-git / isomorphic-git / __tests__ / test-annotatedTag.js View on Github external
it('creates a signed tag to HEAD', async () => {
    // Setup
    const { pgp } = require('@isomorphic-git/pgp-plugin')
    const { gitdir } = await makeFixture('test-annotatedTag')
    plugins.set('pgp', pgp)
    // Test
    const { privateKey, publicKey } = require('./__fixtures__/pgp-keys.js')
    await annotatedTag({
      gitdir,
      ref: 'latest',
      message: 'some tag message',
      tagger: {
        name: 'Yu Shimura',
        email: 'mail@yuhr.org'
      },
      signingKey: privateKey
    })
    const keys = await verify({
      gitdir,
      ref: 'latest',
      publicKeys: publicKey
github adobe / helix-cli / test / testGitUtils.js View on Github external
* OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

/* eslint-env mocha */

const assert = require('assert');
const path = require('path');
const net = require('net');
const fse = require('fs-extra');
const shell = require('shelljs');
const git = require('isomorphic-git');
const { condit } = require('@adobe/helix-testutils');
const { createTestRoot } = require('./utils.js');

git.plugins.set('fs', require('fs'));

const GitUtils = require('../src/git-utils');

const GIT_USER_HOME = path.resolve(__dirname, 'fixtures/gitutils');

if (!shell.which('git')) {
  shell.echo('Sorry, this tests requires git');
  shell.exit(1);
}

describe('Testing GitUtils', () => {
  let testRoot;
  let pwd;
  beforeEach(async () => {
    testRoot = await createTestRoot();
    await fse.writeFile(path.resolve(testRoot, 'README.md'), 'Hello\n', 'utf-8');
github isomorphic-git / isomorphic-git / __tests__ / test-cores.js View on Github external
it('cores have separate plugins', async () => {
    // Setup
    const { _fs } = await makeFixture('test-cores')
    plugins.set('fs', _fs)
    cores.create('third').set('foo', _fs)
    expect(cores.get('default').has('fs')).toBeTruthy()
    expect(cores.get('default').has('foo')).toBeFalsy()
    expect(cores.get('third').has('fs')).toBeFalsy()
    expect(cores.get('third').get('foo')).toBeTruthy()
  })
  it('plugin schema violation', async () => {
github isomorphic-git / isomorphic-git / __tests__ / test-cores.js View on Github external
it('cores.get', async () => {
    // Setup
    const { _fs } = await makeFixture('test-cores')
    cores.get('default').set('fs', _fs)
    let error = null
    try {
      cores.get('first').set('fs', _fs)
    } catch (err) {
      error = err
    }
    expect(error).not.toBeNull()
    expect(error.code).toEqual(E.CoreNotFound)
  })
  it('core.create', async () => {