Skip to content
Open
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
8 changes: 8 additions & 0 deletions forc/src/cli/commands/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ pub struct Command {

/// The name of the project that will be created
pub project_name: String,

/// A git tag to use for the template, e.g. `v0.1.0`.
#[clap(long)]
pub tag: Option<String>,

/// A specific git revision (commit hash) to use for the template.
#[clap(long)]
pub rev: Option<String>,
}

pub(crate) fn exec(command: Command) -> ForcResult<()> {
Expand Down
9 changes: 8 additions & 1 deletion forc/src/ops/forc_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ pub fn init(command: TemplateCommand) -> Result<()> {
.clone()
.unwrap_or_else(|| format!("{}-template-source", command.project_name));

let reference = if let Some(rev) = &command.rev {
source::git::Reference::Rev(rev.clone())
} else if let Some(tag) = &command.tag {
source::git::Reference::Tag(tag.clone())
} else {
source::git::Reference::DefaultBranch
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silently ignores --tag when --rev also provided

Low Severity

The --tag and --rev CLI options lack a conflicts_with declaration, so both can be specified simultaneously. When a user provides both, --rev silently takes priority and --tag is ignored without warning. The codebase already uses conflicts_with for mutually exclusive options (e.g., in shared.rs). Users providing both flags likely have a misconfigured command and deserve a clear error rather than silent precedence.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 57c03a8. Configure here.

let source = source::git::Source {
repo: Url::from_str(&command.url)?,
reference: source::git::Reference::DefaultBranch,
reference,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misleading "HEAD" log message for tag/rev references

Low Severity

The println_action_green("Resolving", &format!("the HEAD of {}", source.repo)) message is now incorrect when --tag or --rev is specified. Previously, the reference was always DefaultBranch so "the HEAD" was accurate. With the new code paths, when a user passes --rev or --tag, the message still claims to resolve "the HEAD" when it's actually resolving a specific tag or commit hash. This gives users confusing feedback about what operation is being performed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 57c03a8. Configure here.

};

let current_dir = &env::current_dir()?;
Expand Down