diff --git a/.github/workflows/moon.yml b/.github/workflows/moon.yml index 791e281dae2..c09c1c61b70 100644 --- a/.github/workflows/moon.yml +++ b/.github/workflows/moon.yml @@ -45,7 +45,7 @@ jobs: args: -- --color --log trace ci --base ${{ github.base_ref || 'master' }} env: MOONBASE_SECRET_KEY: ${{ secrets.MOONBASE_SECRET_KEY }} - MOONBASE_API_KEY: ${{ secrets.MOONBASE_API_KEY }} + MOONBASE_ACCESS_KEY: ${{ secrets.MOONBASE_ACCESS_KEY }} - uses: moonrepo/run-report-action@v1 with: access-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.moon/workspace.yml b/.moon/workspace.yml index 24827ccb204..a40129d1fbe 100644 --- a/.moon/workspace.yml +++ b/.moon/workspace.yml @@ -1,4 +1,4 @@ -# Trigger CI: 9 +# Trigger CI: 10 $schema: '../website/static/schemas/workspace.json' diff --git a/.yarn/versions/ac3556d5.yml b/.yarn/versions/ac3556d5.yml new file mode 100644 index 00000000000..1f2a5d9c201 --- /dev/null +++ b/.yarn/versions/ac3556d5.yml @@ -0,0 +1,9 @@ +releases: + "@moonrepo/cli": patch + "@moonrepo/core-linux-arm64-gnu": patch + "@moonrepo/core-linux-arm64-musl": patch + "@moonrepo/core-linux-x64-gnu": patch + "@moonrepo/core-linux-x64-musl": patch + "@moonrepo/core-macos-arm64": patch + "@moonrepo/core-macos-x64": patch + "@moonrepo/core-windows-x64-msvc": patch diff --git a/crates/core/vcs/src/git.rs b/crates/core/vcs/src/git.rs index fa440059ae7..24c0a5a8784 100644 --- a/crates/core/vcs/src/git.rs +++ b/crates/core/vcs/src/git.rs @@ -51,6 +51,30 @@ impl Git { }) } + pub fn extract_slug_from_remote(output: String) -> Result { + // git@github.com:moonrepo/moon.git + let remote = if output.starts_with("git@") { + format!("https://{}", output.replace(':', "/")) + // https://github.com/moonrepo/moon + } else { + output + }; + + let url = url::Url::parse(&remote) + .map_err(|e| VcsError::FailedToParseGitRemote(e.to_string()))?; + let mut slug = url.path(); + + if slug.starts_with('/') { + slug = &slug[1..]; + } + + if slug.ends_with(".git") { + slug = &slug[0..(slug.len() - 4)]; + } + + Ok(slug.to_owned()) + } + async fn get_merge_base(&self, base: &str, head: &str) -> VcsResult { let mut args = string_vec!["merge-base", head]; let mut candidates = string_vec![base.to_owned()]; @@ -240,27 +264,7 @@ impl Vcs for Git { ) .await?; - // git@github.com:moonrepo/moon.git - let remote = if output.starts_with("git@") { - format!("https://{}", output.replace(':', "/")) - // https://github.com/moonrepo/moon - } else { - output - }; - - let url = url::Url::parse(&remote) - .map_err(|e| VcsError::FailedToParseGitRemote(e.to_string()))?; - let mut slug = url.path(); - - if slug.starts_with('/') { - slug = &slug[1..]; - } - - if slug.ends_with(".git") { - slug = &slug[0..(slug.len() - 4)]; - } - - Ok(slug.to_owned()) + Self::extract_slug_from_remote(output) } // https://git-scm.com/docs/git-status#_short_format diff --git a/crates/core/vcs/tests/git_test.rs b/crates/core/vcs/tests/git_test.rs index e401c82e8ff..c0af4808f0c 100644 --- a/crates/core/vcs/tests/git_test.rs +++ b/crates/core/vcs/tests/git_test.rs @@ -463,3 +463,39 @@ mod touched_files_via_diff { ); } } + +mod slug_parsing { + use super::*; + + #[test] + fn supports_http() { + assert_eq!( + Git::extract_slug_from_remote("http://github.com/moonrepo/moon".into()).unwrap(), + "moonrepo/moon" + ); + assert_eq!( + Git::extract_slug_from_remote("http://github.com/moonrepo/moon.git".into()).unwrap(), + "moonrepo/moon" + ); + assert_eq!( + Git::extract_slug_from_remote("https://github.com/moonrepo/moon".into()).unwrap(), + "moonrepo/moon" + ); + assert_eq!( + Git::extract_slug_from_remote("https://github.com/moonrepo/moon.git".into()).unwrap(), + "moonrepo/moon" + ); + } + + #[test] + fn supports_git() { + assert_eq!( + Git::extract_slug_from_remote("git@github.com:moonrepo/moon".into()).unwrap(), + "moonrepo/moon" + ); + assert_eq!( + Git::extract_slug_from_remote("git@github.com:moonrepo/moon.git".into()).unwrap(), + "moonrepo/moon" + ); + } +}