Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Having contents for before and after for modified files, resolves #15
  • Loading branch information
bahmutov committed Aug 25, 2015
1 parent a4f6ad7 commit 8eee2b2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
7 changes: 5 additions & 2 deletions README.md
@@ -1,4 +1,4 @@
# ggit v1.0.0
# ggit v1.1.0

> Local promise-returning git command wrappers
Expand Down Expand Up @@ -280,10 +280,13 @@ The object `files` groups filenames by modification property
{
diff: 'A' // or C, M, D
name: 'src/something.js' // relative to the repo root
filename: 'full path',
before: 'file contents', // if available (for example M, D)
after: 'file contents' // if available (for A, M)
}
```

This is a wrapper around command `git diff --name-status --diff-filter=ACMD`
This is a wrapper around command `git diff --name-status --diff-filter=ACMD`.



Expand Down
5 changes: 4 additions & 1 deletion docs/changed-files.md
Expand Up @@ -22,9 +22,12 @@ The object `files` groups filenames by modification property
{
diff: 'A' // or C, M, D
name: 'src/something.js' // relative to the repo root
filename: 'full path',
before: 'file contents', // if available (for example M, D)
after: 'file contents' // if available (for A, M)
}
```

This is a wrapper around command `git diff --name-status --diff-filter=ACMD`
This is a wrapper around command `git diff --name-status --diff-filter=ACMD`.


2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "ggit",
"description": "Local promise-returning git command wrappers",
"version": "1.0.0",
"version": "1.1.0",
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",
"bin": {
"ggit": "./bin/ggit.js",
Expand Down
15 changes: 8 additions & 7 deletions src/changed-files.js
Expand Up @@ -68,7 +68,14 @@ function changedFiles(needContents) {
}).then(function (repoPath) {
var promise = Q.when(grouped);

// TODO move full filename setting here
_.each(grouped, function (list) {
la(check.array(list), 'expected list of modifications', list,
'in', grouped);
list.forEach(function (info) {
la(check.unemptyString(info.name), 'missing file name', info);
info.filename = join(repoPath, info.name);
});
});

_.each(grouped, function (list, modification) {
console.log('fetching contents for modification', modification);
Expand All @@ -77,8 +84,6 @@ function changedFiles(needContents) {
if (modification === 'M') {
// need both repo and local copy
list.forEach(function (info) {
la(check.unemptyString(info.name), 'missing file name', info);
info.filename = join(repoPath, info.name);
info.after = read(info.filename, 'utf8');
promise = promise.then(function () {
return fileContentsInRepo(info.name);
Expand All @@ -90,14 +95,10 @@ function changedFiles(needContents) {
} else if (modification === 'A') {
// for added files, only grab file contents
list.forEach(function (info) {
la(check.unemptyString(info.name), 'missing file name', info);
info.filename = join(repoPath, info.name);
info.after = read(info.filename, 'utf8');
});
} else if (modification === 'D') {
list.forEach(function (info) {
la(check.unemptyString(info.name), 'missing file name', info);
info.filename = join(repoPath, info.name);
promise = promise.then(function () {
return fileContentsInRepo(info.name);
}).then(function (contents) {
Expand Down

0 comments on commit 8eee2b2

Please sign in to comment.