Unverified Commit 1bb03e54 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Remove dead subcommand from publisher and switch to regex-lite (#3560)



This PR removes the now unused upgrade-runtime-crates-version subcommand
from publisher, and also switches it to regex-lite since it doesn't need
the full regex feature set.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: default avatarysaito1001 <awsaito@amazon.com>
parent 692cdfeb
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -973,7 +973,7 @@ dependencies = [
 "handlebars",
 "once_cell",
 "pretty_assertions",
 "regex",
 "regex-lite",
 "semver",
 "serde",
 "serde_json",
@@ -1037,6 +1037,12 @@ dependencies = [
 "regex-syntax 0.8.2",
]

[[package]]
name = "regex-lite"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e"

[[package]]
name = "regex-syntax"
version = "0.6.29"
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ dialoguer = "0.8"
fs-err = "2"
handlebars = "4.2"
once_cell = "1.16.0"
regex = "1.5.4"
regex-lite = "0.1.5"
semver = "1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
+6 −3
Original line number Diff line number Diff line
@@ -4,10 +4,14 @@
 */

use anyhow::Result;
use regex::Regex;
use once_cell::sync::Lazy;
use regex_lite::Regex;
use smithy_rs_tool_common::shell::{handle_failure, output_text, ShellOperation};
use std::process::Command;

static LINE_REGEX: Lazy<Regex> =
    Lazy::new(|| Regex::new(r"^([\w\d\-_:]+)\s+\([\w\d\s\-_]+\)$").unwrap());

pub struct GetOwners {
    program: &'static str,
    package_name: String,
@@ -33,9 +37,8 @@ impl ShellOperation for GetOwners {

        let mut result = Vec::new();
        let (stdout, _) = output_text(&output);
        let line_re = Regex::new(r"^([\w\d\-_:]+)\s+\([\w\d\s\-_]+\)$").unwrap();
        for line in stdout.lines() {
            if let Some(captures) = line_re.captures(line) {
            if let Some(captures) = LINE_REGEX.captures(line) {
                let user_id = captures.get(1).unwrap().as_str();
                result.push(user_id.to_string());
            } else {
+0 −10
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@ use publisher::subcommand::publish::subcommand_publish;
use publisher::subcommand::publish::PublishArgs;
use publisher::subcommand::tag_versions_manifest::subcommand_tag_versions_manifest;
use publisher::subcommand::tag_versions_manifest::TagVersionsManifestArgs;
use publisher::subcommand::upgrade_runtime_crates_version::subcommand_upgrade_runtime_crates_version;
use publisher::subcommand::upgrade_runtime_crates_version::UpgradeRuntimeCratesVersionArgs;
use publisher::subcommand::yank_release::{subcommand_yank_release, YankReleaseArgs};
use tracing_subscriber::fmt::format::FmtSpan;

@@ -26,11 +24,6 @@ use tracing_subscriber::fmt::format::FmtSpan;
enum Args {
    /// Fixes path dependencies in manifests to also have version numbers
    FixManifests(FixManifestsArgs),
    /// Upgrade the version of the runtime crates used by the code generator (via `gradle.properties`).
    ///
    /// The command will fail if you try to perform a downgrade - e.g. change the version from
    /// `0.53.1` to `0.52.0` or `0.53.0`.
    UpgradeRuntimeCratesVersion(UpgradeRuntimeCratesVersionArgs),
    /// Publishes crates to crates.io
    Publish(PublishArgs),
    /// Publishes an empty library crate to crates.io when a new runtime crate is introduced.
@@ -59,9 +52,6 @@ async fn main() -> Result<()> {

    match Args::parse() {
        Args::ClaimCrateNames(args) => subcommand_claim_crate_names(&args).await?,
        Args::UpgradeRuntimeCratesVersion(args) => {
            subcommand_upgrade_runtime_crates_version(&args).await?
        }
        Args::Publish(args) => subcommand_publish(&args).await?,
        Args::FixManifests(args) => subcommand_fix_manifests(&args).await?,
        Args::YankRelease(args) => subcommand_yank_release(&args).await?,
+0 −1
Original line number Diff line number Diff line
@@ -9,5 +9,4 @@ pub mod generate_version_manifest;
pub mod hydrate_readme;
pub mod publish;
pub mod tag_versions_manifest;
pub mod upgrade_runtime_crates_version;
pub mod yank_release;
Loading