• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript nodegit.Repository类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: openRepository

 // Open a new instance of the underlying {NodeGit.Repository}.
 //
 // By opening multiple connections to the same underlying repository, users
 // can safely access the same repository concurrently.
 //
 // Returns the new {NodeGit.Repository}.
 public openRepository (): NodeGitRepository {
   if (this.openExactPath) {
     return Git.Repository.open(this.openedPath)
   } else {
     return Git.Repository.openExt(this.openedPath, 0, '')
   }
 }
开发者ID:github,项目名称:ohnogit,代码行数:13,代码来源:repository.ts


示例2: runMigrations

async function runMigrations(fromFolder: string, toFolder: string) {
	toFolder = argv.to  as string || '.';
	if (!fromFolder) {
		throw new Error('Must specify --from option when migrating.');
	}
	fromFolder = resolvePath(fromFolder);
	toFolder = resolvePath(toFolder);

	if (fromFolder === toFolder) {
		logger.info(null, '[migrate] Migration source and destination identical, skipping.');
		return;
	}
	await bootstrapDatabase();
	logger.info(null, '[migrate] Migrating from %s to %s...', fromFolder, toFolder);

	const fromRepo = await Git.Repository.open(fromFolder);
	const toRepo = await Git.Repository.open(toFolder);
	const fromCommit = await fromRepo.getHeadCommit();
	try {
		await toRepo.getCommit(fromCommit.sha());
	} catch (err) {
		logger.warn(null, '[migrate] Cannot find commit %s in repository %s. Assuming force-push, aborting migrations.', fromCommit.sha(), toFolder);
		return;
	}
	let foundFromCommit = false;
	const toCommit = await toRepo.getHeadCommit();
	const commits = await new Promise<Commit[]>((resolve, reject) => {
		const commitsSince: Commit[] = [];
		const emitter = toCommit.history()
			.on('end', () => resolve(commitsSince))
			.on('error', reject)
			.on('commit', (commit: Commit) => {
				foundFromCommit = foundFromCommit || commit.sha() === fromCommit.sha();
				if (!foundFromCommit) {
					commitsSince.push(commit);
				}
			});
		(emitter as any).start();
	});
	if (!foundFromCommit) {
		logger.info(null, '[migrate] Initial commit not found, aborting (this can happen on a force push).');
		return;
	}
	logger.info(null, '[migrate] Found %s commits between %s and %s.', commits.length, fromCommit.sha().substring(0, 7), toCommit.sha().substring(0, 7));
	let numScripts = 0;
	for (const commit of reverse(commits)) {
		const script = scripts.find(filename => commit.sha().startsWith(filename.split('-')[1]));
		if (!script) {
			continue;
		}
		logger.info(null, '[migrate] Executing migration script %s for commit %s...', script, commit.sha());
		const migrate = require(resolvePath(scriptFolder, script));
		await migrate.up();
		numScripts++;
	}
	logger.info(null, '[migrate] %s script%s executed.', numScripts, numScripts === 1 ? '' : 's');
}
开发者ID:freezy,项目名称:node-vpdb,代码行数:57,代码来源:migrate.ts


示例3: require

		(async () => {
			try {
				const Git = require('nodegit');
				const repoRoot = resolve(__dirname, '../../..');

				try {
					const repo = await Git.Repository.open(repoRoot);
					const branch = await repo.getCurrentBranch();
					const commit = await repo.getBranchCommit(branch);
					this.currentLocalBranch = {
						name: branch,
						SHA: commit.sha(),
						shortSHA: commit.sha().substr(0, 7),
						lastCommitTime: new Date(commit.timeMs()),
						lastCommitMessage: commit.message(),
						lastCommitAuthor: commit.author().name,
					};
					logger.info(null, '[git] Successfully read git config from %s.', repoRoot);
				} catch (err) {
					/* istanbul ignore next: we assume node-git is working */
					logger.warn(null, '[git] Unable to retrieve git info from %s (%s)', repoRoot, err.message);
				}
			} catch (err) {
				/* istanbul ignore next: we assume node-git is working */
				logger.warn(null, '[GitInfo] Error loading library.');
			}
		})();
开发者ID:freezy,项目名称:node-vpdb,代码行数:27,代码来源:gitinfo.ts


示例4: checkoutRemoteBranch

