You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

staged-git-files

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

staged-git-files - npm Package Compare versions

Comparing version
0.0.4
to
1.0.0
+17
-11
index.js

@@ -15,3 +15,3 @@ var spawn = require("child_process").spawn;

} else {
var command = "git diff-index --cached --name-status --diff-filter=" + filter + " " + head;
var command = "git diff-index --cached --name-status -M --diff-filter=" + filter + " " + head;
run(command, function(err, stdout, stderr) {

@@ -95,10 +95,16 @@ if (err || stderr) {

/* ===============================================================================================================================
** PER git diff-index --help
** --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
** Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular
** file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any
** combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all
** paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches
** other criteria, nothing is selected.
** ============================================================================================================================ */
** PER docs at https://git-scm.com/docs/git-diff-index
** Possible status letters are:
** A: addition of a file
** C: copy of a file into a new one
** D: deletion of a file
** M: modification of the contents or mode of a file
** R: renaming of a file
** T: change in the type of the file
** U: file is unmerged (you must complete the merge before it can be committed)
** X: "unknown" change type (most probably a bug, please report it)
**
** Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy).
** Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.
** ============================================================================================================================ */

@@ -117,3 +123,3 @@ var map = {

return map[code];
return map[code.charAt(0)];
}

@@ -131,3 +137,3 @@

var result = {
filename: parts[1],
filename: parts[2] || parts[1],
status: codeToStatus(parts[0])

@@ -134,0 +140,0 @@ }

{
"name": "staged-git-files",
"version": "0.0.4",
"version": "1.0.0",
"devDependencies": {

@@ -5,0 +5,0 @@ "should": "~2.0.1",

@@ -109,2 +109,24 @@ describe("As a module", function() {

it("I should find renames", function(done) {
addAndCommitFile(function(err, data) {
if (err) {
done(err);
} else {
var newFileName = randomFileName([8, 3]);
moveFile({
oldFileName: data.filename,
newFileName: newFileName
}, function(err) {
var sgf = newSGF();
sgf(asyncCatch(done, function(results) {
results.length.should.equal(1);
results[0].filename.should.equal(newFileName);
results[0].status.should.equal("Renamed");
}));
});
}
});
});
it("if includeContent is set to true I should return the file paths, their git status and the content", function(done) {

@@ -111,0 +133,0 @@ addFile(function(err, data) {

@@ -63,3 +63,3 @@ require("should");

var randomFileName = function(lengths) {
randomFileName = function(lengths) {
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

@@ -88,2 +88,21 @@ var filename = randomString(possible, lengths[0]);

moveFile = function(opts, callback) {
var oldPath = test_folder + "/" + opts.oldFileName;
var newPath = test_folder + "/" + opts.newFileName;
fs.rename(oldPath, newPath, function(err) {
if (err) {
callback(err);
} else {
run("git add " + opts.oldFileName + " " + opts.newFileName, function(err, stdout, stderr) {
if (err || stderr) {
callback(err || new Error(stderr));
} else {
callback(null, opts);
}
});
}
});
}
newFile = function(opts, callback) {

@@ -90,0 +109,0 @@