From c62b7cc71027cc6ef279a24c26f4f31f7337db60 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 22 Sep 2014 11:01:14 -0700 Subject: [PATCH 1/4] Deprecate requiring `Git` --- exports/atom.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/exports/atom.coffee b/exports/atom.coffee index 985fd4782..c238e4fa9 100644 --- a/exports/atom.coffee +++ b/exports/atom.coffee @@ -1,12 +1,17 @@ {Point, Range} = require 'text-buffer' +{deprecate} = require 'grim' module.exports = BufferedNodeProcess: require '../src/buffered-node-process' BufferedProcess: require '../src/buffered-process' - Git: require '../src/git' + GitRepository: require '../src/git' Point: Point Range: Range +Object.defineProperty module.exports, 'Git', get: -> + deprecate "Please require `GitRepository` instead of `Git`: `{Git} = require 'atom'`" + module.exports.GitRepository + # The following classes can't be used from a Task handler and should therefore # only be exported when not running as a child node process unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE From 84425f238a2e51910f2f759e682eb9fed6ac8872 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 22 Sep 2014 11:07:19 -0700 Subject: [PATCH 2/4] Rename git -> git-repository --- src/{git.coffee => git-repository.coffee} | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename src/{git.coffee => git-repository.coffee} (96%) diff --git a/src/git.coffee b/src/git-repository.coffee similarity index 96% rename from src/git.coffee rename to src/git-repository.coffee index 339debf3b..ec7ee017b 100644 --- a/src/git.coffee +++ b/src/git-repository.coffee @@ -40,10 +40,10 @@ Task = require './task' # ### Requiring in packages # # ```coffee -# {Git} = require 'atom' +# {GitRepository} = require 'atom' # ``` module.exports = -class Git +class GitRepository EmitterMixin.includeInto(this) Subscriber.includeInto(this) @@ -58,18 +58,18 @@ class Git Section: Construction and Destruction ### - # Public: Creates a new Git instance. + # Public: Creates a new GitRepository instance. # # * `path` The {String} path to the Git repository to open. # * `options` An optinal {Object} with the following keys: # * `refreshOnWindowFocus` A {Boolean}, `true` to refresh the index and # statuses when the window is focused. # - # Returns a {Git} instance or `null` if the repository could not be opened. + # Returns a {GitRepository} instance or `null` if the repository could not be opened. @open: (path, options) -> return null unless path try - new Git(path, options) + new GitRepository(path, options) catch null @@ -96,7 +96,7 @@ class Git if @project? @subscribe @project.eachBuffer (buffer) => @subscribeToBuffer(buffer) - # Public: Destroy this {Git} object. + # Public: Destroy this {GitRepository} object. # # This destroys any tasks and subscriptions and releases the underlying # libgit2 repository handle. @@ -143,11 +143,11 @@ class Git on: (eventName) -> switch eventName when 'status-changed' - deprecate 'Use Git::onDidChangeStatus instead' + deprecate 'Use GitRepository::onDidChangeStatus instead' when 'statuses-changed' - deprecate 'Use Git::onDidChangeStatuses instead' + deprecate 'Use GitRepository::onDidChangeStatuses instead' else - deprecate 'Git::on is deprecated. Use event subscription methods instead.' + deprecate 'GitRepository::on is deprecated. Use event subscription methods instead.' EmitterMixin::on.apply(this, arguments) ### From 7a429b024ede01a7b9f80f60717ca80f89d2349c Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 22 Sep 2014 11:07:41 -0700 Subject: [PATCH 3/4] Use GitRepository rather than Git --- exports/atom.coffee | 2 +- spec/git-spec.coffee | 34 +++++++++++++++++----------------- src/project.coffee | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/exports/atom.coffee b/exports/atom.coffee index c238e4fa9..15d128cfa 100644 --- a/exports/atom.coffee +++ b/exports/atom.coffee @@ -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 diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 2cc0a6239..235ff5c97 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -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') diff --git a/src/project.coffee b/src/project.coffee index 361d9c950..529acd830 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -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 From 6e8cfba440068f66c9e926df4425f9fdd659408a Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 22 Sep 2014 11:07:53 -0700 Subject: [PATCH 4/4] nof --- spec/git-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 235ff5c97..f29f71397 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -10,7 +10,7 @@ copyRepository = -> fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) workingDirPath -fdescribe "GitRepository", -> +describe "GitRepository", -> repo = null beforeEach ->