Skip to content

Commit 2bd0bb3

Browse files
har7animsnif
authored andcommitted
xtask: Disable pusing during publish (zellij-org#3040)
* xtask: Add `--no-push` flag to `publish` which can be used when simulating releases to work without a writable git fork of the zellij code. * xtask: Fix borrow issues * xtask/pipe: Require lockfile in publish to avoid errors from invalid dependency versions. * CHANGELOG: Add PR zellij-org#3040.
1 parent 52d638a commit 2bd0bb3

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1313
* perf(plugins): improve plugin download & load feature (https://github.com/zellij-org/zellij/pull/3001)
1414
* chore: bump Rust toolchain to 1.75.0 (https://github.com/zellij-org/zellij/pull/3039)
1515
* feat(plugins): introduce pipes to control data flow to plugins from the command line (https://github.com/zellij-org/zellij/pull/3066)
16+
* feat(xtask): allow publishing without pushing changes (https://github.com/zellij-org/zellij/pull/3040)
1617

1718
## [0.39.2] - 2023-11-29
1819
* fix(cli): typo in cli help (https://github.com/zellij-org/zellij/pull/2906)

xtask/src/flags.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ xflags::xflags! {
3838
cmd publish {
3939
/// Perform a dry-run (don't push/publish anything)
4040
optional --dry-run
41+
/// Publish but don't push a commit to git (only works with '--cargo-registry')
42+
optional --no-push
4143
/// Push commit to custom git remote
4244
optional --git-remote remote: OsString
4345
/// Publish crates to custom registry
@@ -159,6 +161,7 @@ pub struct Manpage;
159161
#[derive(Debug)]
160162
pub struct Publish {
161163
pub dry_run: bool,
164+
pub no_push: bool,
162165
pub git_remote: Option<OsString>,
163166
pub cargo_registry: Option<OsString>,
164167
}

xtask/src/pipelines.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,11 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
197197
None
198198
};
199199
let remote = flags.git_remote.unwrap_or("origin".into());
200-
let registry = if let Some(registry) = flags.cargo_registry {
200+
let registry = if let Some(ref registry) = flags.cargo_registry {
201201
Some(format!(
202202
"--registry={}",
203203
registry
204+
.clone()
204205
.into_string()
205206
.map_err(|registry| anyhow::Error::msg(format!(
206207
"failed to convert '{:?}' to valid registry name",
@@ -212,6 +213,9 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
212213
None
213214
};
214215
let registry = registry.as_ref();
216+
if flags.no_push && flags.cargo_registry.is_none() {
217+
anyhow::bail!("flag '--no-push' can only be used with '--cargo-registry'");
218+
}
215219

216220
sh.change_dir(crate::project_root());
217221
let cargo = crate::cargo().context(err_context)?;
@@ -304,6 +308,8 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
304308
// Push commit and tag
305309
if flags.dry_run {
306310
println!("Skipping push due to dry-run");
311+
} else if flags.no_push {
312+
println!("Skipping push due to no-push");
307313
} else {
308314
cmd!(sh, "git push --atomic {remote} main v{version}")
309315
.run()
@@ -331,7 +337,7 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
331337

332338
if let Err(err) = cmd!(
333339
sh,
334-
"{cargo} publish {registry...} {more_args...} {dry_run...}"
340+
"{cargo} publish --locked {registry...} {more_args...} {dry_run...}"
335341
)
336342
.run()
337343
.context(err_context)

0 commit comments

Comments
 (0)