function checkoutRemoteBranch(element) {
  let bn;
  if (typeof element === "string") {
    bn = element;
  } else {
    bn = element.innerHTML;
  }
  console.log("1.0  " + bn);
  let repos;
  Git.Repository.open(repoFullPath)
  .then(function(repo) {
    repos = repo;
    addCommand("git fetch");
    addCommand("git checkout -b " + bn);
    let cid = remoteName[bn];
    console.log("2.0  " + cid);
    return Git.Commit.lookup(repo, cid);
  })
  .then(function(commit) {
    console.log("3.0");
    return Git.Branch.create(repos, bn, commit, 0);
  })
  .then(function(code) {
    console.log(bn + "PPPPPPP");
    repos.mergeBranches(bn, "origin/" + bn)
    .then(function() {
        refreshAll(repos);
        console.log("Pull successful");
    });
  }, function(err) {
    console.log(err);
  })
}
开发者ID:ElliotWhiley,项目名称:VisualGit,代码行数:33,代码来源:repo.ts


示例5: rateLimit

 promises.push((async () => {
   const dir = path.join('repos', ghRepo.name);
   let repo: nodegit.Repository;
   if (existsSync(dir)) {
     repo = await nodegit.Repository.open(dir);
   } else {
     await rateLimit(100);
     repo = await nodegit.Clone.clone(ghRepo.clone_url, dir, undefined);
   }
   let skipThisElement = false;
   if (opts.branchToFix !== 'master') {
     let ref = undefined;
     try {
       ref = await repo.getBranch(`refs/remotes/origin/${opts.branchToFix}`);
     } catch (_) {
       skipThisElement = true;
     }
     if (ref) {
       const commit = await repo.getReferenceCommit(ref);
       const branch =
           await nodegit.Branch.create(repo, opts.branchToFix, commit, 1);
       await repo.checkoutBranch(branch);
     }
   }
   if (skipThisElement) {
     return undefined;
   }
   return new ElementRepo({repo, dir, ghRepo, analyzer: null});
 })());
开发者ID:TimvdLippe,项目名称:tedium,代码行数:29,代码来源:tedium.ts


示例6: checkoutLocalBranch

 function checkoutLocalBranch(element) {
   let bn;
   let img = "<img"
   if (typeof element === "string") {
     bn = element;
   } else {
     bn = element.innerHTML;
   }
   if (bn.includes(img)) {
     bn = bn.substr(0, bn.lastIndexOf(img)) // remove local branch <img> tag from branch name string
     if (bn.includes(img)) {
       bn = bn.substr(0, bn.lastIndexOf(img)) // remove remote branch <img> tag from branch name string
     }
   }
   console.log("name of branch being checked out: " + bn);
   Git.Repository.open(repoFullPath)
     .then(function (repo) {
       document.getElementById('spinner').style.display = 'block';
       addCommand("git checkout " + bn);
       repo.checkoutBranch("refs/heads/" + bn)
         .then(function () {
           refreshAll(repo);
         }, function (err) {
           console.log("repo.tx, line 271, cannot checkout local branch: " + err);
         });
     })
 }
开发者ID:cchampernowne,项目名称:project-seed,代码行数:27,代码来源:repo.ts


示例7: getOtherBranches

function getOtherBranches() {
  let list;
  let repos;
  Git.Repository.open(repoFullPath)
  .then(function(repo) {
    repos = repo;
    return repo.getReferenceNames(Git.Reference.TYPE.LISTALL);
  })
  .then(function(branchList) {
    clearMergeElement();
    list = branchList;
  })
  .then(function() {
    return repos.getCurrentBranch()
  })
  .then(function(ref) {
    let name = ref.name().split("/");
    console.log("&&&&&&&");
    clearBranchElement();
    for (let i = 0; i < list.length; i++) {
      let bp = list[i].split("/");
      if (bp[1] !== "remotes" && bp[bp.length - 1] !== name[name.length - 1]) {
        displayBranch(bp[bp.length - 1], "merge-dropdown", "mergeLocalBranches(this)");
      }
    }
  })

}
开发者ID:ElliotWhiley,项目名称:VisualGit,代码行数:28,代码来源:repo.ts


示例8: 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


示例9: 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


示例10: ElementRepo

 promises.push(Promise.resolve().then(() => {
   const dir = path.join('repos', ghRepo.name);
   let repoPromise: Promise<nodegit.Repository>;
   if (existsSync(dir)) {
     repoPromise = nodegit.Repository.open(dir);
   } else {
     repoPromise = rateLimit(100).then(
         () => nodegit.Clone.clone(ghRepo.clone_url, dir, null));
   }
   return repoPromise.then((repo) =>
     new ElementRepo({repo, dir, ghRepo, analyzer: null})
   );
 }));
开发者ID:BruceZu,项目名称:tedium,代码行数:13,代码来源:tedium.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript nodegit.Signature类代码示例发布时间:2022-05-25
下一篇:
TypeScript nodegit.Reference类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap