GithubHelp home page GithubHelp logo

git-notes's Introduction

Git Notes

CircleCI codecov Gitter

Your personal notes synced through Git

Git Notes is in its alpha stage. I'd love to chat to users who want to use Git Notes. Please join our Gitter channel.


Git Notes is a locally installed app that detects changes in a Git repo and push the changes immmediately to Github, Gitlab, or your own Git host. Here are the advantages:

  • You can use your fav editor like Vim, Emacs, Sublime, or Atom.
  • Your notes are more permanent. When was the last time you deleted a git repo? I don't remember mine either. Storing Github is how you're able to keep your several-year-old notes.
  • Your notes are versioned by Git.
  • Conflicts are handled intuitively for programmers. You see the git-style conflict text in your notes.

I hope Git Notes hits all the notes for you as it does for me. Enjoy!

Installation

  1. Setup your personal note directory with Git. Make the master branch, commit, add origin, and git push origin master -u.
  2. Clone https://github.com/tanin47/git-notes to $GOPATH/src/github.com/tanin47/git-notes. If your GOPATH is empty, maybe you might want to use ~/go.
  3. Make the config file that contains the paths that will be synced automatically by Git Notes. See the example: git-notes.json.example
  4. Build the binary with go mod init; go build

The binary will be built as git-notes in the root dir.

You can run it by: git-notes [your-config-file].

To make Git Notes run at the startup and in the background, please follow the specific platform instruction below:

Ubuntu

Move ./service_conf/linux.git-notes.service to /etc/systemd/system/git-notes.service

Modify /etc/systemd/user/git-notes.service to use the binary that you built above with and your config file.

Reload service file after moving: systemctl daemon-reload

Enable Git Notes to start at boot: systemctl enable git-notes.service

Run: systemctl start git-notes.service

Read logs: journalctl -u git-notes.service --follow

Start after booting: systemctl enable git-notes.service

Mac

Move ./service_conf/mac.git-notes.plist to ~/Library/LaunchAgents/git-notes.plist

Modify ~/Library/LaunchAgents/git-notes.plist to use the binary that you built above with and your config file.

Run and start after booting:

  1. launchctl load ~/Library/LaunchAgents/git-notes.plist
  2. launchctl start ~/Library/LaunchAgents/git-notes.plist

If the plist file is changed, you will need to unload it first with: launchctl unload ~/Library/LaunchAgents/git-notes.plist.

Read logs: use Console.app. Search for logger.

Windows

TBD

Android and iOS

TBD: I want to build apps for this!

Architecture

Our main engine observes the current state of the git repo and make one action to transition to the next state.

Here are all the states:

  • dirty: Unstaged change -> git add . -> staged
  • staged: Staged change -> git commit -m 'Updated' -> ahead or out-of-sync
  • ahead: Ahead of the remote branch and can fast forward -> git push -> synced
  • out_of_sync: The remote branch has unseen commits -> git pull -> ahead (no conflict) or dirty (there are conflicts)
  • synced: The local branch matches the remote branch

This loop runs until no changes are observed. If the engine doesn't end on synced, something is wrong.

When the file change is detected, we invoke the engine again.

The file changes are detected by running git status every 10 seconds.

Develop

  • go build to build the binary
  • go run . to run the application
  • go test to run tests
  • gofmt -w . to format all files
  • goimports -w . to organize imports in all files

git-notes's People

Contributors

tanin-stripe avatar tanin47 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-notes's Issues

Err: unable to parse status

I'm curious what's causing this error. It's not a blocking issue--these changes and a couple others were successfully committed to my local repo. It reproduces consistently, with every detected change.

  • It's interesting to me that the starting state is error.
  • Changes were indeed committed, but they were not pushed.
  • This is a work machine, so I obscured the hostname (LAPTOP-HOSTNAME).
❯ ./git-notes git-notes.json
2020/06/11 15:07:02 Git Notes is starting...
&{[/Users/tcondit/Bender/3_Resources/vimwiki/]}
2020/06/11 15:07:02 Computing the state of /Users/tcondit/Bender/3_Resources/vimwiki/
2020/06/11 15:07:03 Starting state: error
2020/06/11 15:07:03 Syncing failed. Err: performing GetState() failed. Err: unable to parse status: ## LAPTOP-HOSTNAME...origin/LAPTOP-HOSTNAME
2020/06/11 15:07:03 Git notes is monitoring /Users/tcondit/Bender/3_Resources/vimwiki/
2020/06/11 15:08:03 Changes have been detected.
2020/06/11 15:08:05 Computing the state of /Users/tcondit/Bender/3_Resources/vimwiki/
2020/06/11 15:08:05 Starting state: dirty
2020/06/11 15:08:05 Computing the state of /Users/tcondit/Bender/3_Resources/vimwiki/
[LAPTOP-HOSTNAME df32c77] Commited at 2020-06-11 15:08:05.408897 -0700 PDT m=+63.172554816
 2 files changed, 2 insertions(+)
 create mode 100644 testing-git-notes.md
2020/06/11 15:08:05 Computing the state of /Users/tcondit/Bender/3_Resources/vimwiki/
2020/06/11 15:08:06 Syncing failed. Err: performing GetState() failed. Err: unable to parse status: ## LAPTOP-HOSTNAME...origin/LAPTOP-HOSTNAME [ahead 1]
2020/06/11 15:11:20 Changes have been detected.
2020/06/11 15:11:22 Computing the state of /Users/tcondit/Bender/3_Resources/vimwiki/
2020/06/11 15:11:22 Starting state: dirty
2020/06/11 15:11:22 Computing the state of /Users/tcondit/Bender/3_Resources/vimwiki/
[LAPTOP-HOSTNAME 503a2fb] Commited at 2020-06-11 15:11:22.751097 -0700 PDT m=+260.511405293
 1 file changed, 4 insertions(+)

Works when executed, but not as a service (macOS)

Hi Tanin,
First off, thank you for this great little tool!
I've been using it without any problems on my two machines for more than a year now :-)

The issue:
I noticed today that my git-notes wasn't working on MacBook despite it still running.
The logs (from Console.app) show that it fails to get the status, i.e. running git status --porcelain:

Git notes is monitoring /Users/kasper/org
Failed to get state. Error: unable to get status. Error: exit status 1
Failed to get state. Error: unable to get status. Error: exit status 1
...

When I run the executable directly, it works as expected.
So I figured the service was acting up and I reloaded it but to no avail.
Then I unloaded the service and reinstalled the whole thing following your instructions. But the same problem still occurs.

I updated my MacBook to Monterey yesterday, but I did the same with my Mac Mini (on which git-notes still works).
I don't think I've changed anything else noteworthy recently.

Do you have an idea of what the problem could be or what I could try to debug this?

Binary not created with current build instructions on macOS

Hi, I just attempted to install git-notes on a new machine, but I ran into a minor issue with the install instructions, which meant that it didn't produce the git-notes binary.

And thanks for the otherwise flawless tool ;)

Steps

  1. Run go build *.go inside the root of the repo

Expected

The git-notes binary is built.

Actual

The binary isn't built. (No output is given by the command).

Workaround

When I ran go build (without *.go) it suggested that I initialize the module with go mod init.
After initializing the module, the binary was produced by running go build.

So, at least for macOS, the build instructions should be go mod init; go build 😊

Setup

  • OS: macOS 11.6.5
  • Go: 1.18.4

Add some license

Could you add explicit license to repository (for example in LICENSE file or in the README?)

Without explicit license this project is „All right Reserved”, even if
that's your intent it would be better to state that explicitly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.