Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: moonrepo/moon
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @moonrepo/cli@1.32.4
Choose a base ref
...
head repository: moonrepo/moon
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @moonrepo/cli@1.32.5
Choose a head ref
  • 2 commits
  • 18 files changed
  • 2 contributors

Commits on Feb 14, 2025

  1. fix: Audit 02/14 (#1830)

    * Fix touched files on default.
    
    * Fox uv.
    
    * Aliases.
    
    * Deps.
    
    * Only run in uv.
    
    * Fixes.
    
    * Fix git.
    
    * Change logic.
    
    * More changes.
    milesj authored Feb 14, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    edfaafa View commit details
  2. Release

    - @moonrepo/cli@1.32.5
    - @moonrepo/core-linux-arm64-gnu@1.32.5
    - @moonrepo/core-linux-x64-gnu@1.32.5
    - @moonrepo/core-linux-x64-musl@1.32.5
    - @moonrepo/core-linux-arm64-musl@1.32.5
    - @moonrepo/core-macos-arm64@1.32.5
    - @moonrepo/core-macos-x64@1.32.5
    - @moonrepo/core-windows-x64-msvc@1.32.5
    milesj committed Feb 14, 2025
    Copy the full SHA
    d77bae9 View commit details
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.32.5

#### 🚀 Updates

- Updated Python uv with new features:
- Project aliases are inferred from `project.name` in `pyproject.toml`.
- Implicit project dependencies are inferred from `project.dependencies` in `pyproject.toml`.
- Requires a bare identifier with no version/url/origin markers.
- Currently does not support `tool.uv` or workspaces.

#### 🐞 Fixes

- Fixed an issue where no touched files would be found when pushing commits on the default branch.
- Fixed an issue where `pyproject.toml` or `uv.lock` would sometimes not be parsed.

## 1.32.4

#### 🐞 Fixes
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ starbase_archive = { version = "0.9.4", default-features = false, features = [
starbase_events = "0.6.8"
starbase_sandbox = "0.8.2"
starbase_shell = "0.6.13"
starbase_styles = { version = "0.4.4", features = ["relative-path"] }
starbase_styles = { version = "0.4.14", features = ["relative-path"] }
starbase_utils = { version = "0.10.1", default-features = false, features = [
"editor-config",
"miette",
5 changes: 3 additions & 2 deletions crates/app/src/commands/query.rs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ pub use crate::queries::touched_files::*;
use crate::session::CliSession;
use clap::{Args, Subcommand};
use moon_affected::{AffectedTracker, DownstreamScope, UpstreamScope};
use moon_common::is_ci;
use moon_vcs::TouchedStatus;
use starbase::AppResult;
use starbase_styles::color;
@@ -443,7 +444,7 @@ pub struct QueryTouchedFilesArgs {
long = "defaultBranch",
help = "When on the default branch, compare against the previous revision"
)]
default_branch: bool,
default_branch: Option<bool>,

#[arg(long, help = "Current branch, commit, or revision to compare with")]
head: Option<String>,
@@ -465,7 +466,7 @@ pub async fn touched_files(session: CliSession, args: QueryTouchedFilesArgs) ->

let options = QueryTouchedFilesOptions {
base: args.base,
default_branch: args.default_branch,
default_branch: args.default_branch.unwrap_or_else(is_ci),
head: args.head,
json: args.json,
local: args.local,
57 changes: 29 additions & 28 deletions crates/app/src/queries/touched_files.rs
Original file line number Diff line number Diff line change
@@ -57,41 +57,42 @@ pub async fn query_touched_files(

let default_branch = vcs.get_default_branch().await?;
let current_branch = vcs.get_local_branch().await?;
let base_revision = env::var("MOON_BASE").ok().or(options.base.clone());
let head_revision = env::var("MOON_HEAD").ok().or(options.head.clone());
let base_value = env::var("MOON_BASE").ok().or(options.base.clone());
let base = base_value.as_deref().unwrap_or(&default_branch);
let head_value = env::var("MOON_HEAD").ok().or(options.head.clone());
let head = head_value.as_deref().unwrap_or("HEAD");

// Determine whether we should check against the previous
// commit using a HEAD~1 query
let check_against_previous = base_value.is_none()
&& head_value.is_none()
&& vcs.is_default_branch(&current_branch)
&& options.default_branch;

// Don't check for shallow if base is set,
// since we can assume the user knows what they're doing
if base_value.is_none() {
check_shallow!(vcs);
}

// Check locally touched files
let touched_files_map = if options.local {
trace!("Against local");

vcs.get_touched_files().await?
}
// Otherwise compare against remote
else if base_revision.is_none()
&& options.default_branch
&& vcs.is_default_branch(&current_branch)
{
// Since base is not set, ensure we're not in a
// shallow checkout
check_shallow!(vcs);

// Otherwise compare against previous commit
else if check_against_previous {
trace!(
"Against previous revision, as we're on the default branch \"{}\"",
current_branch
);

vcs.get_touched_files_against_previous_revision(&default_branch)
.await?
} else {
// Don't check for shallow since base is set,
// and we can assume the user knows what they're doing
if base_revision.is_none() {
check_shallow!(vcs);
}

let base = base_revision.as_deref().unwrap_or(&default_branch);
let head = head_revision.as_deref().unwrap_or("HEAD");

}
// Otherwise against remote between 2 revisions
else {
trace!(
"Against remote using base \"{}\" with head \"{}\"",
base,
@@ -139,12 +140,10 @@ pub async fn query_touched_files(
.map(|f| WorkspaceRelativePathBuf::from(standardize_separators(f)))
.collect();

if !touched_files.is_empty() {
debug!(
files = ?touched_files.iter().map(|f| f.as_str()).collect::<Vec<_>>(),
"Found touched files",
);
}
debug!(
files = ?touched_files.iter().map(|f| f.as_str()).collect::<Vec<_>>(),
"Found touched files",
);

Ok(QueryTouchedFilesResult {
files: touched_files,
@@ -181,10 +180,12 @@ pub async fn load_touched_files(
}
}

let ci = is_ci();
let result = query_touched_files(
vcs,
&QueryTouchedFilesOptions {
local: !is_ci(),
default_branch: ci,
local: !ci,
..QueryTouchedFilesOptions::default()
},
)
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "moon_cli"
version = "1.32.4"
version = "1.32.5"
edition = "2021"
publish = false

17 changes: 11 additions & 6 deletions legacy/core/test-utils/src/sandbox.rs
Original file line number Diff line number Diff line change
@@ -60,11 +60,12 @@ impl Sandbox {

// And commit them... this seems like a lot of overhead?
self.run_git(|cmd| {
cmd.args(["commit", "-m", "Fixtures"])
.env("GIT_AUTHOR_NAME", "moon tests")
.env("GIT_AUTHOR_EMAIL", "fakeemail@moonrepo.dev")
.env("GIT_COMMITTER_NAME", "moon tests")
.env("GIT_COMMITTER_EMAIL", "fakeemail@moonrepo.dev");
cmd.args(["commit", "-m", "Fixtures"]);
});

// Add another commit so we can do HEAD~1 tests
self.run_git(|cmd| {
cmd.args(["commit", "-m", "Bump", "--allow-empty"]);
});

self
@@ -75,7 +76,11 @@ impl Sandbox {
C: FnOnce(&mut StdCommand),
{
let mut cmd = StdCommand::new(if cfg!(windows) { "git.exe" } else { "git" });
cmd.current_dir(self.path());
cmd.current_dir(self.path())
.env("GIT_AUTHOR_NAME", "moon tests")
.env("GIT_AUTHOR_EMAIL", "fakeemail@moonrepo.dev")
.env("GIT_COMMITTER_NAME", "moon tests")
.env("GIT_COMMITTER_EMAIL", "fakeemail@moonrepo.dev");

handler(&mut cmd);

6 changes: 3 additions & 3 deletions legacy/python/lang/src/uv.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ fn read_file(path: &Path) -> miette::Result<PyProjectToml> {
config_cache_container!(
PyProjectTomlCache,
PyProjectToml,
"package-lock.json",
"pyproject.toml",
read_file
);

@@ -35,15 +35,15 @@ pub struct UvLockPackage {
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct UvLock {
pub packages: Vec<UvLockPackage>,
pub package: Vec<UvLockPackage>,
}

#[cached(result)]
pub fn load_lockfile_dependencies(path: PathBuf) -> miette::Result<LockfileDependencyVersions> {
let mut deps: LockfileDependencyVersions = FxHashMap::default();
let lockfile: UvLock = toml::read_file(&path)?;

for package in lockfile.packages {
for package in lockfile.package {
let dep = deps.entry(package.name).or_default();
dep.push(package.version);
dep.push(package.sdist.hash);
93 changes: 87 additions & 6 deletions legacy/python/platform/src/python_platform.rs
Original file line number Diff line number Diff line change
@@ -2,12 +2,14 @@ use crate::{actions, toolchain_hash::PythonToolchainHash};
use moon_action::Operation;
use moon_action_context::ActionContext;
use moon_common::{
color,
path::{is_root_level_source, WorkspaceRelativePath},
Id,
};
use moon_config::{
HasherConfig, HasherOptimization, PlatformType, ProjectConfig, ProjectsAliasesList,
ProjectsSourcesList, PythonConfig, PythonPackageManager, UnresolvedVersionSpec,
DependencyConfig, DependencyScope, DependencySource, HasherConfig, HasherOptimization,
PlatformType, ProjectConfig, ProjectsAliasesList, ProjectsSourcesList, PythonConfig,
PythonPackageManager, UnresolvedVersionSpec,
};
use moon_console::Console;
use moon_hash::{ContentHasher, DepsHash};
@@ -26,13 +28,15 @@ use std::{
path::{Path, PathBuf},
sync::Arc,
};
use tracing::instrument;
use tracing::{debug, instrument};

pub struct PythonPlatform {
pub config: PythonConfig,

console: Arc<Console>,

package_names: FxHashMap<String, Id>,

proto_env: Arc<ProtoEnvironment>,

toolchain: ToolManager<PythonTool>,
@@ -53,6 +57,7 @@ impl PythonPlatform {
toolchain: ToolManager::new(Runtime::new(Id::raw("python"), RuntimeReq::Global)),
workspace_root: workspace_root.to_path_buf(),
console,
package_names: FxHashMap::default(),
}
}
}
@@ -116,13 +121,89 @@ impl Platform for PythonPlatform {
#[instrument(skip_all)]
fn load_project_graph_aliases(
&mut self,
_projects_list: &ProjectsSourcesList,
_aliases_list: &mut ProjectsAliasesList,
projects_list: &ProjectsSourcesList,
aliases_list: &mut ProjectsAliasesList,
) -> miette::Result<()> {
// Not supported
if self.config.package_manager == PythonPackageManager::Uv {
debug!(
"Loading names (aliases) from project {}'s",
color::file("pyproject.toml")
);

for (project_id, project_source) in projects_list {
if let Some(data) =
uv::PyProjectTomlCache::read(project_source.to_path(&self.workspace_root))?
{
if let Some(project) = data.project {
let package_name = project.name;

self.package_names
.insert(package_name.clone(), project_id.to_owned());

if package_name == project_id.as_str() {
continue;
}

debug!(
"Inheriting alias {} for project {}",
color::label(&package_name),
color::id(project_id)
);

aliases_list.push((project_id.to_owned(), package_name.clone()));
}
}
}
}

Ok(())
}

#[instrument(skip(self))]
fn load_project_implicit_dependencies(
&self,
project_id: &str,
project_source: &str,
) -> miette::Result<Vec<DependencyConfig>> {
let mut implicit_deps = vec![];

if self.config.package_manager == PythonPackageManager::Uv {
debug!(
"Scanning {} for implicit dependency relations",
color::id(project_id),
);

// TODO: support parsing `tool.uv` sections
if let Some(data) =
uv::PyProjectTomlCache::read(self.workspace_root.join(project_source))?
{
if let Some(project) = data.project {
if let Some(deps) = project.dependencies {
for dep in deps {
let dep_name = dep.name.to_string();

if dep.extras.is_empty()
&& dep.version_or_url.is_none()
&& dep.origin.is_none()
{
if let Some(dep_project_id) = self.package_names.get(&dep_name) {
implicit_deps.push(DependencyConfig {
id: dep_project_id.to_owned(),
scope: DependencyScope::Production,
source: DependencySource::Implicit,
via: Some(dep_name.clone()),
});
}
}
}
}
}
}
}

Ok(implicit_deps)
}

// TOOLCHAIN

fn is_toolchain_enabled(&self) -> miette::Result<bool> {
Loading