Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

09 05 updates #6

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Change Log

## [2.1.0] - 2024-09-05

### Changed

- '-d' working directory flag changed to '-w'
- Delete local git tag when a checkpoint fails to push
- Changed checkpoint id format from incrementing semver to incrementing `monorail-N`, N > 0

## [2.0.0] - 2024-09-03

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "monorail"
description = "A monorepo overlay for version control systems."
description = "A monorepo overlay."
license = "MIT"
homepage = "https://github.com/pnordahl/monorail"
repository = "https://github.com/pnordahl/monorail"
version = "2.0.0"
version = "2.1.0"
authors = ["Patrick Nordahl <[email protected]>"]
edition = "2021"
keywords = ["monorail", "monorepo"]
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Monorail has a simple lexicon:

`monorail` works by labeling filesystem paths within a repository as meaningful. These labels determine how changes reported by the vcs are interpreted. The label types are:

* target: A unique container that can be referenced by change detection and script execution. For example, `ui`, `api`, and `database`, as directories carrying files specific to those projects, would be good candidates for being labeled as targets. So too would a parent directory like `apps`, because targets are _recursive_, which means that targets can lie within the path of other targets.
* target: A unique container that can be referenced by change detection and script execution. For example, `ui`, `api`, and `database`, as directories carrying files specific to those projects, would be good candidates for being labeled as targets. You can also label directories containing multiple targets as a target (e.g. `apps` containing your projects).
* links: A set of paths that recursively affect a target and any targets that lie in its path. For example, a `vendor` directory carrying copies of third-party code may require that all targets within a target's path subdirectories be re-tested.
* uses: A set of paths that affect a target. For example, a directory called `common`, carrying files used by multiple targets might be referred to by multiple targets in their `uses` arrays.
* ignores: a set of paths that do not affect a target
Expand All @@ -59,7 +59,7 @@ For executing code against targets, two more terms:

_NOTE: this tutorial assumes a UNIX-like environment._

In this tutorial, you'll learn:
In this tutorial, you'll learn about:

* mapping repository paths to targets
* analyzing
Expand Down Expand Up @@ -114,7 +114,7 @@ _NOTE_: All filesystem locations specified in `Monorail.toml` are relative to th

## Analyzing changes

`monorail` will detect changes since the last checkpoint; see: [Checkpointing](##Checkpointing). For `git`, this means uncommitted, committed, and pushed files since the last annotated tag created by `monorail checkpoint create`.
`monorail` will detect changes since the last checkpoint; see: [Checkpointing](#checkpointing). For `git`, this means uncommitted, committed, and pushed files since the last annotated tag created by `monorail checkpoint create`.

### Analyze showing no affected targets

Expand Down Expand Up @@ -223,7 +223,7 @@ Push, and view changes again:
git push && monorail analyze | jq .
```

As with the commit, `monorail` still knows about the changes after a push. The reason for this will be explained in the section on checkpointing below.
As with the commit, `monorail` still knows about the changes after a push. The reason for this will be explained in the section on [Checkpointing](#checkpointing) below.

## Declaring "uses" and "links"

Expand Down Expand Up @@ -647,7 +647,7 @@ monorail checkpoint create --dry-run -t patch | jq .

```json
{
"id": "v0.0.1",
"id": "monorail-1",
"targets": [
"group1/Lockfile",
"group1/common/library1",
Expand All @@ -669,7 +669,7 @@ monorail checkpoint create -t patch | jq .

```json
{
"id": "v0.0.1",
"id": "monorail-1",
"targets": [
"group1/Lockfile",
"group1/common/library1",
Expand All @@ -696,13 +696,13 @@ monorail analyze | jq .
Finally, our newly-pushed tag is now in the remote. To see this, execute:

```sh
git -C ../monorail-tutorial-remote show -s --format=%B v0.0.1
git -C ../monorail-tutorial-remote show -s --format=%B monorail-1
```

... which outputs

```
tag v0.0.1
tag monorail-1
Tagger: John Doe <[email protected]>

rust
Expand Down
10 changes: 5 additions & 5 deletions ext/bash/monorail-bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function print_help {
echo ""
echo " -h Display this help message."
echo " -f <file> The monorail configuration file to use. Default: Monorail.toml"
echo " -d <path> The directory to run commands from. Default: current directory"
echo " -w <path> The directory to run commands from. Default: current directory"
echo " -v Print extra information."
echo ""
echo "Subcommands:"
Expand Down Expand Up @@ -69,7 +69,7 @@ function process_exec {
fi

# build array of args to pass to monorail
monorail_args=("-f" "$config_file" "-d" "$working_directory")
monorail_args=("-f" "$config_file" "-w" "$working_directory")

if [ ${#commands[@]} -eq 0 ]; then
log_error "error: no commands specified"
Expand Down Expand Up @@ -172,7 +172,7 @@ function execute_target_command {
local target=$2
local script=$3
pushd "$working_directory" > /dev/null || return
if [ ! -d "$target" ]; then
if [ ! -w "$target" ]; then
log_verbose "$(printf "NOTE: Ignoring command for non-directory target; command: %s, target: %s" "$command" "$target")"
popd > /dev/null || return
return
Expand All @@ -199,7 +199,7 @@ function execute_target_command {
}

# parse options to `monorail-bash`
while getopts "f:d:hv" opt; do
while getopts "f:w:hv" opt; do
case "$opt" in
h )
print_help
Expand All @@ -208,7 +208,7 @@ while getopts "f:d:hv" opt; do
f )
config_file=$OPTARG
;;
d )
w )
working_directory=$OPTARG
;;
v )
Expand Down
38 changes: 14 additions & 24 deletions src/bin/monorail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn get_app() -> clap::Command {
)
.arg(
Arg::new("working-directory")
.short('d')
.short('w')
.long("working-directory")
.help("Sets a directory to use for execution")
.num_args(1),
Expand All @@ -49,29 +49,19 @@ fn get_app() -> clap::Command {
.subcommand(Command::new("config").about("Show configuration, including runtime default values"))
.subcommand(Command::new("checkpoint")
.subcommand(
Command::new("create")
.about("Create a checkpoint of current changes")
.after_help(r#"This command analyzes changed targets since the last checkpoint, constructs a checkpoint object appropriate for the configured vcs"#)
.arg(arg_git_path.clone())
.arg(arg_use_libgit2_status.clone())
.arg(
Arg::new("type")
.short('t')
.long("type")
.help("Semver component to increment for this checkpoint")
.value_parser(["patch", "minor", "major"])
.ignore_case(true)
.required(true)
.num_args(1),
)
.arg(
Arg::new("dry-run")
.short('d')
.long("dry-run")
.help("Do not apply any changes locally (for a distributed version control system) or remotely")
.action(ArgAction::SetTrue),
))
)
Command::new("create")
.about("Create a checkpoint of current changes")
.after_help(r#"This command analyzes changed targets since the last checkpoint, constructs a checkpoint object appropriate for the configured vcs"#)
.arg(arg_git_path.clone())
.arg(arg_use_libgit2_status.clone())
.arg(
Arg::new("dry-run")
.short('d')
.long("dry-run")
.help("Do not apply any changes locally (for a distributed version control system) or remotely")
.action(ArgAction::SetTrue),
)
))
.subcommand(
Command::new("analyze")
.about("Analyze repository changes and targets")
Expand Down
Loading
Loading