Giter Club home page Giter Club logo

gitlabtimesync's Introduction

What is this?

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

Prerequisites

  • 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

Limitations

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)

Installation

Clone the repository

git clone [email protected]:brunetton/gitlabtimesync.git

Install needed Python packages

pip install -r requirements.txt

Prepare config files

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:))

Using hamster-snap

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.

Usage

  1. 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)

  1. 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 and to 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

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 work
  • gitlabtimesync.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)

Future ideas

  • 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 projects project1 and project2

Bonus script: stop_current_activity.py

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.

gitlabtimesync's People

Stargazers

Johan Richer avatar

Watchers

Bruno Duyé avatar James Cloos avatar  avatar

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.