diff --git a/README.md b/README.md index 1517ea7..224dcf9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ggit v1.0.0 +# ggit v1.1.0 > Local promise-returning git command wrappers @@ -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`. diff --git a/docs/changed-files.md b/docs/changed-files.md index 00f5aae..131bc01 100644 --- a/docs/changed-files.md +++ b/docs/changed-files.md @@ -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`. diff --git a/package.json b/package.json index a6e7359..d34b2bc 100644 --- a/package.json +++ b/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 ", "bin": { "ggit": "./bin/ggit.js", diff --git a/src/changed-files.js b/src/changed-files.js index e0d78cd..2071064 100644 --- a/src/changed-files.js +++ b/src/changed-files.js @@ -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); @@ -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); @@ -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) {