GithubHelp home page GithubHelp logo

xingheng / taskwarrior-data Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 3.0 24 KB

Manage taskwarrior data with git.

Home Page: https://xingheng.github.io/when-taskwarrior-met-git/

Shell 100.00%
taskwarrior git sync

taskwarrior-data's Introduction

Legacy

This repository is designed for taskwarrior 2.x only, DO NOT using it for taskwarrior 3.x since it has been upgraded to sqlite database file for data storage.

Taskwarrior Data

This repository is a template project for hosting taskwarrior data with git-sync script to deploy it on all of my working systems.

File Structure

➜  taskwarrior-data git:(master) tree .
├── README.md                            # current file
├── data                                 # taskwarrior data
│   ├── backlog.data
│   ├── completed.data
│   ├── hooks -> ../hooks
│   ├── pending.data
│   └── undo.data
├── git-sync                             # core script from `git-sync`
├── git-sync-on-inotify                  # core script from `git-sync`
└── hooks                                # taskwarrior hooks
    ├── on-exit-sync
    └── on-launch-sync

3 directories, 10 files

Deploy

  1. Clone the current repository to local system.

    git clone https://github.com/xingheng/taskwarrior-data.git --branch dev

    The default master branch has some sample task for demo, so specify the dev branch to fetch a clean environment for personal usage. Recommend keeping the dev branch for upgrade in the future.

  2. Now create a git repository code hosting service like GitHub or Bitbucket for personal data hosting, make it public or private, it’s up to you, the git-sync tool will use your local git configuration only.

    Add it as a new upstream in current repository, in this example we use master branch for data sync.

    git remote add mine [email protected]:your-name/taskwarrior-data.git
    git fetch mine
    git checkout --track mine/master
  3. Configure it for git-sync.

    git config --bool branch.master.sync true
    git config --bool branch.master.syncNewFiles true

    It doesn’t limit you have to use master branch for data sync, just make sure config it right and check it out once everything ready.

  4. Configure the data storage for taskwarrior.

    taskwarrior uses the ~/.task directory as default data storage as its docs said, so you need rewrite the TASKDATA environment variable in ~/.taskrc file or move the current taskwarrior-data directory to the default path, migrate the existing data to taskwarrior-data/data directory if necessary.

Event Trigger

When task command started, it will trigger the on-launch-sync hook script to check current git repository’s branch configuration and file status, break the task launch progress to run if something wrong or dirty found.

When task command finished, it will trigger the on-exit-sync hook script to update the data file status, commit the task context info with a new custom message and call the external git-sync script to remote master branch’s upstream, of course save all the related operation outputs to log file git-sync.log.

Multiple Workspaces

I use taskwarrior with two workspaces, one for personal projects which track all the general task data including side projects, another one for team projects because of security data issues, so I had to create a private git repository in the our private code hosting server.

Luckily taskwarrior uses its environment variables TASKRC and TASKDATA to initialize the configuration and data storage path every time when launching task. So I use direnv to separate the workspace, here is my configuration in ~/work/team-name/.envrc:

# taskwarrior
# ------------------- BEGIN -------------------
# export TASKRC=~/.taskrc  # This is default rc.
export TASKDATA=~/work/team-name/projects/taskwarrior/data
# -------------------- END --------------------

That’s nice! When I work from the any subdirectories under the ~/work/team-name directory, task takes me to the team task workspace instead of global personal one. Enjoy!

References

Automated Syncing With Git

Taskwarrior - Hooks v1

Taskwarrior - Hooks v2

Taskwarrior - Hook Author's Guide

taskwarrior-data's People

Contributors

xingheng avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

linuxcaffe excds

taskwarrior-data's Issues

how to setup?

I am trying to use your project. I do not understand the 2 last steps.

I cloned your repo:

sandrock@firefly-mjr  ~  cd .opt
sandrock@firefly-mjr  ~/.opt  git clone
sandrock@firefly-mjr  ~/.opt  git clone https://github.com/xingheng/taskwarrior-data.git --branch dev
Cloning into 'taskwarrior-data'...
remote: Enumerating objects: 174, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 174 (delta 4), reused 2 (delta 2), pack-reused 167
Receiving objects: 100% (174/174), 26.00 KiB | 3.25 MiB/s, done.
Resolving deltas: 100% (120/120), done.
sandrock@firefly-mjr  ~/.opt  cd taskwarrior-data
sandrock@firefly-mjr  ~/.opt/taskwarrior-data   ls
data  git-sync  git-sync-on-inotify  hooks  README.md

I created a repo somewhere to host data and did the commands:

sandrock@firefly-mjr  ~/.opt/taskwarrior-data   git remote add mine [email protected]:xxx/xxx.git
sandrock@firefly-mjr  ~/.opt/taskwarrior-data   git fetch mine
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 262 bytes | 262.00 KiB/s, done.
From xxxxxx.xxx:xxx/xxx
 * [new branch]      master     -> mine/master
sandrock@firefly-mjr  ~/.opt/taskwarrior-data   git checkout --track mine/master
branch 'master' set up to track 'mine/master'.
Switched to a new branch 'master'
sandrock@firefly-mjr  ~/.opt/taskwarrior-data   git config --bool branch.master.sync true
sandrock@firefly-mjr  ~/.opt/taskwarrior-data   git config --bool branch.master.syncNewFiles true
sandrock@firefly-mjr  ~/.opt/taskwarrior-data   ls
README.md

The checkout commands makes the files from your remote not available. I think it will not work this way. What should I do?

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.