Use GitRepository rather than Git

This commit is contained in:
Ben Ogle
2014-09-22 11:07:41 -07:00
parent 84425f238a
commit 7a429b024e
3 changed files with 21 additions and 21 deletions

View File

@@ -4,7 +4,7 @@
module.exports =
BufferedNodeProcess: require '../src/buffered-node-process'
BufferedProcess: require '../src/buffered-process'
GitRepository: require '../src/git'
GitRepository: require '../src/git-repository'
Point: Point
Range: Range

View File

@@ -1,5 +1,5 @@
temp = require 'temp'
Git = require '../src/git'
GitRepository = require '../src/git-repository'
fs = require 'fs-plus'
path = require 'path'
Task = require '../src/task'
@@ -10,7 +10,7 @@ copyRepository = ->
fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git'))
workingDirPath
describe "Git", ->
fdescribe "GitRepository", ->
repo = null
beforeEach ->
@@ -22,28 +22,28 @@ describe "Git", ->
describe "@open(path)", ->
it "returns null when no repository is found", ->
expect(Git.open(path.join(temp.dir, 'nogit.txt'))).toBeNull()
expect(GitRepository.open(path.join(temp.dir, 'nogit.txt'))).toBeNull()
describe "new Git(path)", ->
describe "new GitRepository(path)", ->
it "throws an exception when no repository is found", ->
expect(-> new Git(path.join(temp.dir, 'nogit.txt'))).toThrow()
expect(-> new GitRepository(path.join(temp.dir, 'nogit.txt'))).toThrow()
describe ".getPath()", ->
it "returns the repository path for a .git directory path", ->
repo = new Git(path.join(__dirname, 'fixtures', 'git', 'master.git', 'HEAD'))
repo = new GitRepository(path.join(__dirname, 'fixtures', 'git', 'master.git', 'HEAD'))
expect(repo.getPath()).toBe path.join(__dirname, 'fixtures', 'git', 'master.git')
it "returns the repository path for a repository path", ->
repo = new Git(path.join(__dirname, 'fixtures', 'git', 'master.git'))
repo = new GitRepository(path.join(__dirname, 'fixtures', 'git', 'master.git'))
expect(repo.getPath()).toBe path.join(__dirname, 'fixtures', 'git', 'master.git')
describe ".isPathIgnored(path)", ->
it "returns true for an ignored path", ->
repo = new Git(path.join(__dirname, 'fixtures', 'git', 'ignore.git'))
repo = new GitRepository(path.join(__dirname, 'fixtures', 'git', 'ignore.git'))
expect(repo.isPathIgnored('a.txt')).toBeTruthy()
it "returns false for a non-ignored path", ->
repo = new Git(path.join(__dirname, 'fixtures', 'git', 'ignore.git'))
repo = new GitRepository(path.join(__dirname, 'fixtures', 'git', 'ignore.git'))
expect(repo.isPathIgnored('b.txt')).toBeFalsy()
describe ".isPathModified(path)", ->
@@ -51,7 +51,7 @@ describe "Git", ->
beforeEach ->
workingDirPath = copyRepository()
repo = new Git(workingDirPath)
repo = new GitRepository(workingDirPath)
filePath = path.join(workingDirPath, 'a.txt')
newPath = path.join(workingDirPath, 'new-path.txt')
@@ -75,7 +75,7 @@ describe "Git", ->
beforeEach ->
workingDirPath = copyRepository()
repo = new Git(workingDirPath)
repo = new GitRepository(workingDirPath)
filePath = path.join(workingDirPath, 'a.txt')
newPath = path.join(workingDirPath, 'new-path.txt')
fs.writeFileSync(newPath, "i'm new here")
@@ -92,7 +92,7 @@ describe "Git", ->
beforeEach ->
workingDirPath = copyRepository()
repo = new Git(workingDirPath)
repo = new GitRepository(workingDirPath)
filePath = path.join(workingDirPath, 'a.txt')
it "no longer reports a path as modified after checkout", ->
@@ -124,7 +124,7 @@ describe "Git", ->
beforeEach ->
workingDirPath = copyRepository()
repo = new Git(workingDirPath)
repo = new GitRepository(workingDirPath)
filePath = path.join(workingDirPath, 'a.txt')
fs.writeFileSync(filePath, 'ch ch changes')
@@ -153,7 +153,7 @@ describe "Git", ->
describe ".destroy()", ->
it "throws an exception when any method is called after it is called", ->
repo = new Git(require.resolve('./fixtures/git/master.git/HEAD'))
repo = new GitRepository(require.resolve('./fixtures/git/master.git/HEAD'))
repo.destroy()
expect(-> repo.getShortHead()).toThrow()
@@ -162,7 +162,7 @@ describe "Git", ->
beforeEach ->
workingDirectory = copyRepository()
repo = new Git(workingDirectory)
repo = new GitRepository(workingDirectory)
filePath = path.join(workingDirectory, 'file.txt')
it "trigger a status-changed event when the new status differs from the last cached one", ->
@@ -182,7 +182,7 @@ describe "Git", ->
beforeEach ->
workingDirectory = copyRepository()
repo = new Git(workingDirectory)
repo = new GitRepository(workingDirectory)
directoryPath = path.join(workingDirectory, 'dir')
filePath = path.join(directoryPath, 'b.txt')
@@ -197,7 +197,7 @@ describe "Git", ->
beforeEach ->
workingDirectory = copyRepository()
repo = new Git(workingDirectory)
repo = new GitRepository(workingDirectory)
modifiedPath = path.join(workingDirectory, 'file.txt')
newPath = path.join(workingDirectory, 'untracked.txt')
cleanPath = path.join(workingDirectory, 'other.txt')

View File

@@ -13,7 +13,7 @@ TextBuffer = require 'text-buffer'
Editor = require './editor'
Task = require './task'
Git = require './git'
GitRepository = require './git-repository'
# Extended: Represents a project that's opened in Atom.
#
@@ -70,7 +70,7 @@ class Project extends Model
Section: Accessing the git repository
###
# Public: Returns the {Git} repository if available.
# Public: Returns the {GitRepository} if available.
getRepo: -> @repo
###
@@ -93,7 +93,7 @@ class Project extends Model
if projectPath?
directory = if fs.isDirectorySync(projectPath) then projectPath else path.dirname(projectPath)
@rootDirectory = new Directory(directory)
if @repo = Git.open(directory, project: this)
if @repo = GitRepository.open(directory, project: this)
@repo.refreshIndex()
@repo.refreshStatus()
else