.. _technical: ************************ Technical specifications ************************ (Spécification technique) Constraints =========== L'exercice est donc l'écriture d'un script Python qui prendrait les données du dépôt d'une de nos applications (prenons Passerelle : https://git.entrouvert.org/passerelle.git) et afficherait ces taux. NB : on est bien sur un script simple, pas sur du web. Library ======= We need a Library to interact with ``git`` repositories. Specifically, we need an API to parse the result of ``git log``: :: $ git log | head commit 1d8e084753d93602aec7a6260eaa4816c3281cc2 Author: Nicolas Roche Date: Fri Nov 9 16:22:49 2018 +0100 document how to build documentation ... Here is a "stabilized" library: :: # apt-get install python-git-doc Unfortunately it doesn't perform any parsing, but just return a big string: :: # apt-get install python-git $ python >>> import git >>> g = git.Git('/home/nroche/git/keepcool') >>> log = g.log() >>> print log ... >>> type(log) It seems we need to play with ``git`` command line's option and pass it to the ``log()`` function. :: $ git log --committer=nroche \ --after="2018-11-09 16:05:00" --before="2018-11-09 16:20:00" \ --pretty='"%cN" %ct' "Nicolas Roche" 1541776456 "Nicolas Roche" 1541776017 $ python >>> import git >>> g = git.Git('/home/nroche/git/keepcool') >>> print g.log('--pretty="%cN" %ct') "Nicolas Roche" 1541776969 "Nicolas Roche" 1541776456 ... .. _no git remote access: https://stackoverflow.com/questions/20055398/is-it-possible-to-get-commit-logs-messages-of-a-remote-git-repo-without-git-clon Sadly it seems to me that the only way to interact with a ``git`` repository is to clone it first (see `no git remote access`_). Logs ==== Not necessary as we do not develop a daemon. Traces may be sufficient. Conclusion ========== * For now, we will use ``python-git`` library. * We first need to clone the remote ``git`` repositories we want to inspect. * We will get dates using the unix timestamp format (easier to parse)