8000 feat: monorepo support by oknozor · Pull Request #240 · cocogitto/cocogitto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: monorepo support #240

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

Merged
merged 26 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c224e98
feat: add support for monorepo
oknozor Oct 28, 2022
28dbc8e
refactor: refactor tag serialization & deserialization
oknozor Oct 31, 2022
58ed3f0
refactor: factorize stash on bump failure
oknozor Oct 31, 2022
6f7030b
ci: bump codecov action
oknozor Oct 31, 2022
efcc5fa
refactor: refactor bump increment
oknozor Oct 31, 2022
fb0548f
refactor: split lib into several command packages
oknozor Jan 16, 2023
de337ed
refactor: change monorepo & package bump
oknozor Jan 17, 2023
84e4135
fix(git): fix list tag for monorepos
oknozor Jan 18, 2023
31c545b
fix: remove stderrlog auto colors for some bump messages
oknozor Jan 18, 2023
e3c58e8
test: remove broken stdout assertion
oknozor Jan 18, 2023
5c44dcd
test(monorepo): add integration test
oknozor Jan 18, 2023
ca3587c
fix: dry run for monorepo
oknozor Jan 18, 2023
8cbe74f
fix: gpg sign for package bump
oknozor Jan 18, 2023
1c2b447
style: run hook display
oknozor Jan 18, 2023
9528a19
chore: clippy + fmt
oknozor Jan 18, 2023
160c548
feat: run hooks in package dir
oknozor Jan 18, 2023
788b1c7
fix: add new line after exec
oknozor Jan 18, 2023
322e27b
fix: display version in hook preview
oknozor Jan 18, 2023
919209b
feat: add package template setting
oknozor Jan 18, 2023
60dc811
test: fix tests failing after adding a trailing newline
oknozor Jan 18, 2023
bc57fd3
chore: clippy
oknozor Jan 18, 2023
7ad6197
test: add tests for monorepo and package templates
oknozor Jan 19, 2023
fa09893
docs: update readme screenshots
oknozor Jan 19, 2023
1c09cf8
docs: update readme
oknozor Jan 19, 2023
bb94861
fix: infer built-in template prefix for monorepo and packages
oknozor Jan 19, 2023
763a2d4
feat: add manual bump for monorepo
oknozor Jan 19, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
args: --all-features --workspace --lcov --output-path lcov.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
files: lcov.info
fail_ci_if_error: true
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@

**The Conventional Commits toolbox**

- **Verified commits️:** create conventional compliant commits with ease.
- **Verified commits:** create conventional compliant commits with ease.
- **Automatic Version bump and changelog:** automatically bump versions and generate changelogs with your own custom steps
and workflows.
- **Release profiles:** your branching model requires different steps for releases, pre-release, hotfixes ? We got you
covered !
- **Depends only on libgit2:** cocogitto has one standalone binary, the only system dependency is libgit2.
- **Conventional git log:** search your commit history matching Conventional Commits items such as scope and commit type.
- **GitHub integration:** enforce the conventional commits specification with our GitHub action and bot.
- **Monorepo support:** Automatic versioning for mono-repositories is supported out of the box.

<p align="center">
<a href="https://docs.cocogitto.io/"><strong>Explore Cocogitto's docs&nbsp;&nbsp;▶</strong></a>
Expand Down
Binary file removed docs/assets/cocogitto-bot-example.png
Binary file not shown.
Binary file modified docs/assets/cog-bot-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/cog-bump-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/bin/cog/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn edit_message(
) -> Result<(Option<String>, Option<String>, bool)> {
let template = prepare_edit_template(typ, message, scope, breaking);

let edited = edit::edit(&template)?;
let edited = edit::edit(template)?;

if edited.lines().all(|line| {
let trimmed = line.trim_start();
Expand Down
57 changes: 49 additions & 8 deletions src/bin/cog/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;

use cocogitto::conventional::changelog::template::{RemoteContext, Template};
use cocogitto::conventional::commit as conv_commit;
use cocogitto::conventional::version::VersionIncrement;
use cocogitto::conventional::version::IncrementCommand;
use cocogitto::git::hook::HookKind;
use cocogitto::git::revspec::RevspecPattern;
use cocogitto::log::filter::{CommitFilter, CommitFilters};
Expand All @@ -26,6 +26,12 @@ fn hook_profiles() -> PossibleValuesParser {
profiles.into()
}

fn packages() -> PossibleValuesParser {
let profiles = SETTINGS.packages.keys().map(|profile| -> &str { profile });

profiles.into()
}

/// Shell with auto-generated completion script available.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
Expand Down Expand Up @@ -230,6 +236,10 @@ enum Command {
#[arg(short = 'H', long, value_parser = hook_profiles())]
hook_profile: Option<String>,

/// Specify which package to bump for monorepo
#[arg(long, value_parser = packages())]
package: Option<String>,

/// Dry-run: print the target version. No action taken
#[arg(short, long)]
dry_run: bool,
Expand Down Expand Up @@ -300,20 +310,50 @@ fn main() -> Result<()> {
patch,
pre,
hook_profile,
package,
dry_run,
} => {
let mut cocogitto = CocoGitto::get()?;

let increment = match version {
Some(version) => VersionIncrement::Manual(version),
None if auto => VersionIncrement::Auto,
None if major => VersionIncrement::Major,
None if minor => VersionIncrement::Minor,
None if patch => VersionIncrement::Patch,
Some(version) => IncrementCommand::Manual(version),
None if auto => IncrementCommand::Auto,
None if major => IncrementCommand::Major,
None if minor => IncrementCommand::Minor,
None if patch => IncrementCommand::Patch,
_ => unreachable!(),
};

cocogitto.create_version(increment, pre.as_deref(), hook_profile.as_deref(), dry_run)?
let is_monorepo = !SETTINGS.packages.is_empty();

if is_monorepo {
match package {
Some(package_name) => {
// Safe unwrap here, package name is validated by clap
let package = SETTINGS.packages.get(&package_name).unwrap();
cocogitto.create_package_version(
(&package_name, package),
increment,
pre.as_deref(),
hook_profile.as_deref(),
dry_run,
)?
}
None => cocogitto.create_monorepo_version(
increment,
pre.as_deref(),
hook_profile.as_deref(),
dry_run,
)?,
}
} else {
cocogitto.create_version(
increment,
pre.as_deref(),
hook_profile.as_deref(),
dry_run,
)?
}
}
Command::Verify {
message,
Expand Down Expand Up @@ -421,7 +461,7 @@ fn main() -> Result<()> {
println!("{}", result);
}
Command::Init { path } => {
cocogitto::init(&path)?;
cocogitto::command::init::init(&path)?;
}
Command::InstallHook { hook_type } => {
let cocogitto = CocoGitto::get()?;
Expand Down Expand Up @@ -466,6 +506,7 @@ fn main() -> Result<()> {
}
}

println!();
Ok(())
}

Expand Down
Loading
0