Commit Graph

13 Commits

Author SHA1 Message Date
Kevin Sawicki
f7c4fa4bcc Only do legacy emits when deprecations are included 2015-04-03 11:29:12 -07:00
Kevin Sawicki
00b31c5c6e Conditionally include Emitter mixin 2015-04-03 11:29:12 -07:00
Kevin Sawicki
efcfcc73a4 Conditionally include deprecations in GitRepository 2015-04-03 11:29:12 -07:00
Michael Bolin
14316b1cd7 Add Repository::getType().
For `GitRepository`, this will return `"git"`.
2015-03-23 15:38:38 -07:00
Kevin Sawicki
2219abece1 Don't use deprecated buffer events 2015-03-16 16:44:52 -07:00
Jeremy Engel
6256f62217 Change "optinal" to "optional" 2015-02-14 09:36:20 -08:00
Michael Bolin
1191db009e Addressing @nathansobo's feedback. 2015-02-11 09:17:25 -08:00
Michael Bolin
e04f17fe5f Set up the atom.repository-provider service and implement GitRepositoryProvider.
I tested this by creating a dummy implementation of an `HgRepositoryProvider`
(with the optional `createRepositorySync()` method implemented) and an `HgRepository`
in an Atom package with the following stanza in the `package.json`:

```
  "providedServices": {
    "atom.repository-provider": {
      "versions": {
        "0.1.0": "createHgRepositoryProvider"
      }
    }
  },
```

I opened a path with an Hg repository from the command line using Atom.
I verified that `atom.project.repositoryProviders` contains both a
`GitRepositoryProvider` and an `HgRepositoryProvider`.

I also verified that running the following printed out an `HgRepository`:

```
var Directory = require('pathwatcher').Directory;
atom.project.repositoryForDirectory(
    new Directory(atom.project.getPath(), /* symlink */ false)).then(
        function(repo) { console.log('repo: %o', repo); });
```

One thing that stands out to me about the current API for the
atom.repository-provider service is that the function used to create
a `RepositoryProvider` does not receive any arguments. If the creation
of the `GitRepositoryProvider` were done via the service, this would
be a problem because it needs a reference to `atom.project`, which is
not defined when it is created. (We work around this because it is
created in `Project`'s constructor, so it can pass `this` to
`new GitRepositoryProvider()`.)

We would have to create a `RepositoryProviderFactory` or something if
we wanted to specify arguments when creating a `RepositoryProvider`,
in general. Maybe that's too crazy / not an issue, in practice.

Though note that `GitRepository` cannot access `atom.project` lazily
because it uses it in its constructor to do the following:

```
if @project?
  @subscriptions.add @project.eachBuffer (buffer) => @subscribeToBuffer(buffer)
```

So long as we can guarantee that `atom.project` is defined before the
other providers are initialized, I think we should be OK.

Follow-up work:
* Replace the use of `RepositoryProvider.createRepositorySync()` with
`RepositoryProvider.repositoryForDirectory()` in `Project.setPaths()`.
* Replace all uses of `Project.getRepositories()` with
`Project.repositoryForDirectory()` in packages that are bundled with Atom
by default.
* Implement `Directory.exists()` and/or `Directory.existsSync()` and update
`git-repositor-provider.coffee`, as appropriate.
* Eliminate `GitRepositoryProvider.repositoryForDirectory()`'s use of
synchronous methods.
* Somewhat orthogonal to this diff, but the following fields need to be
removed from `Project` because they enforce the idea of a single root:
`path`, `rootDirectory`, and `repo`. This has implications around the
existing use of `@rootDirectory?.off()` and `@destroyRepo()`.
2015-02-10 21:46:02 -08:00
Adrian Lee
63ad6b1a66 Fix getOriginUrl calling itself 2015-01-14 15:44:59 -08:00
Nathan Sobo
7f8ab72f53 Capitalize initialisms
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-01-12 22:00:24 -08:00
Kevin Sawicki
91770f2885 Add buffer subscriptions to repo's subscriptions
Closes #4570
2014-12-12 12:26:09 -08:00
Nathan Sobo
5f68af27f5 Fix memory leak in GitRepository and convert to CompositeDisposables
We were calling @unsubscribe with the TextBuffer, which previously
unsubscribed from that object. The problem is that we were no longer
subscribing to that object directly, but only adding subscriptions to
that object. This caused us to never unsubscribe from buffers.
2014-11-20 10:56:51 -07:00
Ben Ogle
84425f238a Rename git -> git-repository 2014-09-22 11:07:19 -07:00