Skip to content
Closed
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
53 changes: 0 additions & 53 deletions dsdk-cli/src/git_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::config::GitConfig;
use crate::git_operations;
use crate::messages;
use anyhow::Result;
Expand Down Expand Up @@ -100,55 +99,3 @@ pub fn get_mirror_repo_path(mirror_path: &Path, name: &str, url: &str) -> PathBu
let org_repo = git_operations::extract_org_and_repo(url);
mirror_path.join(format!("{}-{}", org_repo, hash))
}

/// Updates a git repository by cloning or fetching from the configured URL.
///
/// # Errors
///
/// Returns an error if:
/// - The repository cannot be cloned or opened
/// - Network operations fail
/// - Git operations such as fetch or checkout fail
pub fn update_git(config: &GitConfig, mirror_path: &Path) -> Result<()> {
let repo_path = get_mirror_repo_path(mirror_path, &config.name, &config.url);

if repo_path.exists() {
messages::status(&format!("Fetching {}...", config.name));

let fetch_result = git_operations::fetch_all(&repo_path)?;

if !fetch_result.is_success() {
messages::error(&format!(
"Failed to fetch {}: {}",
config.name, fetch_result.stderr
));
return Err(anyhow::anyhow!("Git fetch failed"));
}
} else {
messages::status(&format!("Cloning {}...", config.name));

let clone_result = git_operations::clone_repo(&config.url, &repo_path, None)?;

if !clone_result.is_success() {
messages::error(&format!(
"Failed to clone {}: {}",
config.name, clone_result.stderr
));
return Err(anyhow::anyhow!("Git clone failed"));
}
}

messages::status(&format!("Checking out commit/tag: {}", config.commit));

let checkout_result = git_operations::checkout(&repo_path, &config.commit)?;

if !checkout_result.is_success() {
return Err(anyhow::anyhow!(
"Failed to checkout {}: {}",
config.commit,
checkout_result.stderr
));
}

Ok(())
}
Loading