pub struct Fetch {
pub clone_dir: PathBuf,
pub diff_dir: PathBuf,
pub git: PathBuf,
pub git_flags: Vec<String>,
pub aur_url: Url,
}
Expand description
Handle to the current configuration.
This handle is used to configure parts of the fetching process. All the features of this crate must be done through this handle.
Fields§
§clone_dir: PathBuf
The directory to place AUR packages in.
diff_dir: PathBuf
The directory to place diffs in.
git: PathBuf
The git command to run.
git_flags: Vec<String>
Flags passed to git.
aur_url: Url
The AUR URL.
Implementations§
Source§impl Fetch
impl Fetch
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new Handle with working defaults.
This Inializes the clone and diff dir to the current dirrectory. If you want to configure a cache directory you will need to do that yourself.
Sourcepub fn with_cache_dir<P: AsRef<Path>>(path: P) -> Self
pub fn with_cache_dir<P: AsRef<Path>>(path: P) -> Self
Create a new handle with a specified cache dir.
clone_dir will be a subdirectory named clone inside of the specified path. diff_dir will be a subdirectory named diff inside of the specified path.
Sourcepub fn with_combined_cache_dir<P: AsRef<Path>>(path: P) -> Self
pub fn with_combined_cache_dir<P: AsRef<Path>>(path: P) -> Self
Create a new handle with a specified cache dir.
Both diffs and cloned packages will be places in the provided dir.
Sourcepub fn download<S: AsRef<str> + Send + Sync>(
&self,
pkgs: &[S],
) -> Result<Vec<String>>
pub fn download<S: AsRef<str> + Send + Sync>( &self, pkgs: &[S], ) -> Result<Vec<String>>
Downloads a list of packages to the cache dir.
This downloads packages from the AUR using git. New packages will be cloned, while packages that already exist in cache will be fetched. Merging will need to be done in a separate step.
Each package is downloaded concurrently which givess a major speedup
Depending on how many packages are being downloaded and connection speed this
function may take a little while to complete. See download_cb
if
you wish track the progress of each download.
This also filters the input list to packages that were already in cache. This filtered list
can then be passed on to merge
as freshly cloned packages will
not need to be merged.
Sourcepub fn download_cb<S: AsRef<str> + Send + Sync, F: Fn(Callback<'_>)>(
&self,
pkgs: &[S],
f: F,
) -> Result<Vec<String>>
pub fn download_cb<S: AsRef<str> + Send + Sync, F: Fn(Callback<'_>)>( &self, pkgs: &[S], f: F, ) -> Result<Vec<String>>
The same as download
but calls a Callback after each download.
The callback is called each time a package download is completed.
Sourcepub fn download_repos<F: Fn(Callback<'_>)>(
&self,
repos: &[Repo],
) -> Result<Vec<String>>
pub fn download_repos<F: Fn(Callback<'_>)>( &self, repos: &[Repo], ) -> Result<Vec<String>>
The same as download
but downloads a specified list of repos instead of AUR packages.
Sourcepub fn download_repos_cb<F: Fn(Callback<'_>)>(
&self,
repos: &[Repo],
f: F,
) -> Result<Vec<String>>
pub fn download_repos_cb<F: Fn(Callback<'_>)>( &self, repos: &[Repo], f: F, ) -> Result<Vec<String>>
The same as download_repos
but calls a Callback after each download.
The callback is called each time a package download is completed.
Sourcepub fn has_diff<'a, S: AsRef<str>>(&self, pkgs: &'a [S]) -> Result<Vec<&'a str>>
pub fn has_diff<'a, S: AsRef<str>>(&self, pkgs: &'a [S]) -> Result<Vec<&'a str>>
Filters a list of packages, keep ones that have a diff.
A reoo has a diff if AUR_SEEN is defined and is different to the upstram HEAD.
Sourcepub fn unseen<'a, S: AsRef<str>>(&self, pkgs: &'a [S]) -> Result<Vec<&'a str>>
pub fn unseen<'a, S: AsRef<str>>(&self, pkgs: &'a [S]) -> Result<Vec<&'a str>>
Filterrs a list of packages, keeping ones that have not yet been seen.
A repo is seen if AUR_SEEN exists and is equal to the upstram HEAD.
Sourcepub fn diff<S: AsRef<str>>(
&self,
pkgs: &[S],
color: bool,
) -> Result<Vec<String>>
pub fn diff<S: AsRef<str>>( &self, pkgs: &[S], color: bool, ) -> Result<Vec<String>>
Diff a list of packages returning the diffs as strings.
Diffing a package that is already up to date will generate a diff against an empty git tree
Additionally this function gives you the ability to force color. This is useful if you intend to print the diffs to stdout.
Sourcepub fn print_diff<S: AsRef<str>>(&self, pkg: S) -> Result<()>
pub fn print_diff<S: AsRef<str>>(&self, pkg: S) -> Result<()>
Diff a single package.
Relies on git diff
for printing. This means output will likley be coloured and ran through less.
Although this is dependent on the user’s git config
Sourcepub fn save_diffs<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>
pub fn save_diffs<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>
Diff a list of packages and save them to diff_dir.
Diffing a package that is already up to date will generate a diff against an empty git tree
Sourcepub fn make_view<P: AsRef<Path>, S1: AsRef<str>, S2: AsRef<str>>(
&self,
dir: P,
pkgs: &[S1],
diffs: &[S2],
) -> Result<()>
pub fn make_view<P: AsRef<Path>, S1: AsRef<str>, S2: AsRef<str>>( &self, dir: P, pkgs: &[S1], diffs: &[S2], ) -> Result<()>
Makes a view of newly downloaded files.
This view is a dir containing the packages downloaded/fetched and diffs for packages that have diffs.
Files are symlinked from the cache dirs so there is no duplication of files.
Sourcepub fn merge<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>
pub fn merge<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>
Merge a list of packages with their upstream.
Sourcepub fn merge_cb<S: AsRef<str>, F: Fn(Callback<'_>)>(
&self,
pkgs: &[S],
cb: F,
) -> Result<()>
pub fn merge_cb<S: AsRef<str>, F: Fn(Callback<'_>)>( &self, pkgs: &[S], cb: F, ) -> Result<()>
Merge a list of packages with their upstream, calling callback for each merge.
Sourcepub fn mark_seen<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>
pub fn mark_seen<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>
Marks a list of repos as seen.
This updates AUR_SEEN to the upstream HEAD
Sourcepub fn commit<S1: AsRef<str>, S2: AsRef<str>>(
&self,
pkgs: &[S1],
message: S2,
) -> Result<()>
pub fn commit<S1: AsRef<str>, S2: AsRef<str>>( &self, pkgs: &[S1], message: S2, ) -> Result<()>
Commits changes to list of packages
This is intended to allow saving changes made by the user after reviewing.
Sourcepub fn is_git_repo<S: AsRef<str>>(&self, pkg: S) -> bool
pub fn is_git_repo<S: AsRef<str>>(&self, pkg: S) -> bool
Check if a package is already cloned.