Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 2.81 KB

memacs_git.org

File metadata and controls

65 lines (49 loc) · 2.81 KB

## Time-stamp: <2017-12-26 16:22:57 vk> ## This file is best viewed with GNU Emacs Org-mode: http://orgmode.org/

memacs-git

Options

  • -f, --file, path to a file which contains output from following git command: git rev-list --all --pretty=raw
  • -g, --grep-user, if you wanna parse only commit from a specific person. format <Forename Lastname> of user to grep
  • -e, --encoding, default encoding utf-8, see http://docs.python.org/library/codecs.html#standard-encodings for possible encodings

Data Source

Version control systems are quite common to manage all kinds of data with. git is a modern distributed system that has an enormous feature set.

memacs_git.py parses the output of:

git rev-list --all --pretty=raw

If an outfile is specified, only new commits are appended.

Example Invocation

Example with rev-list file:

git rev-list --all --pretty=raw > /tmp/file
./memacs_git.py -f /tmp/file -o /path/to/git-project.org_archive

Example Crontab Entry

Every 60 minutes try to fetch something new from git repository and parse the output

ORG_DIR="/home/user/orgmode/memacs"
MEMACS_DIR="/home/user/git/Memacs"
*/60   *   *   *  *    /home/user/bin/no-power-supply.sh || cd "/home/user/git/Memacs" && git fetch && git rev-list --all --pretty=raw | $MEMACS_DIR/versioning_systems/memacs_git.py -o $ORG_DIR/git-memacs.org_archive

.gitconfig - alias

For easily adding a crontab entry, you can modify your .gitconfig and add an alias like memacs-add-crontab to the [alias] section.

It could look like this: (adjust the paths!)

[alias]
      ...
	memacs-add-crontab = "! crontab -l > /tmp/crontab &&  echo \"*/60   *   *   *  *    /home/user/bin/no-power-supply.sh || cd \"$(git rev-parse --show-toplevel)\" && git fetch && git rev-list --all --pretty=raw | /path/to/memacs/versioning_systems/memacs_git.py -o ~/orgmode/memacs/git-$(basename $(git rev-parse --show-toplevel)).org_archive\n\" >> /tmp/crontab && crontab /tmp/crontab && rm /tmp/crontab"

filter by username

use option

./memacs_git.py <...> -g "Forename Lastname"

or

./memacs_git.py <...> --grep-user "Forename Lastname"

Example Orgmode entries

Whenever user “Bob” commits a change set to an example project, memacs_git can provide an entry like this:

* Memacs for git files           :Memacs:git:
** Bob Bobman: added utf-8 support for stdin
  :PROPERTIES:
  :COMMIT:        5503912cde8ac94346a7c78583e2e6a6b9163582
  :TREE:          845f83f4678963bad0504ce73161312c60de4d2f
  :PARENT:        652601b94e640ea1225c415e603a6c8374219dd1
  :AUTHOR:        Bob Bobman <bob@example.com> 1324463332 +0100
  :CREATED:       <2011-12-21 Wed 11:28:52>
  :COMMITTER:     Bob Bobman <bob@examlpe.com> 1324463332 +0100
  :END: