Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5178dbf
Make Unstaged Changes div focusable
kuychaco Jan 24, 2017
e10790b
Rename command for discarding changes in file
kuychaco Jan 24, 2017
eb6dcbe
Add discardChangesInBuffer function with tests
kuychaco Jan 26, 2017
476e12a
Modify buffer in transaction to allow undoing discard actions
kuychaco Jan 26, 2017
e3c4daf
Implement GitController#discardLines and test
kuychaco Jan 26, 2017
eb6d14e
Add discard selection context menu option for untaged file diff
kuychaco Jan 26, 2017
6ff442f
Add TODO to handle no-new-line case
kuychaco Jan 26, 2017
0263946
:fire: console.log
kuychaco Jan 26, 2017
9bd128a
Add createBlob and restoreBlob to GitShellOutStrategy
kuychaco Jan 27, 2017
569a1fa
Create FileDiscardHistory model
kuychaco Jan 27, 2017
2044feb
Add ability to undo last discard action
kuychaco Jan 27, 2017
4a5a489
Fix borked test
kuychaco Jan 27, 2017
3d0df0f
Throw error if there's no match when discarding added lines
kuychaco Jan 27, 2017
097782b
Add FilePatch-header
simurai Jan 24, 2017
803e8d5
:shirt:
kuychaco Jan 27, 2017
853b630
Merge remote-tracking branch 'origin/master' into ku-discard-lines
kuychaco Jan 27, 2017
5093966
Wire up buttons in file diff header
kuychaco Jan 27, 2017
e2a9737
Move discard context menu items to separate section
kuychaco Jan 27, 2017
8455e3f
Add to GitShellOutStrategy#isPartiallyStaged
kuychaco Jan 27, 2017
2b1fdc0
Only show diff view button for viewing corresonding diff if one exists
kuychaco Jan 27, 2017
42c6a61
Align FilePatchView-title
simurai Jan 27, 2017
d1862a8
Add `github:view-corresponding-diff` command
kuychaco Jan 27, 2017
2650171
Add command `github:undo-last-file-diff-discard`
kuychaco Jan 27, 2017
d672567
:shirt:
kuychaco Jan 27, 2017
3f4ce84
Undo discard with `cmd-z`
kuychaco Jan 27, 2017
9a5747e
:fire: Remove toggle styles
simurai Jan 27, 2017
bba2bfc
Truncate FilePatchView-title
simurai Jan 27, 2017
cac3ccf
Merge branch 'ku-discard-lines' of https://github.com/atom/github int…
simurai Jan 27, 2017
357a813
Perform safety check before performing destructive action to avoid races
kuychaco Jan 27, 2017
2adf514
Dispose of newly created buffer after discard
kuychaco Jan 27, 2017
d72302d
:fire: comment
kuychaco Jan 27, 2017
fb0d10a
:art: use `until` in tests
kuychaco Feb 1, 2017
038c09f
Fix test
kuychaco Feb 1, 2017
2f218fd
Fix flakey tests using `until`
kuychaco Feb 1, 2017
9c8a2e0
:art:
kuychaco Feb 1, 2017
455cf45
:shirt:
kuychaco Feb 1, 2017
9ebd6a7
Quietly select corresponding item in StagingView
kuychaco Feb 2, 2017
be5e400
Use `core:undo` instead of `cmd-z`
kuychaco Feb 5, 2017
1738ea5
:art: Create `CannotRestoreError`
kuychaco Feb 5, 2017
34bdd81
Log non-CannotRestoreError errors
kuychaco Feb 5, 2017
d6799a0
:art: use assert.async.isTrue rather than until
kuychaco Feb 5, 2017
5281ad9
:art: use assert.async.equal instead of until
kuychaco Feb 5, 2017
8073c37
:shirt:
kuychaco Feb 5, 2017
bb3d953
Allow blob creation with stdin in GSOS#createBlob
kuychaco Feb 5, 2017
771c582
Fix test description
kuychaco Feb 5, 2017
03a9a68
Add GSOS#getBlobContents(sha)
kuychaco Feb 5, 2017
11960f9
Persist discard history in git config across refresh and Atom windows
kuychaco Feb 8, 2017
3f3633d
Limit discard history to prevent unbounded growth
kuychaco Feb 8, 2017
0a222b3
Merge remote-tracking branch 'origin/master' into ku-discard-lines
kuychaco Feb 8, 2017
4057109
Clear discard history if snapshot is expired
kuychaco Feb 9, 2017
18d768e
:shirt:
kuychaco Feb 9, 2017
3dd6f96
Add button in file diff to stage or unstage all
kuychaco Feb 9, 2017
1a048a0
Clean up window focus listener
kuychaco Feb 9, 2017
7ffcfb4
Set default discard history to empty object
kuychaco Feb 9, 2017
684d729
getHistoryForPath -> getLastHistorySnapshotsForPath
kuychaco Feb 10, 2017
50b306d
Open pre-discard versin of file in new buffer
kuychaco Feb 10, 2017
a219518
Move hasUndoHistory method from GitController to FilePatchController
kuychaco Feb 10, 2017
7e62f54
Add test for openFileInNewBuffer
kuychaco Feb 10, 2017
b788334
Fix tests
kuychaco Feb 10, 2017
06cfcd5
:art:
kuychaco Feb 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add to GitShellOutStrategy#isPartiallyStaged
  • Loading branch information
