Don't destroy repo in ::removePath if it is still needed

This commit is contained in:
Max Brunsfeld
2015-02-19 10:28:54 -08:00
parent d4298bf077
commit cf60855245
2 changed files with 7 additions and 1 deletions

View File

@@ -352,6 +352,12 @@ describe "Project", ->
expect(atom.project.getPaths()).toEqual(originalPaths)
expect(onDidChangePathsSpy).not.toHaveBeenCalled()
it "doesn't destroy the repository if it is shared by another root directory", ->
atom.project.setPaths([__dirname, path.join(__dirname, "..", "src")])
atom.project.removePath(__dirname)
expect(atom.project.getPaths()).toEqual([path.join(__dirname, "..", "src")])
expect(atom.project.getRepositories()[0].isSubmodule("src")).toBe false
describe ".relativize(path)", ->
it "returns the path, relative to whichever root directory it is inside of", ->
atom.project.addPath(temp.mkdirSync("another-path"))

View File

@@ -225,7 +225,7 @@ class Project extends Model
[removedDirectory] = @rootDirectories.splice(indexToRemove, 1)
[removedRepository] = @repositories.splice(indexToRemove, 1)
removedDirectory.off()
removedRepository?.destroy()
removedRepository?.destroy() unless removedRepository in @repositories
@emit "path-changed"
@emitter.emit "did-change-paths", @getPaths()
true