Commit Graph

16 Commits

Author SHA1 Message Date
Daniel Hengeveld
47edd1b984 Use async’s destroy callback in repo provider. 2015-11-03 16:39:01 +01: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
Phil Hord
5d62127b67 🐛 Teach git-repository-provider to recognize .git-files
Git repositories may be contained in a .git directory or a .git file
in the workdir hierarchy, but Atom only recognizes the directory format.
Teach Atom to recognize the filesystem-agnostic Git symbolic link
used by default in many situations including, for example, submodules.

The .git file contains a relative or absolute path to the location of
the real git-dir, preceded by the 8-byte string "gitdir: ".

Here's a console log showing the normal creation of such a symbolic link.

    /tmp $ git init --separate-git-dir foo.git bar
    Initialized empty Git repository in /tmp/foo.git/
    /tmp $ ls
    /tmp $ bar  foo.git
    /tmp $ ls -la bar
    drwxr-xr-x 2 hordp hordp 4096 Sep 18 15:54 .
    drwxr-xr-x 4 hordp hordp 4096 Sep 18 15:54 ..
    -rw-r--r-- 1 hordp hordp   25 Sep 18 15:54 .git
    /tmp $ ls foo.git
    branches  config  description  HEAD  hooks  info  objects  refs
    /tmp $ cat bar/.git
    gitdir: /tmp/foo.git

Fixes #8876
2015-09-21 17:29:22 -04:00
Michael Bolin
b015e1bfa7 revert changes to isValidGitDirectorySync() 2015-02-23 09:56:57 -08:00
Michael Bolin
07039ba47a Check whether existsSync() is available in GitRepositoryProvider before trying to call it. 2015-02-23 09:30:43 -08:00
Michael Bolin
eb06cb7f97 On second thought, don't print anything.
This can be a common, expected occurrence when using special implementations
of Directory, so it creates a lot of distracting noise for the user.
2015-02-22 20:36:14 -08:00
Michael Bolin
947df9a6cc Print exception via console.warn(). 2015-02-22 20:35:51 -08:00
Michael Bolin
6d24aaf497 Make sure that GitRepositoryProvider.repositoryForDirectorySync() returns null rather than throws.
The UI locks up if this method does not return.
2015-02-21 00:07:40 -08:00
Kevin Sawicki
63af713a3f Guard against detected repository that does not open
Closes #5609
2015-02-18 09:16:06 -08:00
Michael Bolin
8f9b6a3082 Replace directoryExistsSync() with Directory::existsSync().
This makes it possible to remove a TODO in `GitRepositoryProvider`.
2015-02-13 13:25:02 -08:00
Kevin Sawicki
f7138e5190 ⬆️ pathwatcher@3.3 2015-02-13 12:30:37 -08:00
Max Brunsfeld
723117a2dc 🎨 fix linter errors 2015-02-12 11:36:16 -08:00
Michael Bolin
5d788f9a6c Use getPath() instead of getRealPathSync() because other parts of Atom are relying on getPath() for contains(). 2015-02-12 10:45: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