Skip to content
This repository was archived by the owner on Nov 3, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 36 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ jobs:

- name: Clone dependencies
shell: bash
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
git clone --depth 1 https://github.com/gitkb/meta_plugin_protocol.git
git clone --depth 1 https://github.com/gitkb/meta_cli.git
git clone --depth 1 https://github.com/gitkb/meta_core.git
git clone --depth 1 https://github.com/gitkb/meta_git_lib.git
git clone --depth 1 https://github.com/gitkb/loop_lib.git
for repo in meta_plugin_protocol meta_cli meta_core meta_git_lib loop_lib; do
if git clone --depth 1 -b "$BRANCH" "https://github.com/gitkb/${repo}.git" 2>/dev/null; then
echo "Cloned ${repo}@${BRANCH}"
elif git clone --depth 1 "https://github.com/gitkb/${repo}.git"; then
echo "Branch ${BRANCH} not found for ${repo}; falling back to default branch"
else
echo "::error::Failed to clone ${repo}"
exit 1
fi
done

- name: Create workspace Cargo.toml
shell: bash
Expand Down Expand Up @@ -71,12 +78,19 @@ jobs:
path: meta_project_cli

- name: Clone dependencies
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
git clone --depth 1 https://github.com/gitkb/meta_plugin_protocol.git
git clone --depth 1 https://github.com/gitkb/meta_cli.git
git clone --depth 1 https://github.com/gitkb/meta_core.git
git clone --depth 1 https://github.com/gitkb/meta_git_lib.git
git clone --depth 1 https://github.com/gitkb/loop_lib.git
for repo in meta_plugin_protocol meta_cli meta_core meta_git_lib loop_lib; do
if git clone --depth 1 -b "$BRANCH" "https://github.com/gitkb/${repo}.git" 2>/dev/null; then
echo "Cloned ${repo}@${BRANCH}"
elif git clone --depth 1 "https://github.com/gitkb/${repo}.git"; then
echo "Branch ${BRANCH} not found for ${repo}; falling back to default branch"
else
echo "::error::Failed to clone ${repo}"
exit 1
fi
done

- name: Create workspace Cargo.toml
run: |
Expand Down Expand Up @@ -116,12 +130,19 @@ jobs:
path: meta_project_cli

- name: Clone dependencies
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
git clone --depth 1 https://github.com/gitkb/meta_plugin_protocol.git
git clone --depth 1 https://github.com/gitkb/meta_cli.git
git clone --depth 1 https://github.com/gitkb/meta_core.git
git clone --depth 1 https://github.com/gitkb/meta_git_lib.git
git clone --depth 1 https://github.com/gitkb/loop_lib.git
for repo in meta_plugin_protocol meta_cli meta_core meta_git_lib loop_lib; do
if git clone --depth 1 -b "$BRANCH" "https://github.com/gitkb/${repo}.git" 2>/dev/null; then
echo "Cloned ${repo}@${BRANCH}"
elif git clone --depth 1 "https://github.com/gitkb/${repo}.git"; then
echo "Branch ${BRANCH} not found for ${repo}; falling back to default branch"
else
echo "::error::Failed to clone ${repo}"
exit 1
fi
done

- name: Create workspace Cargo.toml
run: |
Expand Down
31 changes: 26 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ pub fn execute_command(
return project_command_help(command);
}

// meta_cli sends an unclaimed `project <word>` as `project` plus args
if command == "project" {
let typed: Vec<&str> = std::iter::once(command)
.chain(args.iter().map(String::as_str))
.collect();
return CommandResult::ShowHelp(Some(format!(
"unrecognized command '{}'. Use 'meta git update' to sync projects.",
typed.join(" ")
)));
}

// project dependents reads the dependency graph directly
if command == "project dependents" {
return handle_project_dependents(args, options, cwd);
Expand Down Expand Up @@ -139,10 +150,15 @@ pub fn execute_command(
}
}

/// A `--help`/`-h` before `--`; after it, they are arguments for the command.
fn has_help_token(command: &str, args: &[String]) -> bool {
command
.split_whitespace()
.chain(args.iter().map(String::as_str))
.chain(
args.iter()
.map(String::as_str)
.take_while(|arg| *arg != "--"),
)
.any(|arg| arg == "--help" || arg == "-h")
}

Expand Down Expand Up @@ -712,10 +728,13 @@ mod tests {
std::fs::write(temp_dir.path().join(".meta"), r#"{"projects": {}}"#).unwrap();

let options = ExecuteOptions::default();
let result = execute_command("project unknown", &[], &options, &[], temp_dir.path());
let args = ["unknown".to_string()];
let result = execute_command("project", &args, &options, &[], temp_dir.path());

match result {
CommandResult::ShowHelp(Some(msg)) => assert!(msg.contains("unrecognized command")),
CommandResult::ShowHelp(Some(msg)) => {
assert!(msg.contains("unrecognized command 'project unknown'"))
}
_ => panic!("Expected ShowHelp result"),
}
}
Expand Down Expand Up @@ -772,7 +791,9 @@ mod tests {
fn test_execution_plan_serialization() {
let commands = vec![PlannedCommand {
dir: ".".to_string(),
cmd: "git clone https://example.com/repo.git repo".to_string(),
argv: ["git", "clone", "https://example.com/repo.git", "repo"]
.map(str::to_string)
.to_vec(),
env: None,
}];
let plan = ExecutionPlan {
Expand All @@ -787,7 +808,7 @@ mod tests {
let json = serde_json::to_string(&response).unwrap();
assert!(json.contains("\"plan\""));
assert!(json.contains("\"commands\""));
assert!(json.contains("git clone"));
assert!(json.contains(r#""argv":["git","clone""#));
}

#[test]
Expand Down
Loading