Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix subfolder git detection #560

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 5 additions & 10 deletions lib/mru-item-view.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use babel'

import {Directory} from 'atom'
import getIconServices from './get-icon-services'
import path from 'path'

export default class MRUItemView {
initialize (listView, item) {
async initialize (listView, item) {
this.listView = listView
this.item = item

Expand All @@ -17,7 +17,7 @@ export default class MRUItemView {
this.itemPath = item.getPath()
}

const repo = MRUItemView.repositoryForPath(this.itemPath)
const repo = await MRUItemView.repositoryForPath(this.itemPath)
if (repo != null) {
const statusIconDiv = document.createElement('div')
const status = repo.getCachedPathStatus(this.itemPath)
Expand Down Expand Up @@ -56,14 +56,9 @@ export default class MRUItemView {
this.element.classList.remove('selected')
}

static repositoryForPath (filePath) {
static async repositoryForPath (filePath) {
if (filePath) {
const projectPaths = atom.project.getPaths()
for (let i = 0; i < projectPaths.length; i++) {
if (filePath === projectPaths[i] || filePath.startsWith(projectPaths[i] + path.sep)) {
return atom.project.getRepositories()[i]
}
}
return atom.project.repositoryForDirectory(new Directory(filePath))
}
return null
}
Expand Down
6 changes: 2 additions & 4 deletions lib/tab-view.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
path = require 'path'
{Disposable, CompositeDisposable} = require 'atom'
{Directory, Disposable, CompositeDisposable} = require 'atom'
getIconServices = require './get-icon-services'

layout = require './layout'
Expand Down Expand Up @@ -263,9 +263,7 @@ class TabView
@updateVcsStatus(repo)

repoForPath: ->
for dir in atom.project.getDirectories()
return atom.project.repositoryForDirectory(dir) if dir.contains @path
Promise.resolve(null)
return atom.project.repositoryForDirectory(new Directory(@path))

# Update the VCS status property of this tab using the repo.
updateVcsStatus: (repo, status) ->
Expand Down
8 changes: 6 additions & 2 deletions spec/tabs-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ describe "TabBarView", ->
expect(tabBar2.tabForItem(pane2.getActiveItem()).element.querySelector('.title')).not.toHaveClass 'temp'

describe "integration with version control systems", ->
[repository, tab, tab1] = []
[repository, repositorySpy, tab, tab1] = []

beforeEach ->
tab = tabBar.tabForItem(editor1)
Expand Down Expand Up @@ -1476,7 +1476,7 @@ describe "TabBarView", ->
callback(event) for callback in @changeStatusesCallbacks ? []

# Mock atom.project to pretend we are working within a repository
spyOn(atom.project, 'repositoryForDirectory').andReturn Promise.resolve(repository)
repositorySpy = spyOn(atom.project, 'repositoryForDirectory').andReturn Promise.resolve(repository)

atom.config.set "tabs.enableVcsColoring", true

Expand Down Expand Up @@ -1518,6 +1518,10 @@ describe "TabBarView", ->
expect(repository.getCachedPathStatus.calls.length).toBe 0

it "does not update status for items not in the repository", ->
atom.config.set "tabs.enableVcsColoring", false
repositorySpy.andReturn Promise.resolve(null)
atom.config.set "tabs.enableVcsColoring", true

tab1.updateVcsStatus.reset()
repository.emitDidChangeStatuses()
expect(tab1.updateVcsStatus.calls.length).toEqual 0
Expand Down