mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Merge pull request #12008 from atom/as-ns-recreate-destroyed-repo
Recreate Repository if the same project is added after being removed
This commit is contained in:
commit
a5fdf3e18a
@ -363,6 +363,24 @@ describe "Project", ->
|
||||
# Verify that the result is cached.
|
||||
expect(atom.project.repositoryForDirectory(directory)).toBe(promise)
|
||||
|
||||
it "creates a new repository if a previous one with the same directory had been destroyed", ->
|
||||
repository = null
|
||||
directory = new Directory(path.join(__dirname, '..'))
|
||||
|
||||
waitsForPromise ->
|
||||
atom.project.repositoryForDirectory(directory).then (repo) -> repository = repo
|
||||
|
||||
runs ->
|
||||
expect(repository.isDestroyed()).toBe(false)
|
||||
repository.destroy()
|
||||
expect(repository.isDestroyed()).toBe(true)
|
||||
|
||||
waitsForPromise ->
|
||||
atom.project.repositoryForDirectory(directory).then (repo) -> repository = repo
|
||||
|
||||
runs ->
|
||||
expect(repository.isDestroyed()).toBe(false)
|
||||
|
||||
describe ".setPaths(paths)", ->
|
||||
describe "when path is a file", ->
|
||||
it "sets its path to the files parent directory and updates the root directory", ->
|
||||
|
@ -130,6 +130,10 @@ class GitRepository
|
||||
@async.destroy()
|
||||
@async = null
|
||||
|
||||
# Public: Returns a {Boolean} indicating if this repository has been destroyed.
|
||||
isDestroyed: ->
|
||||
not @repo?
|
||||
|
||||
# Public: Invoke the given callback when this GitRepository's destroy() method
|
||||
# is invoked.
|
||||
#
|
||||
|
@ -129,6 +129,7 @@ class Project extends Model
|
||||
# registered in the future that could supply a Repository for the
|
||||
# directory.
|
||||
@repositoryPromisesByPath.delete(pathForDirectory) unless repo?
|
||||
repo?.onDidDestroy?(=> @repositoryPromisesByPath.delete(pathForDirectory))
|
||||
repo
|
||||
@repositoryPromisesByPath.set(pathForDirectory, promise)
|
||||
promise
|
||||
|
Loading…
Reference in New Issue
Block a user