Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Branch Selection for coffee_install() #242

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions coffee_github/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use coffee_storage::model::repository::Kind;
use coffee_storage::model::repository::Repository as StorageRepository;

use crate::utils::clone_recursive_fix;
use crate::utils::git_upgrade;
use crate::utils::git_upgrade_with_branch;

pub struct Github {
/// the url of the repository to be able
Expand Down Expand Up @@ -259,7 +259,7 @@ impl Repository for Github {
}
}
// pull the changes from the repository
let status = git_upgrade(&self.url.path_string, &self.branch, verbose).await?;
let status = git_upgrade_with_branch(&self.url.path_string, &self.branch, verbose).await?;
self.git_head = Some(status.commit_id());
self.last_activity = Some(status.date());
Ok(CoffeeUpgrade {
Expand Down Expand Up @@ -336,6 +336,11 @@ impl Repository for Github {
None
}

/// return the git head of the repository.
fn git_head(&self) -> Option<String> {
self.git_head.clone()
}
Comment on lines +339 to +342
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this as a struct method and not an a trait implementation


fn as_any(&self) -> &dyn Any {
self
}
Expand Down
3 changes: 3 additions & 0 deletions coffee_lib/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ pub trait Repository: Any {
/// return the url of the repository.
fn url(&self) -> URL;

/// return the git head of the repository.
fn git_head(&self) -> Option<String>;

Comment on lines +43 to +45
Copy link
Contributor

Choose a reason for hiding this comment

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

does not make sense to have this inside the repository trait

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point. I will update it

fn as_any(&self) -> &dyn Any;
}