Commit Graph

46 Commits

Author SHA1 Message Date
Mihail Bodrov
d602655708 replace _.extend in favore of Object.assign 2016-05-20 01:27:27 +03:00
joshaber
cd8b28da4d Document why 2016-04-27 22:40:34 -04:00
joshaber
d11e30579b Manually emit the change event. 2016-04-27 17:17:09 -04:00
joshaber
c0adf125ec Reset the cache before calling the callback. 2016-04-27 16:05:00 -04:00
joshaber
69e97204d5 Test for undefinedness instead of 0. 2016-04-27 12:50:27 -04:00
joshaber
db8e62315c Defer the callback to the next tick.
This gives GitRepository the chance to clear its path cache before the callback 
is invoked. Otherwise reads from the cached status state within the callback 
would be wrong.
2016-04-07 11:19:27 -04:00
joshaber
fdebbf12ac If we're been destroyed then we won't have an async anymore. 2016-03-25 17:14:09 -04:00
joshaber
8ee1c3274b Always update the cached status path. 2016-03-25 17:13:06 -04:00
joshaber
fff1e8f3d1 Cache the results of calling getPathStatus so we're consistent across calls. 2016-03-25 15:36:44 -04:00
joshaber
f001c83263 Bring back some synchronous event emitting.
Preserve the previous behavior of emitting synchronously with observed
change.
2016-03-25 15:26:18 -04:00
joshaber
380df72808 All emissions will propagate out from the async layer. 2016-03-25 15:15:24 -04:00
joshaber
c9ff5db064 Don't update status anymore in the sync layer. 2016-03-25 15:15:10 -04:00
joshaber
4ecc6aac90 Grab the branch from the async layer. 2016-03-25 15:14:32 -04:00
joshaber
3aae2054f7 Grab status from the underlying async layer. 2016-03-25 15:14:12 -04:00
joshaber
2f58c40472 Pass subscriptions through to the async layer. 2016-03-25 15:12:06 -04:00
joshaber
0e8161f30e Always search the repo itself. 2016-02-12 14:45:21 -05:00
joshaber
98a63d1d68 Glob it. 2016-02-10 14:25:05 -05:00
joshaber
24db4586e4 Merge branch 'master' into dh-async-repo 2016-01-05 12:44:35 -05:00
joshaber
b4035547c2 Use .getStatusForPaths. 2016-01-01 17:05:50 -05:00
joshaber
0c42747e8a Just Use Clone. 2015-12-10 16:55:21 -05:00
joshaber
9bb8703978 Don't make the async repo duplicate the work if it's wrapped by a sync repo. 2015-12-03 09:49:10 -05:00
joshaber
d0b148a97a Call the better-named method. 2015-12-02 14:39:00 -05:00
joshaber
628e810758 Expose the promise for refreshStatus. 2015-11-10 15:23:36 -05:00
Daniel Hengeveld
4f06509fde Destroy async repo from sync repo 2015-11-03 16:39:26 +01:00
Daniel Hengeveld
226c1dd6a7 Merge remote-tracking branch 'remotes/origin/master' into dh-async-repo 2015-10-21 14:52:36 +02:00
Daniel Hengeveld
2ff283a6b0 Async buffer events 2015-10-20 16:01:35 +02:00
Daniel Hengeveld
60180677a2 add .async attribute to GitRepository 2015-10-20 14:03:19 +02:00
Nathan Sobo
f9a269ed99 Prompt about checking out head revision in TextEditor, not GitRepository
This allows us not to inject confirm or ApplicationDelegate into
Project, GitRepositoryProvider, and GitRepository.
2015-10-13 19:11:55 -06:00
Antonio Scandurra
a3a6db7f68 Don't use atom.{config,confirm} global in GitRepository 2015-10-07 15:25:05 -05:00
Thomas Johansen
efda18ae73 📝 Update reference to deprecated method
GitRepository class documentation references deprecated method
Project::getRepo. This resolves that by instead using the replacement
Project::getRepositories.

Although, it seems as if that will be removed in v2.0, so perhaps we should
update this to instead using the async Project::getDirectories method, coupled
with Project::repositoryForDirectory?

/cc @atom/feedback

Fixes #8971
2015-09-28 13:34:36 +02:00
Nathan Sobo
23dd4f5990 🔥 Remove deprecations from GitRepository 2015-09-22 10:37:07 -06:00
Ross Allen
51016550c3 Add missing docs for GitRepository
Add argument and return type docs to fill in the documentation site.
2015-06-11 13:45:06 -07:00
Kevin Sawicki
7d592c8b78 includeDeprecations -> includeDeprecatedAPIs 2015-04-03 11:29:16 -07:00
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