trilbymedia / grav-plugin-git-sync

Collaboratively Synchronize your Grav `user` folder hosted on GitHub, BitBucket or GitLab
Apache License 2.0
246 stars 57 forks source link

Support for local git repo? #113

Open fralau opened 6 years ago

fralau commented 6 years ago

Thanks for the great plugin.

I would need a relatively simple setup where the git 'remote' repository is actually on the same machine than the git-grav application, and then a developer would just need to ssh into the machine for a git clone, git push/pull, etc.

I guess the plugin should be able to implement this practice since git admits the following file syntaxes:

    /path/to/repo.git/
    file:///path/to/repo.git/

In practice:

  1. Could we use a relative URL, and if yes, what is its "home"? [Best to use absolute urls?]
  2. Does the pluging correctly identify that username and password are not needed, or does it behave in such a way that it doesn't matter?
  3. Issues or caveats with file access rights?
  4. If the method works, could we agree on a canonic place in the project arborescence, where to put that repo? (it would have to be outside of the userdirectory, for sure; but would it be feasible to create a new directory within the grav arboresence, e.g. archive)?
w00fz commented 6 years ago

Hey @fralau,

Gitsync follows the git standards everywhere which is why it is compatible with the most popular services as well as any other git server. However, so far, I only ever took into account an authentication based remote origin.

I never actually tried a local git server. Could you show me how a .git/config looks like when it's setup to use it?

Regarding the folders location. It should behave the same as it does with remote services. If you repo is on GitHub, for example, GitSync assumes your user/ origin is in the GitHub repository where the root of the repository is the actual user/ folder and so in there you see pages/, themes/ and whatnot.

This also follows Grav's Skeleton standards (ie, https://github.com/getgrav/grav-skeleton-blog-site).

I would assume your local repository would be contained somewhere on your server outside of the Grav instance. If that's the case the I am guessing that you reference it in git through the path /user/git/myrepo.git or ~/location/of/myrepo or something along those line.

If that's the case, and keep in mind having not dealt with this before I am just assuming, then we can make it work so that in GitSync you do pass that path location and we let it be added as the remote origin.

fralau commented 6 years ago

Sorry for not answering faster. The list of protocols available for git is defined here.

The command fo setting up a "local" remote repo is the same as for any other (git init --bare <directory>).

According to the instructions, you can add a remote repo on the same filesystem in this way:

$ git remote add local_proj /srv/git/project.git

or

$ git remote add local_proj file:///srv/git/project.git

which is less efficient.

(The question is, of course, where GitSync will consider its local directory to be (for relative paths); unless it is recommended to use an absolute path.)

After a few tests, it seems that the one thing that fails is that the function doesn't know how to deal with an empty user (or else tries to insert a user to the path).