hammerlab / genspio

Generate Shell Phrases In OCaml
https://smondet.gitlab.io/genspio-doc/
Apache License 2.0
48 stars 3 forks source link

Add `README.md` generation for mutli-git #99

Closed smondet closed 5 years ago

smondet commented 5 years ago

Here the current output (github commenting thing does not treat newlines like the normal markdown renderer):


Git: Multi-Repository

This project provides a couple of scripts which handle multiple Git repositories at once. One can provide a list of directories to scan for repositories (non-recursively) on the command line or through Git's configuration mechanism.

The scripts provided as of now are:

It may be interesting for the user to also alias them in ~/.gitconfig, for instance:

[alias]
    mst = multi-status --show-modified
    arfd = activity-report --section-base '####' --since

See below for detailed usage information ⮷.

Usage: Git-multi-status

See git-multi-status --help:

usage: git-multi-status <args>
Show the status of a bunch of Git repositories.

Use `git multi-status /path/to/repos1 /path/to/repos2` to display
a compact report of all the git repositories found in the folders 
`/path/to/repos1` and `/path/to/repos2`.

Default paths to explore can be set in Git's configuration:

    git config --global --add multi-git.paths /path/to/repos1
    git config --global --add multi-git.paths /path/to/repos2

Options:

* `--show-modified`: Show the list of modified files.
* `--no-config`: Do not look at the `multi-git.paths` git-config option.
* `--version`: Show version information.
* `--describe`: Show the status of a bunch of Git repositories

Usage: Git-activity-report

See git-activity-report --help:

usage: git-activity-report <args>
Make a report of developments in a bunch of Git repositories.

Use `git activity-report --since 2018-10-23 /path/to/repos1 /path/to/repos2` to display
a detailed “recent happenings” report of all the git repositories found
in the folders `/path/to/repos1` and `/path/to/repos2`.

Default paths to explore can be set in Git's configuration:

    git config --global --add multi-git.paths /path/to/repos1
    git config --global --add multi-git.paths /path/to/repos2

Options:

* `--no-config`: Do not look at the `multi-git.paths` git-config option.
* `--since <string>`: Date to get the logs/information since (default: “last sunday”).
* `--section-base <string>`: The base markdown section ('##', '###', etc. default: ###)
* `--version`: Show version information.
* `--describe`: Make a report of developments in a bunch of Git repositories

Authors / Making-of

This repository is generated by an OCaml program which itself was written by Seb Mondet, it uses the Genspio EDSL library, and serves as one of its examples of usage, see also its implementation.

Similarly, you may check out the https://github.com/smondet/cosc repository, which is also a bunch of shell scripts maintained by an OCaml program.

Example Session / Demo

Let's see a sequence of examples to demo the scripts. First, we prepare a set of “test” repositories in /tmp/git-repos-example:

$ mkdir -p /tmp/git-repos-example/hammerlab
$ mkdir -p /tmp/git-repos-example/smondet
$ mkdir -p /tmp/git-repos-example/tezos
$ git clone https://github.com/hammerlab/ketrew.git \
  /tmp/git-repos-example/hammerlab/ketrew
$ git clone https://github.com/hammerlab/biokepi.git \
  /tmp/git-repos-example/hammerlab/biokepi
$ git clone https://github.com/hammerlab/genspio.git \
  /tmp/git-repos-example/hammerlab/genspio
$ git clone https://github.com/hammerlab/coclobas.git \
  /tmp/git-repos-example/hammerlab/coclobas
$ git clone https://gitlab.com/smondet/genspio-doc.git \
  /tmp/git-repos-example/smondet/genspio-doc
$ git clone https://gitlab.com/smondet/vecosek.git \
  /tmp/git-repos-example/smondet/vecosek
$ git clone https://gitlab.com/tezos/tezos.git \
  /tmp/git-repos-example/tezos/tezos

For now, we haven't changed anything to the repositories so the “multi-status” is full of zeros (we use the --no-config option to get consistent output w.r.t. users' configuration):

