A tool to help managing forked repos with their own history
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a --depth option to the init command

webbeef 0419ba9c def01543

+21 -6
+2 -2
src/commands/init.rs
··· 7 7 use crate::git::{self, SOURCE_DIR}; 8 8 use crate::patch; 9 9 10 - pub fn run(url: Option<String>, branch: &str) -> Result<()> { 10 + pub fn run(url: Option<String>, branch: &str, depth: Option<usize>) -> Result<()> { 11 11 // Determine the URL - either from argument or existing config 12 12 let url = match url { 13 13 Some(u) => u, ··· 42 42 println!("Created forkme.toml"); 43 43 44 44 // Clone the repository 45 - let repo = git::clone_repo(&url, &branch)?; 45 + let repo = git::clone_repo(&url, &branch, depth)?; 46 46 47 47 // Create the forkme branch 48 48 git::create_forkme_branch(&repo, &branch)?;
+13 -2
src/git.rs
··· 5 5 pub const SOURCE_DIR: &str = "source"; 6 6 pub const FORKME_BRANCH: &str = "forkme"; 7 7 8 - pub fn clone_repo(url: &str, branch: &str) -> Result<Repository> { 9 - println!("Cloning {} (branch: {})...", url, branch); 8 + pub fn clone_repo(url: &str, branch: &str, depth: Option<usize>) -> Result<Repository> { 9 + let depth_msg = match depth { 10 + Some(d) => format!(" with depth {}", d), 11 + None => String::new(), 12 + }; 13 + println!("Cloning {} (branch: {}){}...", url, branch, depth_msg); 10 14 11 15 let mut builder = git2::build::RepoBuilder::new(); 12 16 builder.branch(branch); 17 + 18 + // Set fetch depth if provided 19 + if let Some(d) = depth { 20 + let mut fetch_options = git2::FetchOptions::new(); 21 + fetch_options.depth(d as i32); 22 + builder.fetch_options(fetch_options); 23 + } 13 24 14 25 let repo = builder 15 26 .clone(url, Path::new(SOURCE_DIR))
+6 -2
src/main.rs
··· 23 23 #[arg(long)] 24 24 url: Option<String>, 25 25 26 - /// Branch to track from upstream 26 + /// Branch to track from upstream (default to main) 27 27 #[arg(long, default_value = "main")] 28 28 branch: String, 29 + 30 + /// Limit the git cloning depth (optional) 31 + #[arg(long)] 32 + depth: Option<usize>, 29 33 }, 30 34 31 35 /// Apply patches to the source directory ··· 48 52 let cli = Cli::parse(); 49 53 50 54 match cli.command { 51 - Commands::Init { url, branch } => commands::init::run(url, &branch)?, 55 + Commands::Init { url, branch, depth } => commands::init::run(url, &branch, depth)?, 52 56 Commands::Apply => commands::apply::run()?, 53 57 Commands::Sync => commands::sync::run()?, 54 58 Commands::Status => commands::status::run()?,