Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to sync with git automatically #12

Open
jacobmischka opened this issue Dec 3, 2016 · 9 comments
Open

Option to sync with git automatically #12

jacobmischka opened this issue Dec 3, 2016 · 9 comments

Comments

@jacobmischka
Copy link
Contributor

I think it might be nice to have some kind of automatic git integration. Since gdrive still isn't a first class citizen on Linux and I don't use any other sync service, some kind of git hooks would be a great alternative for me, and I would assume others.

This is a neat helper, great idea!

@jacobmischka
Copy link
Contributor Author

Oh ha I just realized this is already in the README, nice. I'm going to look into trying it myself, but I'm not particularly good at bash so we'll see how that goes.

@pimterry
Copy link
Owner

pimterry commented Dec 3, 2016

Yep, I'd love to have this, but it will be quite difficult to do well. Before you dig in too much, I should point out there's quite a few things I'd really like out of a solution to this:

  • It needs to be a substantial gain over users just managing Git by themselves, which I think probably means it needs to totally Just Work without user intervention. If we end up with a notes commit command then something's gone wrong.
  • It doesn't break or change anything for users who don't want to do this (i.e. it's totally optional, and doesn't change the existing API).
  • It doesn't need either extra command line options for every command, or extra config files lying around. I'd be fine with auto-detecting a git repo in the notes directory, and using that to turn this on (but you probably need an opt-out in the local git config, or something, for people who want to do git themselves)
  • It isn't platform specific (it should at least work with bash+gnu utilities on linux, osx and windows with cygwin).

If I were you I'd be quite tempted to play with this as a layer outside this project, to start with at least, and see whether that solves everything (and where the gaps are, if it doesn't). Try building something into your editor of choice for example that automatically commits changes on save, and then just add a git repo in your notes folder, and use that. There's probably a pretty easy route there that gives you a nicely working solution which clicks together easily with notes but doesn't need to actually be baked into notes directly. Try that, see if it works for the basics, and see what notes is missing to make it work really well.

@jacobmischka
Copy link
Contributor Author

  • Right, no interaction required aside from setting it up.
  • I was thinking about adding a git init-like command, but not changing the others.
  • I quite like the concept of configuration with env vars, so I think they should be leveraged if possible instead of automatic file detection. It should definitely be explicitly opt-in.
  • Certainly, nothing except basic git commands.

Thanks for the ideas!

@ecksun
Copy link
Contributor

ecksun commented Dec 5, 2016

I think pass's git integration is a good inspiration, it solves all of your listed concerns (well, I don't know about platform agnosticism as I never use neither osx nor windows).

@primis
Copy link
Collaborator

primis commented Oct 31, 2017

Here's my take on it:

  • A notes git autocommit command with enable and disable as options. This gets saved in the config file.

  • A notes git autopush command with enable and disable as options, same as above.

  • notes git commitmessage <FOO> for commit that gets piped through date for time stamping commits.

  • When opened, notes will check for autocommit=true and then do git add $FILENAME && git commit -m"$COMMITMESSAGE" and if autopush=true then git push as well

  • Both auto commit and auto push disabled by default

@pimterry
Copy link
Owner

The approach overall sounds good to me. A couple of questions on the details:

  • Do all those first three need to be commands? They could easily be just the config options alone, and keep the command API simpler. Arguably we could have a generic command to manage config, a la git config, but I'm not sure it's necessary at the current stage (though that's pretty debatable).

  • What exactly does when opened mean? When does this get triggered?

  • What should happen if you have some uncommitted changes in the repo lying around? Easy to do if you're using any other syncing mechanism with a device without git (e.g. your phone), or if you just edit a file directly rather than through notes. I'm not sure myself - we could just blanket commit everything, just in case (but we'll get file changes grouped into random commits) or try to commit each file individually, or ignore other changes, or probably something else?

  • One thing not covered here is conflicts: as soon as you have multiple computers sharing notes, they'll get out of sync. Presumably we just expose it to the user as a normal git conflict, and they have to sort it out themselves? Works for me, just worth being explicit about upfront.

@primis
Copy link
Collaborator

primis commented Nov 1, 2017

  1. Fair enough point config options work fine. A notes config might get a bit too complicated, maybe later on.

  2. when opened in that context meant "whenever you open a note through notes, the editor will run, then after you exit the editor, git functions will run."

  3. I'm not sure, we'll have to figure this one out

  4. Git merge would automatically come up anyway unless we suppress it, so that's a decent solution. We can also go the dropbox route and create a "conflicted copy". Up for discussion

@PhilTaken
Copy link

Is anybody actively working on this? I'd be interested myself.

@JoshuaCrewe
Copy link

This is an interesting feature to me too. I ended up using sparkle share to do the same thing ( with the added benefit of being able to sync not note things ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants