This is meant to help people (like me) that use both Hamster applet (Gnome Time Tracker) and Gitlab to keep trace of activities done.
This project is based on my own "same" project for synching with Redmine; available at https://github.com/brunetton/redminetimesync
- Running Gitlab instance (with API v4)
- Gitlab personal access token (with
api
scope). See here for more details - Python installed your local machine
- Hamster running on your local machine, with at least one activity recorded
This scripts is limited to mono-project Gitlab; ie all issues must belong to the same Gitlab project (see below for ideas for the future)
git clone git@github.com:brunetton/gitlabtimesync.git
pip install -r requirements.txt
Copy gitlabtimesync.config.tpl
to gitlabtimesync.config
: it's an INI-like file that needs two parameters:
- url: your Gitlab public url
- token: a Gitlab private API access token (with
api
scope). See here for more details - project_id: Gitlab internal ID of project containing issues (this ID is given in Gitlab's project's page just below the project's name (search for
Project ID:
))
When using Snap installation (hamster-snap), database file is located in ~/snap/hamster-snap/47/.local/share/hamster/hamster.db
(you may change 47
version in path). In that case, you'll have to change db
path in [default]
section.
- Log some activities in Hamster, precising Gitlab issues IDs. Valid formats are :
-
#134: Adding some interesting stuff
-
Fix #243
-
Adding logging output (#132)
(you can add other custom formats, changing
issue_id_regexp
regex in configuration file)
- run the python script: gitlabtimesync.py
- to sync one day, just give the date to the script :
gitlabtimesync.py 10/10/13
- to sync a period, use
from
andto
arguments :gitlabtimesync.py from 10/10/13 to 15/10/13
- -> to sync from a given date until today, you don't need to precise
to
parameter :gitlabtimesync.py from 10/10/14
- -> to sync from a given date until today, you don't need to precise
You can configure dates formats in gitlabtimesync.config
file.
Note that all dates parameters can be also replaced by "days ago" parameters :
gitlabtimesync.py 1
will sync yesterday workgitlabtimesync.py from 7
will sync last week work (from 7 days ago to today)gitlabtimesync.py from 15 to 7
will sync week before last week work (from 15 days ago to last week)
- to add support to multiple projects, we could use Hamster tags/activities. For example,
#123 - this is a bug@project1
and#123 - this is a bug@project2
could differentiate 2 different projectsproject1
andproject2
I included a "bonus script": stop_current_activity.py
that automatically stop current activity. I use this script with systemd to stop tracking when I put my computer in sleep mode.