kuychaco committed Jan 27, 2017
commit 8455e3f802a1ce916e9ec33ab397baf298a93e66
13 changes: 13 additions & 0 deletions lib/git-shell-out-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,19 @@ export default class GitShellOutStrategy {
return rawDiffs[0];
}

async isPartiallyStaged(filePath) {
const args = ['status', '--short', '--', filePath];
const output = await this.exec(args);
const results = output.trim().split(LINE_ENDING_REGEX);
if (results.length === 2) {
return true;
} else if (results.length === 1) {
return ['MM', 'AM', 'MD'].includes(results[0].slice(0, 2));
} else {
throw new Error(`Unexpected output for ${args.join(' ')}: ${output}`);
}
}

/**
* Miscellaneous getters
*/
Expand Down
36 changes: 36 additions & 0 deletions test/git-shell-out-strategy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,42 @@ describe('Git commands', function() {
});
});

describe('isPartiallyStaged(filePath)', () => {
it('returns true if specified file path is partially staged', async () => {
const workingDirPath = await cloneRepository('three-files');
const git = new GitShellOutStrategy(workingDirPath);
fs.writeFileSync(path.join(workingDirPath, 'a.txt'), 'modified file', 'utf8');
fs.writeFileSync(path.join(workingDirPath, 'new-file.txt'), 'foo\nbar\nbaz\n', 'utf8');
fs.writeFileSync(path.join(workingDirPath, 'b.txt'), 'blah blah blah', 'utf8');
fs.unlinkSync(path.join(workingDirPath, 'c.txt'));

assert.isFalse(await git.isPartiallyStaged('a.txt'));
assert.isFalse(await git.isPartiallyStaged('b.txt'));
assert.isFalse(await git.isPartiallyStaged('c.txt'));
assert.isFalse(await git.isPartiallyStaged('new-file.txt'));

await git.stageFiles(['a.txt', 'b.txt', 'c.txt', 'new-file.txt']);
assert.isFalse(await git.isPartiallyStaged('a.txt'));
assert.isFalse(await git.isPartiallyStaged('b.txt'));
assert.isFalse(await git.isPartiallyStaged('c.txt'));
assert.isFalse(await git.isPartiallyStaged('new-file.txt'));

// modified on both
fs.writeFileSync(path.join(workingDirPath, 'a.txt'), 'more mods', 'utf8');
// modified in working directory, added on index
fs.writeFileSync(path.join(workingDirPath, 'new-file.txt'), 'foo\nbar\nbaz\nqux\n', 'utf8');
// deleted in working directory, modified on index
fs.unlinkSync(path.join(workingDirPath, 'b.txt'));
// untracked in working directory, deleted on index
fs.writeFileSync(path.join(workingDirPath, 'c.txt'), 'back baby', 'utf8');

assert.isTrue(await git.isPartiallyStaged('a.txt'));
assert.isTrue(await git.isPartiallyStaged('b.txt'));
assert.isTrue(await git.isPartiallyStaged('c.txt'));
assert.isTrue(await git.isPartiallyStaged('new-file.txt'));
});
});

describe('isMerging', function() {
it('returns true if `.git/MERGE_HEAD` exists', async function() {
const workingDirPath = await cloneRepository('merge-conflict');
Expand Down