|
2 | 2 | [](https://travis-ci.org/ibabushkin/rust-semverver)
|
3 | 3 |
|
4 | 4 | This repository is hosting a proof-of-concept implementation of an automatic tool checking
|
5 |
| -rust library crates for semantic versioning adherence. The goal is to provide an automated |
6 |
| -command akin to `cargo clippy` that analyzes the current crate's souce code for changes |
7 |
| -compared to the most recent version on `crates.io`. |
| 5 | +rust library crates for semantic versioning adherence, developed during the Google Summer |
| 6 | +of Code 2017. The goal is to provide an automated command akin to `cargo clippy` that |
| 7 | +analyzes the current crate's source code for changes compared to the most recent version |
| 8 | +on `crates.io`. |
8 | 9 |
|
9 | 10 | ## Background
|
10 | 11 | The approach taken is to compile both versions of the crate to `rlib`s and to link them as
|
11 |
| -dependencies of a third crate. Then, a custom compiler driver is run on the resulting |
12 |
| -crate and all necessary analysis is performed in that context. |
| 12 | +dependencies of a third, empty, crate. Then, a custom compiler driver is run on the |
| 13 | +resulting crate and all necessary analysis is performed in that context. |
13 | 14 |
|
14 |
| -The general concepts and aspects of the algorithms used are outlined in more detail in the |
15 |
| -[proposal](https://summerofcode.withgoogle.com/projects/#5063973872336896). |
| 15 | +More information on the inner workings will be provided soon. |
16 | 16 |
|
17 | 17 | ## Installation
|
18 |
| -This is currently irrelevant, as the functionality is not yet implemented. Please check |
19 |
| -back later. |
| 18 | +The tool is implemented as a cargo plugin. As of now, it can be obtained from this git |
| 19 | +repository and compiled from source, provided you have a recent Rust nightly installed: |
| 20 | + |
| 21 | +```sh |
| 22 | +$ rustup update nightly |
| 23 | +$ rustup default nightly |
| 24 | +$ git clone https://github.com/ibabushkin/rust-semverver |
| 25 | +$ cd rust-semverver |
| 26 | +$ cargo install |
| 27 | +``` |
| 28 | + |
| 29 | +At this point, the current development version can be invoked using `cargo semver` in any |
| 30 | +directory your project resides in. If you prefer not to install to `~/.cargo/bin`, you can |
| 31 | +invoke it like so after building with a regular `cargo build`: |
| 32 | + |
| 33 | +```sh |
| 34 | +PATH=/path/to/repo/target/debug:$PATH cargo semver <args> |
| 35 | +``` |
| 36 | + |
| 37 | +If you have built using `cargo build --release` instead, change the path to point to the |
| 38 | +`release` subdirectory of the `target` directory. |
20 | 39 |
|
21 | 40 | ## Usage
|
22 |
| -This is currently irrelevant, as the functionality is not yet implemented. Please check |
23 |
| -back later. |
| 41 | +Invoking `cargo semver -h` gives you the latest help message, which outlines how to use |
| 42 | +the cargo plugin: |
| 43 | + |
| 44 | +```sh |
| 45 | +$ cargo semver -h |
| 46 | +usage: cargo semver [options] [-- cargo options] |
| 47 | + |
| 48 | +Options: |
| 49 | + -h, --help print this message and exit |
| 50 | + -V, --version print version information and exit |
| 51 | + -d, --debug print command to debug and exit |
| 52 | + -s, --stable-path PATH |
| 53 | + use local path as stable/old crate |
| 54 | + -c, --current-path PATH |
| 55 | + use local path as current/new crate |
| 56 | + -S, --stable-pkg SPEC |
| 57 | + use a name-version string as stable/old crate |
| 58 | + -C, --current-pkg SPEC |
| 59 | + use a name-version string as current/new crate |
| 60 | +``` |
| 61 | + |
| 62 | +## Functionality |
| 63 | +The guideline used to implement semver compatibility is the [API evolution |
| 64 | +RFC](https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md), which |
| 65 | +applies the principles of semantic versioning to the Rust language. According to the RFC, |
| 66 | +most changes are already recognized correctly, even though trait- and inherent |
| 67 | +implementations are not yet handled, and some type checks behave incorrectly. |
| 68 | + |
| 69 | +At the time of writing, the following types of changes are recognized and classified |
| 70 | +correctly: |
| 71 | + |
| 72 | +* items moving from `pub` to non-`pub` |
| 73 | +* items changing their kind, i.e. from a `struct` to an `enum` |
| 74 | +* additions and removals of region parameters to and from an item's declaration |
| 75 | +* additions and removals of (possibly defaulted) type parameters to and from an item's |
| 76 | + declaration |
| 77 | +* additions of new and removals of old enum variants |
| 78 | +* additions of new and removals of old enum variant- or struct fields |
| 79 | +* changes from tuple structs or variants to struct variants and vice-versa |
| 80 | +* changes to a function or method's constness |
| 81 | +* additions and removals of a self-parameter to and from methods |
| 82 | +* addition and removal of (posslibly defaulted) trait items |
| 83 | +* changes to the unsafety of a trait |
| 84 | +* type changes of all toplevel items |
| 85 | + |
| 86 | +Yet, the results presented to the user are merely an approximation of the required |
| 87 | +versioning policy, especially at such an early stage of development. |
0 commit comments