Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const FLAGS = NodeGit.Stash.FLAGS;
const flags = includeUntracked ?
FLAGS.INCLUDE_UNTRACKED :
FLAGS.DEFAULT;
stashId = yield NodeGit.Stash.save(subRepo, sig, "stash",
flags);
}
else {
stashId = NodeGit.Oid.fromString(wd.status.headCommit);
}
subResults[name] = stashId.tostrS();
// Record the values we've created.
subChanges[name] = new TreeUtil.Change(
stashId,
NodeGit.TreeEntry.FILEMODE.COMMIT);
}));
const head = yield repo.getHeadCommit();
exports.writeRepoPaths = co.wrap(function *(repo, status, message) {
assert.instanceOf(repo, NodeGit.Repository);
assert.instanceOf(status, RepoStatus);
assert.isString(message);
const headCommit = yield repo.getHeadCommit();
const changes = {};
const staged = status.staged;
const FILEMODE = NodeGit.TreeEntry.FILEMODE;
const FILESTATUS = RepoStatus.FILESTATUS;
const Change = TreeUtil.Change;
// We do a soft reset later, which means that we don't touch the index.
// Therefore, all of our files must be staged.
const index = yield repo.index();
// First, handle "normal" file changes.
for (let filename in staged) {
const stat = staged[filename];
if (FILESTATUS.REMOVED === stat) {
yield index.removeByPath(filename);
changes[filename] = null;
}
"use strict";
const assert = require("chai").assert;
const co = require("co");
const NodeGit = require("nodegit");
const Commit = require("./commit");
const ConfigUtil = require("./config_util");
const DoWorkQueue = require("./do_work_queue");
const GitUtil = require("./git_util");
const SubmoduleConfigUtil = require("./submodule_config_util");
const SubmoduleUtil = require("./submodule_util");
const SyntheticBranchUtil = require("./synthetic_branch_util");
const TreeUtil = require("./tree_util");
const FILEMODE = NodeGit.TreeEntry.FILEMODE;
// This constant defines the maximum number of simple, multi-threaded parallel
// operations we'll perform. We allow the user to configure the number of
// parallel operations that we must shell out for, but this value is just to
// prevent us from running out of JavaScript heap.
const maxParallel = 1000;
/**
* Return a string having the value of the specified `sha` with the "/"
* character inserted between the second and third characters of `sha`. The
* behavior is undefined unless `sha` is at least three characters long.
*
* @param {String} sha
* @return {String}
*/
if (STAGE.NORMAL !== stage) {
let subEntry = conflictEntries.get(name);
if (undefined === subEntry) {
subEntry = {};
conflictEntries.set(name, subEntry);
}
subEntry[stage] = entry;
}
}
// Now, look at `conflictEntries` and see if any are eligible for further
// work -- basically, submodule changes where there is a conflict that
// could be resolved by an internal merge, cherry-pick, etc. Otherwise,
// log and resolve conflicts.
const COMMIT = NodeGit.TreeEntry.FILEMODE.COMMIT;
const ConflictEntry = ConflictUtil.ConflictEntry;
const Conflict = ConflictUtil.Conflict;
const changes = {};
function makeConflict(entry) {
if (undefined === entry) {
return null;
}
return new ConflictEntry(entry.mode, entry.id.tostrS());
}
const libgit2MergeBugData = {
head: srcCommit,
targetCommit: targetCommit
};
for (const [name, entries] of conflictEntries) {
yield workAroundLibgit2MergeBug(libgit2MergeBugData, repo, name,
const delta = diff.getDelta(i);
const diffStatus = delta.status();
if (DELTA.CONFLICTED === diffStatus) {
continue; // CONTINUE
}
const fileStatus = exports.convertDeltaFlag(diffStatus);
const file = FILESTATUS.REMOVED === fileStatus ?
delta.oldFile() :
delta.newFile();
const path = file.path();
// Skip the .gitmodules file and all submodule changes; they're handled
// separately.
if (SubmoduleConfigUtil.modulesFileName !== path &&
NodeGit.TreeEntry.FILEMODE.COMMIT !== file.mode()) {
result[path] = fileStatus;
}
}
return result;
}
exports.getSubmoduleChangesFromDiff = function (diff, allowMetaChanges) {
assert.instanceOf(diff, NodeGit.Diff);
assert.isBoolean(allowMetaChanges);
const num = diff.numDeltas();
const result = {};
const DELTA = NodeGit.Diff.DELTA;
const COMMIT = NodeGit.TreeEntry.FILEMODE.COMMIT;
const modulesFileName = SubmoduleConfigUtil.modulesFileName;
for (let i = 0; i < num; ++i) {
const delta = diff.getDelta(i);
switch (delta.status()) {
case DELTA.COPIED:
case DELTA.RENAMED: {
if (COMMIT === delta.newFile.mode() ||
COMMIT === delta.oldFile.mode()) {
throw new Error(
"Not sure if these are possible. TODO: find out.");
}
} break;
case DELTA.MODIFIED:
case DELTA.CONFLICTED: {
const newFile = delta.newFile();
const path = newFile.path();
const assert = require("chai").assert;
const binarySearch = require("binary-search");
const co = require("co");
const fs = require("fs-promise");
const groupBy = require("group-by");
const path = require("path");
const NodeGit = require("nodegit");
const CloseUtil = require("./close_util");
const SparseCheckoutUtil = require("./sparse_checkout_util");
const SubmoduleUtil = require("./submodule_util");
const SubmoduleConfigUtil = require("./submodule_config_util");
const TextUtil = require("./text_util");
const UserError = require("./user_error");
const FILEMODE = NodeGit.TreeEntry.FILEMODE;
const STATUS = NodeGit.Status.STATUS;
function needToRequestRecursive(path) {
throw new UserError(
`not removing '${path}' recursively without -r`);
}
function pluralizeHas(n) {
return n === 1 ? "has" : "have";
}
const errorsByCause = {
unstaged: {
problem: "local modifications",
solution: "use --cached to keep the file, or -f to force removal"
},
.then(oid=>deepInsert(repo
, tree
, pathParts
, [[target, oid, NodeGit.TreeEntry.FILEMODE.TREE]]
)
);
const assert = require("chai").assert;
const co = require("co");
const NodeGit = require("nodegit");
const path = require("path");
const BulkNotesUtil = require("./bulk_notes_util");
const DoWorkQueue = require("./do_work_queue");
const GitUtil = require("./git_util");
const StitchUtil = require("./stitch_util");
const SubmoduleConfigUtil = require("./submodule_config_util");
const SubmoduleUtil = require("./submodule_util");
const SyntheticBranchUtil = require("./synthetic_branch_util");
const TreeUtil = require("./tree_util");
const UserError = require("./user_error");
const FILEMODE = NodeGit.TreeEntry.FILEMODE;
/**
* @property {String} local record of stitched commits
*/
exports.localReferenceNoteRef = "refs/notes/stitched/local-reference";
/**
* Return the destitched data corresponding to the specified `stitchedSha` in
* the specified `repo` if it can be found in `refs/notes/stitched/reference`
* or `refs/notes/stitched/local-reference` or in the specified
* `newlyStitched`, and null if it has not been destitched.
*
* @param {NodeGit.Repository} repo
* @param {Object} newlyStitched
* @param {String} stitchedSha
* @return {Object}
treeEntries.push(treeEntry);
const treeId = treeEntry.id();
const curTree = yield repo.getTree(treeId);
subtree = yield writeSubtree(curTree, entry, fullPath);
}
else {
subtree = yield writeSubtree(null, entry, fullPath);
}
if (0 === subtree.entryCount()) {
builder.remove(filename);
}
else {
const inserted = builder.insert(
filename,
subtree.id(),
NodeGit.TreeEntry.FILEMODE.TREE);
treeEntries.push(inserted);
}
}
}
const id = yield builder.write();
return yield repo.getTree(id);
});
return yield writeSubtree(baseTree, directory, "");