Skip to content

Commit

Permalink
fix: Fix shallow checkout when base is provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Nov 27, 2024
1 parent 194fd41 commit cb5882b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#### 🐞 Fixes

- Fixed a Git "fatal: bad object" error when submodules are in being used.
- Fixed an issue where `moon ci` would trigger a shallow checkout error, even when a base revision
is provided.

## 1.30.0

Expand Down
2 changes: 1 addition & 1 deletion crates/app/src/app_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use thiserror::Error;
pub enum AppError {
#[diagnostic(code(app::ci::no_shallow))]
#[error(
"CI requires a full VCS history to operate correctly. Please avoid shallow checkouts."
"CI requires a full VCS history or a base revision to operate correctly. Please avoid shallow checkouts."
)]
CiNoShallowHistory,

Expand Down
4 changes: 2 additions & 2 deletions crates/app/src/commands/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ async fn gather_touched_files(
&vcs,
&QueryTouchedFilesOptions {
default_branch: true,
base,
base: base.clone(),
head,
..QueryTouchedFilesOptions::default()
},
)
.await?;

if result.shallow {
if result.shallow && base.is_none() {
return Err(AppError::CiNoShallowHistory.into());
}

Expand Down
8 changes: 6 additions & 2 deletions crates/app/src/queries/touched_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ pub async fn query_touched_files(

// On a branch, so compare branch against remote base/default branch
} else if !options.local {
check_shallow!(vcs);
let base_env = env::var("MOON_BASE");

if options.base.is_none() && base_env.is_err() {
check_shallow!(vcs);
}

let base = env::var("MOON_BASE").unwrap_or_else(|_| {
let base = base_env.unwrap_or_else(|_| {
options
.base
.as_deref()
Expand Down

0 comments on commit cb5882b

Please sign in to comment.