mirror of
https://github.com/atom/atom.git
synced 2026-02-14 08:35:11 -05:00
Make project's Git repository a window global
This allows it to operate independently of the project and mirror the availability of the root view and project.
This commit is contained in:
@@ -419,12 +419,10 @@ class Buffer
|
||||
return match[0][0] != '\t'
|
||||
undefined
|
||||
|
||||
getRepo: -> @project?.repo
|
||||
|
||||
checkoutHead: ->
|
||||
path = @getPath()
|
||||
return unless path
|
||||
if @getRepo()?.checkoutHead(path)
|
||||
if git?.checkoutHead(path)
|
||||
@trigger 'git-status-changed'
|
||||
|
||||
scheduleStoppedChangingEvent: ->
|
||||
|
||||
@@ -7,7 +7,6 @@ EditSession = require 'edit-session'
|
||||
EventEmitter = require 'event-emitter'
|
||||
Directory = require 'directory'
|
||||
ChildProcess = require 'child-process'
|
||||
Git = require 'git'
|
||||
|
||||
module.exports =
|
||||
class Project
|
||||
@@ -35,8 +34,6 @@ class Project
|
||||
grammarOverridesByPath: @grammarOverridesByPath
|
||||
|
||||
destroy: ->
|
||||
@repo?.destroy()
|
||||
@repo = null
|
||||
editSession.destroy() for editSession in @getEditSessions()
|
||||
|
||||
addGrammarOverrideForPath: (path, grammar) ->
|
||||
@@ -60,10 +57,8 @@ class Project
|
||||
if path?
|
||||
directory = if fs.isDirectory(path) then path else fs.directory(path)
|
||||
@rootDirectory = new Directory(directory)
|
||||
@repo = Git.open(path)
|
||||
else
|
||||
@rootDirectory = null
|
||||
@repo = null
|
||||
|
||||
@trigger "path-changed"
|
||||
|
||||
@@ -85,7 +80,7 @@ class Project
|
||||
@ignoreRepositoryPath(path)
|
||||
|
||||
ignoreRepositoryPath: (path) ->
|
||||
config.get("core.hideGitIgnoredFiles") and @repo?.isPathIgnored(fs.join(@getPath(), path))
|
||||
config.get("core.hideGitIgnoredFiles") and git?.isPathIgnored(fs.join(@getPath(), path))
|
||||
|
||||
resolve: (filePath) ->
|
||||
filePath = fs.join(@getPath(), filePath) unless filePath[0] == '/'
|
||||
|
||||
@@ -91,6 +91,7 @@ window.handleWindowEvents = ->
|
||||
window.buildProjectAndRootView = ->
|
||||
RootView = require 'root-view'
|
||||
Project = require 'project'
|
||||
Git = require 'git'
|
||||
|
||||
pathToOpen = atom.getPathToOpen()
|
||||
windowState = atom.getRootViewStateForPath(pathToOpen) ? {}
|
||||
@@ -102,6 +103,11 @@ window.buildProjectAndRootView = ->
|
||||
|
||||
$(rootViewParentSelector).append(rootView)
|
||||
|
||||
window.git = Git.open(project.getPath())
|
||||
project.on 'path-changed', ->
|
||||
window.git?.destroy()
|
||||
window.git = Git.open(project.getPath())
|
||||
|
||||
window.stylesheetElementForId = (id) ->
|
||||
$("head style[id='#{id}']")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user