当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Repository.init方法代码示例

本文整理汇总了TypeScript中nodegit.Repository.init方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Repository.init方法的具体用法?TypeScript Repository.init怎么用?TypeScript Repository.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nodegit.Repository的用法示例。


在下文中一共展示了Repository.init方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: makeTmpPath

    async function makeTmpPath(createGit: boolean = false): Promise<void> {
        await fse.ensureDir(tmpPath);

        if (createGit) {
            const repo = await _git.Repository.init(tmpPath, 0);
            repo.free();
        }
    }
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:8,代码来源:git.service.spec.ts

示例2: createLocalRepository

  function createLocalRepository() {
    //console.log("createLocalRepo")
    if (document.getElementById("repoCreate").value == null || document.getElementById("repoCreate").value == "") {
      document.getElementById("dirPickerCreateLocal").click();
      let localPath = document.getElementById("dirPickerCreateLocal").files[0].webkitRelativePath;
      let fullLocalPath = document.getElementById("dirPickerCreateLocal").files[0].path;
      document.getElementById("repoCreate").value = fullLocalPath;
      document.getElementById("repoCreate").text = fullLocalPath;
    } else {
      let localPath = document.getElementById("repoCreate").value;
      let fullLocalPath;
      if (!require('path').isAbsolute(localPath)) {
        updateModalText('The filepath is not valid. For OSX and Ubuntu the filepath should start with /, for Windows C:\\\\')
        return
      } else {
        if (checkFile.existsSync(localPath)) {
          fullLocalPath = localPath;
        } else {
          checkFile.mkdirSync(localPath);
          fullLocalPath = localPath;
        }
      }
    }

    //console.log("pre-git check")
    //console.log("fullLocalPath is " + fullLocalPath)
    //console.log(require("path").join(fullLocalPath,".git"));
    if (checkFile.existsSync(require("path").join(fullLocalPath, ".git"))) {
      //console.log("Is git repository already")
      updateModalText("This folder is already a git repository. Please try to open it instead.");
    } else {
      displayModal("creating repository at " + require("path").join(fullLocalPath, ".git"));
      Git.Repository.init(fullLocalPath, 0).then(function (repository) {
        repoFullPath = fullLocalPath;
        repoLocalPath = localPath;
        refreshAll(repository);
        //console.log("Repo successfully created");
        updateModalText("Repository successfully created");
        document.getElementById("repoCreate").value = "";
        document.getElementById("dirPickerCreateLocal").value = null;
        switchToMainPanel();
      },
        function (err) {
          updateModalText("Creating Failed - " + err);
          //console.log("repo.ts, line 131, cannot open repository: "+err); // TODO show error on screen
        });
    }
  }
开发者ID:cchampernowne,项目名称:project-seed,代码行数:48,代码来源:repo.ts

示例3: checkoutGhPagesBranch

export async function checkoutGhPagesBranch(path: string, user: string) {
  let repo: NodeGitRepository = undefined;

  /** initialize repository if not exist */
  try {
    repo = await nodegit.Repository.open(path);
  } catch (error) {
    Log.info("git init");
    repo = await nodegit.Repository.init(path, 0);
  }

  let branch: NodeGitBranch = undefined;

  /** do initial commit if not exist */
  try {
    branch = await repo.getCurrentBranch();
  } catch (error) {
    await addAllAndCommit(path, user, "initial commit", true);
    repo = await nodegit.Repository.open(path);
    branch = await repo.getCurrentBranch();
  }

  /** lookup gh-pages branch and create it if not exists */
  try {
    let ghPagesBranch = await repo.getBranch("gh-pages");
  } catch (error) {
    Log.info("git branch gh-pages HEAD");

    let headCommit = await repo.getHeadCommit();
    await repo.createBranch("gh-pages", headCommit, 0, repo.defaultSignature(), "message");
  }

  /** checkout gh-pages */
  let branchName = branch.name();
  if (!branchName.endsWith("/gh-pages")) {
    Log.info("git checkout gh-pages");

    repo = await nodegit.Repository.open(path);

    return await repo.checkoutBranch("gh-pages", {
      checkoutStrategy: nodegit.Checkout.STRATEGY.SAFE | nodegit.Checkout.STRATEGY.RECREATE_MISSING
    });
  }

  return await Promise.resolve();
}
开发者ID:NohSeho,项目名称:oh-my-github-1,代码行数:46,代码来源:nodegit_util.ts

