From a0374af0d272cb308ab7b6b82a17aa8494eda055 Mon Sep 17 00:00:00 2001 From: Hubot Date: Mon, 26 Jul 2021 12:55:52 -0400 Subject: [PATCH 1/4] 1.59.0-beta0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d103290692a..90866f19a6b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom", "productName": "Atom", - "version": "1.59.0-dev", + "version": "1.59.0-beta0", "description": "A hackable text editor for the 21st Century.", "main": "./src/main-process/main.js", "repository": { From 967d63bb5eb95bc04ce20e94ee0778854028b251 Mon Sep 17 00:00:00 2001 From: Ruby Allison Rose Date: Sun, 2 Jan 2022 16:38:49 -0800 Subject: [PATCH 2/4] fix(git-diff): Now targets the closest parent repo to the open file. Initial fix to `helpers` done by Utkarsh, Spec written by me. Co-authored-by: Utkarsh Gupta --- packages/git-diff/lib/helpers.js | 7 +- .../git-diff/spec/git-diff-subfolder-spec.js | 72 +++++++++++++++++++ 2 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 packages/git-diff/spec/git-diff-subfolder-spec.js diff --git a/packages/git-diff/lib/helpers.js b/packages/git-diff/lib/helpers.js index 974d2ff429c..4d3d12d0d0c 100644 --- a/packages/git-diff/lib/helpers.js +++ b/packages/git-diff/lib/helpers.js @@ -1,10 +1,9 @@ 'use babel'; +import { Directory } from 'atom'; export default async function(goalPath) { - for (const directory of atom.project.getDirectories()) { - if (goalPath === directory.getPath() || directory.contains(goalPath)) { - return atom.project.repositoryForDirectory(directory); - } + if (goalPath) { + return atom.project.repositoryForDirectory(new Directory(goalPath)); } return null; } diff --git a/packages/git-diff/spec/git-diff-subfolder-spec.js b/packages/git-diff/spec/git-diff-subfolder-spec.js new file mode 100644 index 00000000000..28caaa302f8 --- /dev/null +++ b/packages/git-diff/spec/git-diff-subfolder-spec.js @@ -0,0 +1,72 @@ +const path = require('path'); +const fs = require('fs-plus'); +const temp = require('temp').track(); + +describe('GitDiff when targeting nested repository', () => { + let editor, editorElement, projectPath, screenUpdates; + + beforeEach(() => { + screenUpdates = 0; + spyOn(window, 'requestAnimationFrame').andCallFake(fn => { + fn(); + screenUpdates++; + }); + spyOn(window, 'cancelAnimationFrame').andCallFake(i => null); + + projectPath = temp.mkdirSync('git-diff-spec-'); + + fs.copySync(path.join(__dirname, 'fixtures', 'working-dir'), projectPath); + fs.moveSync( + path.join(projectPath, 'git.git'), + path.join(projectPath, '.git') + ); + + // The nested repo doesn't need to be managed by the temp module because + // it's a part of our test environment. + const nestedPath = path.join(projectPath, 'nested-repository'); + // When instantiating a GitRepository, the repository will always point + // to the .git folder in it's path. + const targetRepositoryPath = path.join(nestedPath, '.git'); + // Initialize the repository contents. + fs.copySync(path.join(__dirname, 'fixtures', 'working-dir'), nestedPath); + fs.moveSync( + path.join(nestedPath, 'git.git'), + path.join(nestedPath, '.git') + ); + + atom.project.setPaths([projectPath]); + + jasmine.attachToDOM(atom.workspace.getElement()); + + waitsForPromise(async () => { + await atom.workspace.open(path.join(nestedPath, 'sample.js')); + await atom.packages.activatePackage('git-diff'); + }); + + runs(() => { + editor = atom.workspace.getActiveTextEditor(); + editorElement = atom.views.getView(editor); + }); + }); + + afterEach(() => { + temp.cleanup(); + }); + + describe('When git-diff targets a file in a nested git-repository', () => { + /*** + * Non-hack regression prevention for nested repositories. If we know + * that our project path contains two repositories, we can ensure that + * git-diff is targeting the correct one by creating an artificial change + * in the ancestor repository, which doesn't effect the target repository. + * If our diff shows any kind of change to our target file, we're targeting + * the incorrect repository. + */ + it("uses the innermost repository", () => { + //waitsForPromise(async () => await new Promise(resolve => setTimeout(resolve, 4000))); + //waitsFor(() => !! atom.packages.isPackageLoaded("git-diff")); + waitsFor(() => screenUpdates > 0); + runs(() => expect(editor.getMarkers().length).toBe(0)); + }); + }); +}); From 4dc862073c6dbd91047b6c2b87b06e40fec8e8eb Mon Sep 17 00:00:00 2001 From: Ruby Allison Rose Date: Mon, 3 Jan 2022 15:55:50 -0800 Subject: [PATCH 3/4] fix(git-diff): Fixed linter issue and caught unnoticed spec issue. --- .../git-diff/spec/git-diff-subfolder-spec.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/git-diff/spec/git-diff-subfolder-spec.js b/packages/git-diff/spec/git-diff-subfolder-spec.js index 28caaa302f8..13aaab125cb 100644 --- a/packages/git-diff/spec/git-diff-subfolder-spec.js +++ b/packages/git-diff/spec/git-diff-subfolder-spec.js @@ -24,9 +24,6 @@ describe('GitDiff when targeting nested repository', () => { // The nested repo doesn't need to be managed by the temp module because // it's a part of our test environment. const nestedPath = path.join(projectPath, 'nested-repository'); - // When instantiating a GitRepository, the repository will always point - // to the .git folder in it's path. - const targetRepositoryPath = path.join(nestedPath, '.git'); // Initialize the repository contents. fs.copySync(path.join(__dirname, 'fixtures', 'working-dir'), nestedPath); fs.moveSync( @@ -58,15 +55,20 @@ describe('GitDiff when targeting nested repository', () => { * Non-hack regression prevention for nested repositories. If we know * that our project path contains two repositories, we can ensure that * git-diff is targeting the correct one by creating an artificial change - * in the ancestor repository, which doesn't effect the target repository. - * If our diff shows any kind of change to our target file, we're targeting - * the incorrect repository. + * in the ancestor repository, which is percieved differently within the + * child. In this case, creating a new file will not generate markers in + * the ancestor repo, even if there are changes; but changes will be + * marked within the child repo. So all we have to do is check if + * markers exist and we know we're targeting the proper repository, + * If no markers exist, we're targeting an ancestor repo. */ - it("uses the innermost repository", () => { - //waitsForPromise(async () => await new Promise(resolve => setTimeout(resolve, 4000))); - //waitsFor(() => !! atom.packages.isPackageLoaded("git-diff")); + it('uses the innermost repository', () => { + editor.insertText('a'); waitsFor(() => screenUpdates > 0); - runs(() => expect(editor.getMarkers().length).toBe(0)); + runs(() => { + expect(editorElement.querySelectorAll('.git-line-modified').length) + .toBe(1); + }); }); }); }); From 8b2e42e9fbe3866556e7e456ca55e6f3eb947548 Mon Sep 17 00:00:00 2001 From: Ruby Allison Rose Date: Mon, 3 Jan 2022 18:14:04 -0800 Subject: [PATCH 4/4] chore: I forgot how touchy the linter settings were. --- packages/git-diff/spec/git-diff-subfolder-spec.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/git-diff/spec/git-diff-subfolder-spec.js b/packages/git-diff/spec/git-diff-subfolder-spec.js index 13aaab125cb..db1cf0c392c 100644 --- a/packages/git-diff/spec/git-diff-subfolder-spec.js +++ b/packages/git-diff/spec/git-diff-subfolder-spec.js @@ -66,8 +66,9 @@ describe('GitDiff when targeting nested repository', () => { editor.insertText('a'); waitsFor(() => screenUpdates > 0); runs(() => { - expect(editorElement.querySelectorAll('.git-line-modified').length) - .toBe(1); + expect( + editorElement.querySelectorAll('.git-line-modified').length + ).toBe(1); }); }); });