Functional specification

(Spécifications fonctionelle)

API

Get the list of commit

We are looking for a python script that take the local path of a git‘s clone repository as parameter, and that display some computed status on committers (including the out-working-hour commit’s ratio):

$ keepcool [OPTIONS] [GIT_PATH]
---------------------------------------
 Paserelle.git's commiter:  sum / ratio
---------------------------------------
              Josue Kouka:  112 /    3%
       Benjamin Dauvergne:  117 /   11%
            Serghei Mihai:  181 /    9%
          Frédéric Péters:  425 /   21%
              Thomas NOEL:  497 /   18%
---------------------------------------
                      all: 1395 /   15%
---------------------------------------

Options

The result should be modified by providing options:

  • -h, –help: print a help message
  • –version: print the project version number
  • -v, –verbose: print commit’s dates too
  • -u, –user: limit search to a single user. ex: "Thomas NOEL"
  • -a, –after: limit search from a date. ex: "2018-11-09 16:05:00"
  • -b, –before: limit search up to a date. ex: "2018-11-09 16:20:00"
  • -s, –sort: sort results on name, sum or ratio

Relational Schema

Here is the current relation schema (using Merise 2 format).

_images/schema.png

Notes

  • We could optimise if we do not store commits, by computing statistics while parsing the git logs.

However, we keep the commit object and prefer to perform 3 passes (parse, compute and display) in order be keep program simplest and easy to upgrade.

  • We could omit to use a key for commits as we know they are unique.

We prefer to keep the commit’s uuid hash in order to provide all data, and to implement all relation in the same way (using dictionaries).

Classes

The following classes are deduced from the above relational schema.

Date

We need a function to check if a Unix timestamp integer belongs to normal working hours or not.

API:

def belongs_to_workin_hours(self):

Note: we can get dates by translating them using bash:

$ date --date="1978-05-11 09:45:00" "+%Y-%m-%d %H:%M:%S -> (%A %s)"
1978-05-11 09:45:00 -> (jeudi 263720700)

$ date --date="2018-11-10 01:41:14" "+%Y-%m-%d %H:%M:%S -> (%A %s)"
2018-11-10 01:41:14 -> (samedi 1541810474)

Commit

The Commit class inherits from the Date‘s API.

Users

API:

def add_commit(self, commit)
def compute_status(self)
def print_status(self)

KeepCool

Main level API:

def get_user(self, name)
def add_user(self, name)
def add_commit(self, uuid, name, unix_timestamp)
def compute_status(self)
def print_status(self)