示例4: stageCommand

export async function stageCommand(config: Config, args) {
  const logger = config.logger;
  const path = args["p"] || args["path"] || process.cwd();
  const workingDir = await searchForProjectDir(path);
  const projectName = await getProjectName(workingDir);

  const remoteUrl = await Git.Repository.open(workingDir).then(function(repository) {
    return repository.getRemote("origin").then(function(remote) {
      return remote.url();
    });
  });
  const serveUrl = "https://tbtimes.github.io/" + projectName + "/";

  let servePath = join(workingDir, config.caches.DEPLOY_DIR, projectName);
  const projectDirs = await glob(`*/`, {cwd: servePath});
  const servePathGit = servePath + "/.git/";

  if (existsSync(servePathGit)) {
    logger.info("Deleting existing .git directory.")
    rmrf.sync(servePathGit);
  }

  let repo, index, oid;
  const token = args["t"] || args["token"] || config.GH_TOKEN || process.env.GH_TOKEN;
  if (!token)
      logger.error(`Must specify a token to access github.`) && process.exit(1);
  const pushOpts = {
      callbacks: {
          credentials: function () {
              return Git.Cred.userpassPlaintextNew(token, "x-oauth-basic");
          }
      }
  };
  if (process.platform === "darwin") {
      pushOpts.callbacks.certificateCheck = function () { return 1; };
  }
  const signature = Git.Signature.now("newsroom-user", "ejmurra2@gmail.com");

  await Git.Repository.init(servePath, 0)
    .then(function(repository) {
      repo = repository;
      return repo.refreshIndex().then(function(indexResult) {
        index = indexResult;
        return index.addAll()
          .then(function() {
            return index.write();
          })
          .then(function() {
            return index.writeTree();
          });
      });
    })
    .then(function(oidResult) {
      oid = oidResult;
      return repo.createCommit("HEAD", signature, signature, "lede stage", oid);
    })
    .then(function(o) {
      return repo.createBranch("gh-pages", o);
    })
    .then(function() {
      return repo.checkoutBranch("gh-pages");
    })
    .then(function() {
      return Git.Remote.create(repo, "origin", remoteUrl).then(function(remote) {
        logger.info("Pushing to GitHub.");
        return remote.push("+refs/heads/gh-pages:refs/heads/gh-pages", pushOpts)
          .then(function() {
            return projectDirs.map(dir=> logger.info(dir.slice(0,-1) + " served at " + serveUrl + dir));
          })
        })
      }, function(err) { logger.error(err); });
}
开发者ID:tbtimes,项目名称:lede-cli,代码行数:72,代码来源:stage.ts

示例5:

import * as Git from 'nodegit';

Git.Repository.discover("startPath", 1, "ceilingDirs").then((string) => {
    // Use string
});

Git.Repository.init("path", 0).then((repository) => {
    // Use repository
});

const repo = new Git.Repository();
const id = new Git.Oid();
const ref = new Git.Reference();
const tree = new Git.Tree();

// AnnotatedCommit Tests

Git.AnnotatedCommit.fromFetchhead(repo, "branch_name", "remote_url", id).then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.fromRef(repo, ref).then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.fromRevspec(repo, "revspec").then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.lookup(repo, id).then((annotatedCommit) => {
    // Use annotatedCommit
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:nodegit-tests.ts

示例6: require

import * as cli from 'commander';
import * as path from 'path';
const NodeGit = require('nodegit');

cli
    .usage('[dir]')
    .parse(process.argv);

let directory = cli.args[0];

console.log(directory)

let repositoryPath = path.resolve(directory);
let isBare = 0;

NodeGit.Repository.init(repositoryPath, isBare).then((repository: any) => {
    console.log('done');
}).catch((err: any) => {
    console.log(err);
});
开发者ID:maxdeviant,项目名称:orochi,代码行数:20,代码来源:orochi-init.ts


注:本文中的nodegit.Repository.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。