Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const sig = bare.defaultSignature();
for (let i = 0; i < refs.length; ++i) {
const ref = refs[i];
const shorthand = ref.shorthand();
if (ref.isBranch() && !(shorthand in existingBranches)) {
yield bare.createBranch(ref.shorthand(),
ref.target(),
1,
sig,
"i made a branch");
}
}
// And then remove the original remote.
yield NodeGit.Remote.delete(bare, "origin");
return bare;
});
assert.isString(commitish);
assert.isString(metaRemoteName);
if (null !== targetRefName) {
assert.isString(targetRefName);
}
const annotated = yield GitUtil.resolveCommitish(repo, commitish);
if (null === annotated) {
throw new UserError(`\
Could not resolve '${commitish}' to a commit.`);
}
const commit = yield repo.getCommit(annotated.id());
if (!(yield GitUtil.isValidRemoteName(repo, metaRemoteName))) {
throw new UserError(`Invalid remote name: '${metaRemoteName}'.`);
}
const remote = yield NodeGit.Remote.lookup(repo, metaRemoteName);
const baseUrl = remote.url();
const newlyStitched = {};
console.log("Destitching");
const result = yield exports.destitchChain(repo,
commit,
baseUrl,
newlyStitched);
const resultCommit = yield repo.getCommit(result);
// Push synthetic-refs
console.log("Pushing synthetic refs");
yield exports.pushSyntheticRefs(repo, baseUrl, resultCommit, newlyStitched);
it('should return url of remote.', async () => {
// First set remote..
const remoteName = 'my_remote';
const remoteUrl = 'some_remote_url';
const repo = await _git.Repository.open(tmpPath);
await _git.Remote.create(repo, remoteName, remoteUrl);
const result = await git.getRemoteUrl({
workspaceDirPath: tmpPath,
remoteName,
});
expect(result).to.equals(remoteUrl);
});
});
exports.getRemoteForBranch = co.wrap(function *(repo, branch) {
assert.instanceOf(repo, NodeGit.Repository);
assert.instanceOf(branch, NodeGit.Reference);
const trackingInfo = yield exports.getTrackingInfo(repo, branch);
if (null === trackingInfo || null === trackingInfo.remoteName) {
return null;
}
let upstream;
try {
upstream = yield NodeGit.Branch.upstream(branch);
}
catch (e) {
// No way to check for this other than to catch.
return null;
}
return yield NodeGit.Remote.lookup(repo, trackingInfo.remoteName);
});
exports.readRAST = co.wrap(function *(repo) {
// We're going to list all the branches in `repo`, and walk each of their
// histories to generate a complete set of commits.
assert.instanceOf(repo, NodeGit.Repository);
const branches = yield repo.getReferences(NodeGit.Reference.TYPE.LISTALL);
let commits = {};
let branchTargets = {};
let refTargets = {};
// Load up the remotes.
const remotes = yield NodeGit.Remote.list(repo);
let remoteMap = {};
for (let i = 0; i < remotes.length; ++i) {
const remoteName = remotes[i];
const remote = yield NodeGit.Remote.lookup(repo, remoteName);
remoteMap[remoteName] = {
url: remote.url(),
branches: {},
};
}
// For various operations where `NodeGit` can return arrays, it requires a
// maximum count size; I think it sets up a pre-allocated buffer. I'm
// picking a fairly arbitrary, but probably large enough, number for this.
const MAX_IDS = 1000000;
exports.getRemoteForBranch = co.wrap(function *(repo, branch) {
assert.instanceOf(repo, NodeGit.Repository);
assert.instanceOf(branch, NodeGit.Reference);
const trackingInfo = yield exports.getTrackingInfo(repo, branch);
if (null === trackingInfo || null === trackingInfo.remoteName) {
return null;
}
let upstream;
try {
upstream = yield NodeGit.Branch.upstream(branch);
}
catch (e) {
// No way to check for this other than to catch.
return null;
}
return yield NodeGit.Remote.lookup(repo, trackingInfo.remoteName);
});
// the correct URL; otherwise, add it.
const realUrl = exports.resolveSubmoduleUrl(repoUrl, url);
let origin = null;
try {
origin = yield result.getRemote("origin");
}
catch (e) {
}
if (null !== origin) {
if (realUrl !== origin.url()) {
NodeGit.Remote.setUrl(result, "origin", realUrl);
}
}
else {
yield NodeGit.Remote.create(result, "origin", realUrl);
}
return result;
});
.then(function(_repo) {
repo = _repo;
fileDir = clone.getfileDir(repo,req);
return git.Remote.create(repo, req.body.Remote, req.body.RemoteURI);
})
.then(function(remote) {
.then(function(r) {
repo = r;
return git.Remote.lookup(repo, remote);
})
.then(function(r) {
.then(function(r) {
repo = r;
fileDir = clone.getfileDir(repo,req);
return git.Remote.list(r);
})
.then(function(remotes){