Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let result = Git.Attr.addMacro(repo, "name", "values");
Git.Attr.cacheFlush(repo);
Git.Attr.get(repo, 1, "path", "name").then((string) => {
// Use string
});
const array = Git.Attr.getMany(repo, 1, "path", 1, "names");
result = Git.Attr.value("attr");
const blameOptions = new Git.BlameOptions();
Git.Branch.lookup(repo, "branch_name", Git.Branch.BRANCH.LOCAL).then((reference) => {
// Use reference
});
repo.getCommit("0123456789abcdef0123456789abcdef").then((commit) => {
const sig = Git.Signature.now('John Doe', 'jd@example.com');
const newCommit: Promise = commit.amend('ref', sig, sig, 'utf8', 'message', tree);
});
const signature = Git.Signature.now("name", "email");
signature.name();
signature.email();
signature.when();
repo.createBlobFromBuffer(Buffer.from("test")).then((oid: Git.Oid) => oid.cpy());
repo.commondir();
it("simple detached", co.wrap(function *() {
const r = yield TestUtil.createSimpleRepository();
r.detachHead();
const branch = yield r.getBranch("master");
NodeGit.Branch.delete(branch);
const ast = yield ReadRepoASTUtil.readRAST(r);
const headId = yield r.getHeadCommit();
const commit = headId.id().tostrS();
let commits = {};
commits[commit] = new Commit({
changes: { "README.md": ""},
message: "first commit",
});
const expected = new RepoAST({
commits: commits,
branches: {},
head: commit,
currentBranchName: null,
});
RepoASTUtil.assertEqualASTs(ast, expected);
}));
return Promise.all(branches.map(function(branch) {
return git.Branch.lookup(repo, api.join(remote.name(), branch.Name), git.Branch.BRANCH.REMOTE).then(function(remoteBranch) {
return repo.getBranchCommit(remoteBranch).then(function(commit) {
var rJson = mRemotes.remoteJSON(remote, fileDir, [mRemotes.remoteBranchJSON(remoteBranch, commit, remote, fileDir)]);
var trackingRemote = config.branch && config.branch[branch.Name] && config.branch[branch.Name].remote;
if (trackingRemote === remote.name() || !trackingRemote) {
branch["RemoteLocation"].splice(0, 0, rJson);
} else {
branch["RemoteLocation"].push(rJson);
}
});
}).catch(function() {
//No remote tracking branch
branch["RemoteLocation"].push(mRemotes.remoteJSON(remote, fileDir, [mRemotes.remoteBranchJSON(null, null, remote, fileDir, branch)]));
});
}));
})
.then(function(commit) {
if (!branchName) {
branchName = theRef.shorthand().split("/").slice(1).join("/");
}
return git.Branch.create(theRepo, branchName, commit, 0);
})
.then(function(ref) {
const deleteBranch = co.wrap(function *(repo) {
const branch = yield GitUtil.findBranch(repo, branchName);
if (null !== branch) {
NodeGit.Branch.delete(branch);
}
});
function findMatchingRemote(currentBranch) {
return NodeGit.Branch.upstream(currentBranch).catch(err => {
return Promise.reject('UPSTREAM_NOT_FOUND');
})
}
.then(function(ref) {
if (git.Branch.delete(ref) === 0) {
res.status(200).end();
} else {
writeError(403, res);
}
})
.catch(function() {
.then((branch) => {
return nodegit.Branch.upstream(repository.currentBranch);
}, (error) => {
repository.status.upstream = 'none';
}
if (null !== newBranch) {
const name = newBranch.name;
const branch = yield GitUtil.createBranchFromHead(repo, name);
const tracking = newBranch.tracking;
if (null !== tracking) {
const trackingName = tracking.branchName;
const remote = tracking.remoteName;
let trackingBranchName;
if (null !== remote) {
trackingBranchName = `${remote}/${trackingName}`;
}
else {
trackingBranchName = trackingName;
}
yield NodeGit.Branch.setUpstream(branch, trackingBranchName);
}
}
if (null !== switchBranch) {
yield repo.setHead(`refs/heads/${switchBranch}`);
}
});