How to use the isomorphic-git.plugins function in isomorphic-git

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 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 mizchi / next-editor / src / runApp.tsx View on Github external
export async function run(opts = {}) {
  // Run
  await Promise.all([setupFonts(), loadBrowserFS()])
  git.plugins.set("fs", fs)

  try {
    const {
      setupInitialRepository
    } = await import("./domain/git/commands/setupInitialRepository")
    await setupInitialRepository("/playground")
  } catch (e) {
    // Skip
    console.error("init error", e)
  }

  ReactDOM.render(, document.querySelector(".root"))
}
github adobe / helix-cli / src / git-utils.js View on Github external
*
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

const path = require('path');
const os = require('os');
const ignore = require('ignore');
const ini = require('ini');
const fse = require('fs-extra');

const { GitUrl } = require('@adobe/helix-shared');
const git = require('isomorphic-git');
git.plugins.set('fs', require('fs'));

class GitUtils {
  /**
   * Determines whether the working tree directory contains uncommitted or unstaged changes.
   *
   * @param {string} dir working tree directory path of the git repo
   * @param {string} [homedir] optional users home directory
   * @returns {Promise} `true` if there are uncommitted/unstaged changes; otherwise `false`
   */
  static async isDirty(dir, homedir = os.homedir()) {
    // see https://isomorphic-git.org/docs/en/statusMatrix
    const HEAD = 1;
    const WORKDIR = 2;
    const STAGE = 3;
    const matrix = await git.statusMatrix({ dir });
    let modified = matrix
github AztecProtocol / AZTEC / packages / monorepo-scripts / git / detector.js View on Github external
const git = require('isomorphic-git');
const fs = require('fs');
const path = require('path');

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

const CONTRACT_ADDRESSES_PREFIX = '@aztec/contract-addresses@';
const CONTRACT_ARTIFACTS_PREFIX = '@aztec/contract-artifacts@';

const contractAddressesPrefix = '@aztec/contract-addresses@';
const repoRoot = path.join(__dirname, '..', '..', '..');

/**
 * 
 * Figures out whether the package has been modified since the last tagged commit.
 * 
 * @param {string} aztecPackage
 * @returns boolean
 */
const hasPackageChanged = async (aztecPackage) => {
    console.log({ aztecPackage });
github InventivetalentDev / PluginBlueprint / js / versionControl.js View on Github external
const git = require("isomorphic-git");
const fs = require("fs");
git.plugins.set("fs", fs);
const path = require("path");
const prompt = require("electron-prompt");
const keytar = require("keytar");
const {copyFile} = require("./util");

function init(projectPath) {
    return new Promise((resolve, reject) => {
        copyFile(path.join(__dirname, "../assets/projectGitignore.txt"), path.join(projectPath, ".gitignore"))
            .then(() => {
                return git.init({dir: projectPath})
            })
            .then(() => {
                return git.add({dir: projectPath, filepath: "."})
            })
            .then(() => {
                return git.commit({
github felipemanga / FemtoIDE / plugins / git.js View on Github external
APP.addPlugin("Git", ["Project"], _=>{
    
    const log = APP.log;
    const git = require('isomorphic-git');
    const fs = require('fs');
    git.plugins.set('fs', fs);
    let dir, wasInit = false, noGit = false;

    const statusMap = {
        "ignored":{ type:"info", text:"ignored" },
        "unmodified":{ type:"info", text:"OK" },
        "*modified":{ type:"button", text:"Stage", cb:gitAdd },
        "modified":{ type:"info", text:"Added" },
        "*added":{ type:"button", text:"Stage", cb:gitAdd },
        "added":{ type:"info", text:"Added" },
        "*unmodified":{ type:"info", text:"Unmodified" }
    };

    const colorMap = {
        "ignored":"",
        "unmodified":"",
        "*modified":"#552200",
github arjun27 / rubberduck / native-host / src / git / index.ts View on Github external
import {
  BASE_REPOS_URI,
  toPath,
  constructRootUri,
  constructCloneUri,
  mkdir
} from "../utils";
import { emitter } from "./emitter";
import { log } from "../logger";

const rimraf = require("rimraf");
const fs = require("fs");
const git = require("isomorphic-git");

git.plugins.set("fs", fs);
git.plugins.set("emitter", emitter);

const getTempSuffix = (path: string) => {
  const temp = Math.random()
    .toString(36)
    .substring(7);
  return `${path}_temp_${temp}`;
};

export class GitManager {
  clonePath: string;
  finalPath: string;

  constructor(private repo: RepoPayload, private cloneUrl: string) {
    this.clonePath = toPath(constructCloneUri(repo));
    this.finalPath = toPath(constructRootUri(repo));
  }
github elastic / kibana / x-pack / legacy / plugins / code / server / git_operations.ts View on Github external
} from '@elastic/nodegit';
import Boom from 'boom';
import LruCache from 'lru-cache';
import * as Path from 'path';
import * as fs from 'fs';
import * as isogit from 'isomorphic-git';
import { CommitDescription, TreeDescription } from 'isomorphic-git';
import { isBinaryFileSync } from 'isbinaryfile';

import { GitBlame } from '../common/git_blame';
import { CommitDiff, Diff, DiffKind } from '../common/git_diff';
import { FileTree, FileTreeItemType, RepositoryUri, sortFileTree } from '../model';
import { CommitInfo, ReferenceInfo, ReferenceType } from '../model/commit';
import { detectLanguage } from './utils/detect_language';

isogit.plugins.set('fs', fs);

export const HEAD = 'HEAD';
const REFS_HEADS = 'refs/heads/';
export const DEFAULT_TREE_CHILDREN_LIMIT = 50;

/**
 * do a nodegit operation and check the results. If it throws a not found error or returns null,
 * rethrow a Boom.notFound error.
 * @param func the nodegit operation
 * @param message the message pass to Boom.notFound error
 */
async function checkExists(func: () => Promise, message: string): Promise {
  let result: R;
  try {
    result = await func();
  } catch (e) {
github cardstack / cardstack / packages / git / remote.js View on Github external
const git = require('isomorphic-git');
const fs = require('fs');
git.plugins.set('fs', fs);
const  { Remote } = require('nodegit');

class IsoRemote {
    static async create(repo, name, url) {
        await git.addRemote({fs, remote: name, url, gitdir: repo.path()});
        return Remote.lookup(repo, name);
    }
}

module.exports = IsoRemote;
github arjun27 / rubberduck / native-host / src / git / index.ts View on Github external
import child_process from "child_process";
import {
  BASE_REPOS_URI,
  toPath,
  constructRootUri,
  constructCloneUri,
  mkdir
} from "../utils";
import { emitter } from "./emitter";
import { log } from "../logger";

const rimraf = require("rimraf");
const fs = require("fs");
const git = require("isomorphic-git");

git.plugins.set("fs", fs);
git.plugins.set("emitter", emitter);

const getTempSuffix = (path: string) => {
  const temp = Math.random()
    .toString(36)
    .substring(7);
  return `${path}_temp_${temp}`;
};

export class GitManager {
  clonePath: string;
  finalPath: string;

  constructor(private repo: RepoPayload, private cloneUrl: string) {
    this.clonePath = toPath(constructCloneUri(repo));
    this.finalPath = toPath(constructRootUri(repo));