$ git multi-status --no-config /tmp/git-repos-example/hammerlab \
  /tmp/git-repos-example/smondet /tmp/git-repos-example/tezos
    --------------------------------------------------------------------------------
    >> /tmp/git-repos-example/hammerlab
    GHub: biokepi                        | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    GHub: coclobas                       | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    GHub: genspio                        | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    GHub: ketrew                         | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    --------------------------------------------------------------------------------
    >> /tmp/git-repos-example/smondet
    GLab: genspio-doc                    | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    GLab: vecosek                        | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    --------------------------------------------------------------------------------
    >> /tmp/git-repos-example/tezos
    GLab: tezos                          | U: 0      | M: 0    | Ahead: 0    | Behind: 0

The activity-report is, for now, more interesting, and it outputs directly Markdown:

$ git activity-report --section-base '####' --since 2018-10-20 \
  --no-config /tmp/git-repos-example/hammerlab \
  /tmp/git-repos-example/smondet /tmp/git-repos-example/tezos

In /tmp/git-repos-example/hammerlab

GHub: genspio
* origin/sm@multigit-readme
* HEAD -> master, origin/master, origin/HEAD
* origin/sm@add-activity-report
* origin/sm@add-multigit-example
On master:
  • Tweak vm-tester documentation w.r.t Docker images.
  • Add docker-build trigger in Travis build.
  • Trigger docker-build only in one travis-job. (and fix it).
  • Add the “Multi-git” example. For now there is a git multi-status <paths> command.
  • Fix untracked count in multi_status.
  • Add multigit to TravisCI.
  • Put multigit test in separate script.
  • Fix multi-status tests in OSX.
  • Add option --show-modified (git multi-status).
  • Display repository provider (git multi-status).
  • Put descriptive comments in git-multi-status.
  • Add multigit to the literally documented examples.
  • Add support for git-config and improve help.
  • Add new multi-git script: git-activity-report.
  • This is still work in progress.
  • The tests do not verify much yet either.
  • Merge sm@add-multigit-example (PR #97).
  • Merge master into sm@add-activity-report.
  • Add --section-base to git-activity_report.
  • Compute default --since to “Last Sunday”.
  • Improve markdown output of git-activity-report.
  • Add more tests of git-activity-report.
  • Merge sm@add-activity-report (PR #98, @smondet).

In /tmp/git-repos-example/smondet

GLab: genspio-doc
* HEAD -> master, origin/master, origin/HEAD
On master:
  • Update .gitlab-ci.yml (missing in fb3bbbd).

In /tmp/git-repos-example/tezos

GLab: tezos
* origin/reorg_michelson_test_contracts
| * origin/vb/crypto-lock-and-wipe
| * origin/mb/distributed_db_delay
|/
| * origin/mb/pending_requests
|/
* HEAD -> master, origin/master, origin/HEAD
* origin/plaforgue/p2p_discovery
* origin/vb/raft
* origin/galfour/benchmark
* origin/galfour/benchmark-landmarks
* origin/julien/Nack-with-list-of-peer_rewritten
* origin/philb/demo_protocol
* origin/eztz/signer-deterministic_nonce
* origin/julien/Nack-with-list-of-peer
* origin/quyen/test_michelson_types
* origin/victor-proto_process
* origin/abate/prevalidator-rpc-functor
* origin/abate/error_monad_docstring
* origin/identity_backward_compat
* origin/michelson_test_contracts
* origin/galfour/benchmark-dirty
* origin/plaforgue/annotation_assert
* origin/state_migration
* origin/abate/prevalidator-preapply-refactor
* origin/quick-mempool-fix
* origin/philb/trusted_peers
* origin/julien/kick-wth-lst-of-peer
* origin/alphanet
* origin/pirbo/mainnet, origin/mainnet-staging
* origin/galfour/benchmark-wtf
* origin/raphael/prototype-batch-scheduler
On master:
  • Target only USB ledger with interface number 0.
  • Shell: simplify the signature of Prevalidation. Co-authored-by: Raphaël Proust code@bnwr.net Co-authored-by: Pietro Abate pietro.abate@tezcore.com Co-authored-by: Grégoire Henry gregoire@tezcore.com
  • Shell: Extract the block-application function into a separate module.
  • Shell: first batch of statistics in the DistributedDB. Co-authored-by: Pietro Abate pietro.abate@tezcore.com Co-authored-by: Mathias Bourgoin mathias.bourgoin@tezcore.com
  • Shell: fix notification of new operations in the mempool.
  • RPC: add a way to access a given block using its level.
  • RPC: add a hash+N and a hash-N notations.
  • RPC: minor changes and add genesis+N.
  • Shell/Peer_metadata: change counters to aribtrary precision integers.
  • Micheline: fix printer for code that exceeds 80 columns.
  • Signer: add handler.mli.
  • Stdlib/Ring: fix ring's semantics.
  • doc: add support page.

Let's do some modifications:

$ echo 'This is Great!' >> \
  /tmp/git-repos-example/hammerlab/biokepi/README.md
$ echo 'More lawyery stuff' >> \
  /tmp/git-repos-example/hammerlab/biokepi/LICENSE
$ echo 'This is tracked' >> \
  /tmp/git-repos-example/hammerlab/coclobas/README.md
$ echo 'This is *not* tracked' >> \
  /tmp/git-repos-example/hammerlab/coclobas/NOT-TRACKED.md
$ echo 'This is Great' >> \
  /tmp/git-repos-example/hammerlab/ketrew/README.md
$ git -C /tmp/git-repos-example/hammerlab/ketrew/ checkout -b \
  new-branch-for-the-example -t master
    M   README.md
    Branch 'new-branch-for-the-example' set up to track local branch 'master'.
$ git -C /tmp/git-repos-example/hammerlab/ketrew/ commit -a -m 'Add \
  greatness to the README'
    [new-branch-for-the-example 83021d3] Add greatness to the README
    1 file changed, 1 insertion(+)

Now in the multi-status we can see the modified files, the untracked counts, and one branch is “ahead” (since we used -t master while creating, it has a remote to define it):

$ git multi-status --show-modified --no-config \
  /tmp/git-repos-example/hammerlab /tmp/git-repos-example/smondet \
  /tmp/git-repos-example/tezos
    --------------------------------------------------------------------------------
    >> /tmp/git-repos-example/hammerlab
    GHub: biokepi                        | U: 0      | M: 2    | Ahead: 0    | Behind: 0
    |- Modified:
    |    - LICENSE
    |    - README.md
    GHub: coclobas                       | U: 1      | M: 1    | Ahead: 0    | Behind: 0
    |- Modified:
    |    - README.md
    GHub: genspio                        | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    GHub: ketrew                         | U: 0      | M: 0    | Ahead: 1    | Behind: 0
    --------------------------------------------------------------------------------
    >> /tmp/git-repos-example/smondet
    GLab: genspio-doc                    | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    GLab: vecosek                        | U: 0      | M: 0    | Ahead: 0    | Behind: 0
    --------------------------------------------------------------------------------
    >> /tmp/git-repos-example/tezos
    GLab: tezos                          | U: 0      | M: 0    | Ahead: 0    | Behind: 0

Let's concentrate the activity-report on /tmp/git-repos-example/hammerlab and on the past 3 days:

$ git activity-report --no-config --since $(date -d '-3 days' \
  +%Y-%m-%d) /tmp/git-repos-example/hammerlab

    ### In `/tmp/git-repos-example/hammerlab`

    #### GHub: genspio
* origin/sm@multigit-readme
* HEAD -> master, origin/master, origin/HEAD
* origin/sm@add-activity-report
```

##### On `master`:
- Add `--section-base` to `git-activity_report`.
- Compute default `--since` to “Last Sunday”.
- Improve markdown output of `git-activity-report`.
- Add more tests of `git-activity-report`.
- Merge `sm@add-activity-report` (PR #98, @smondet).

#### GHub: ketrew

```
* HEAD -> new-branch-for-the-example
```

##### On `master`:

##### On `new-branch-for-the-example`

- Add greatness to the README.


We can see the new commit in the new branch appear in the report ⮵.

And that's all for today ☺ !

License
-------

The code generator is covered by the Apache 2.0
[license](http://www.apache.org/licenses/LICENSE-2.0), the scripts are
ISC [licensed](https://opensource.org/licenses/ISC).