diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-16 00:59:54 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-16 01:03:45 +0900 |
| commit | 3a388b98a9aa6a14b1c7f7dc909c109cf9837800 (patch) | |
| tree | 593e342313c6e6bd3ec2943a1690b8798e0a83ae /crates/shirabe/src/repository/vcs | |
| parent | aad468e8b75ffc3e87ea6dfa22c53a8299fc08da (diff) | |
| download | php-shirabe-3a388b98a9aa6a14b1c7f7dc909c109cf9837800.tar.gz php-shirabe-3a388b98a9aa6a14b1c7f7dc909c109cf9837800.tar.zst php-shirabe-3a388b98a9aa6a14b1c7f7dc909c109cf9837800.zip | |
refactor: narrow pub(crate) items to private
Porting mapped every PHP `protected` member onto `pub(crate)`, which is
wider than nearly all of them need. Each item demoted here is reached
only from the module that defines it, so the crate-wide visibility
conveyed nothing.
Every `pub(crate)` that survives has at least one reader in another
module of the same crate.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/forgejo_driver.rs | 14 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/fossil_driver.rs | 16 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs | 8 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/github_driver.rs | 34 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/gitlab_driver.rs | 25 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/hg_driver.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/perforce_driver.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/svn_driver.rs | 28 |
8 files changed, 69 insertions, 72 deletions
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs index 54f5dddd..7687db0d 100644 --- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs +++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs @@ -23,12 +23,12 @@ use shirabe_php_shim::{ #[derive(Debug)] pub struct ForgejoDriver { - pub(crate) inner: VcsDriverBase, - pub(crate) forgejo_url: Option<ForgejoUrl>, - pub(crate) repository_data: Option<ForgejoRepositoryData>, - pub(crate) git_driver: Option<GitDriver>, - pub(crate) tags: Option<IndexMap<String, String>>, - pub(crate) branches: Option<IndexMap<String, String>>, + inner: VcsDriverBase, + forgejo_url: Option<ForgejoUrl>, + repository_data: Option<ForgejoRepositoryData>, + git_driver: Option<GitDriver>, + tags: Option<IndexMap<String, String>>, + branches: Option<IndexMap<String, String>>, } impl ForgejoDriver { @@ -595,7 +595,7 @@ impl ForgejoDriver { None } - pub(crate) fn get_contents( + fn get_contents( &mut self, url: &str, fetching_repo_data: bool, diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs index 9a0c4b2e..8ce479fd 100644 --- a/crates/shirabe/src/repository/vcs/fossil_driver.rs +++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs @@ -19,12 +19,12 @@ use shirabe_php_shim::{ #[derive(Debug)] pub struct FossilDriver { - pub(crate) inner: VcsDriverBase, - pub(crate) tags: Option<IndexMap<String, String>>, - pub(crate) branches: Option<IndexMap<String, String>>, - pub(crate) root_identifier: Option<String>, - pub(crate) repo_file: Option<String>, - pub(crate) checkout_dir: String, + inner: VcsDriverBase, + tags: Option<IndexMap<String, String>>, + branches: Option<IndexMap<String, String>>, + root_identifier: Option<String>, + repo_file: Option<String>, + checkout_dir: String, } impl FossilDriver { @@ -95,7 +95,7 @@ impl FossilDriver { Ok(()) } - pub(crate) fn check_fossil(&self) -> anyhow::Result<()> { + fn check_fossil(&self) -> anyhow::Result<()> { let mut ignored_output = String::new(); if self.inner.process.borrow_mut().execute_args( ["fossil", "version"].map(|s| s.to_string()).as_ref(), @@ -112,7 +112,7 @@ impl FossilDriver { Ok(()) } - pub(crate) fn update_local_repo(&mut self) -> anyhow::Result<()> { + fn update_local_repo(&mut self) -> anyhow::Result<()> { assert!(self.repo_file.is_some()); let mut fs = Filesystem::new(None); diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index c3da08ff..9558e3b2 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -24,11 +24,11 @@ use shirabe_php_shim::{ #[derive(Debug)] pub struct GitBitbucketDriver { - pub(crate) inner: VcsDriverBase, + inner: VcsDriverBase, /// @var string - pub(crate) owner: String, + owner: String, /// @var string - pub(crate) repository: String, + repository: String, /// @var bool has_issues: bool, /// @var ?string @@ -50,7 +50,7 @@ pub struct GitBitbucketDriver { /// @var array<string, mixed> repo_data: IndexMap<String, PhpMixed>, /// @var ?VcsDriver - pub(crate) fallback_driver: Option<Box<dyn VcsDriverInterface>>, + fallback_driver: Option<Box<dyn VcsDriverInterface>>, /// @var string|null if set either git or hg vcs_type: Option<String>, } diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index 9dbb8513..56ff3853 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -24,24 +24,24 @@ use shirabe_php_shim::{ #[derive(Debug)] pub struct GitHubDriver { - pub(crate) inner: VcsDriverBase, - pub(crate) owner: String, - pub(crate) repository: String, + inner: VcsDriverBase, + owner: String, + repository: String, /// @var array<int|string, string> Map of tag name to identifier - pub(crate) tags: Option<IndexMap<String, String>>, + tags: Option<IndexMap<String, String>>, /// @var array<int|string, string> Map of branch name to identifier - pub(crate) branches: Option<IndexMap<String, String>>, - pub(crate) root_identifier: String, + branches: Option<IndexMap<String, String>>, + root_identifier: String, /// @var mixed[] - pub(crate) repo_data: Option<IndexMap<String, PhpMixed>>, - pub(crate) has_issues: bool, - pub(crate) is_private: bool, + repo_data: Option<IndexMap<String, PhpMixed>>, + has_issues: bool, + is_private: bool, is_archived: bool, /// @var array<int, array{type: string, url: string}>|false|null funding_info: Option<PhpMixed>, allow_git_fallback: bool, /// Git Driver - pub(crate) git_driver: Option<GitDriver>, + git_driver: Option<GitDriver>, } impl GitHubDriver { @@ -194,7 +194,7 @@ impl GitHubDriver { ) } - pub(crate) fn get_api_url(&self) -> String { + fn get_api_url(&self) -> String { let api_url = if self.inner.origin_url == "github.com" { "api.github.com".to_string() } else { @@ -995,7 +995,7 @@ impl GitHubDriver { } /// Generate an SSH URL - pub(crate) fn generate_ssh_url(&self) -> String { + fn generate_ssh_url(&self) -> String { if strpos(&self.inner.origin_url, ":").is_some() { return format!( "ssh://git@{}/{}/{}.git", @@ -1009,7 +1009,7 @@ impl GitHubDriver { ) } - pub(crate) fn get_contents( + fn get_contents( &mut self, url: &str, fetching_repo_data: bool, @@ -1154,7 +1154,7 @@ impl GitHubDriver { /// Fetch root identifier from GitHub /// /// @throws TransportException - pub(crate) fn fetch_root_identifier(&mut self) -> anyhow::Result<()> { + fn fetch_root_identifier(&mut self) -> anyhow::Result<()> { if self.repo_data.is_some() { return Ok(()); } @@ -1225,7 +1225,7 @@ impl GitHubDriver { /// @phpstan-impure /// /// @throws \RuntimeException - pub(crate) fn attempt_clone_fallback( + fn attempt_clone_fallback( &mut self, e: Option<std::sync::Arc<anyhow::Error>>, ) -> anyhow::Result<bool> { @@ -1263,7 +1263,7 @@ impl GitHubDriver { } } - pub(crate) fn setup_git_driver(&mut self, url: &str) -> anyhow::Result<()> { + fn setup_git_driver(&mut self, url: &str) -> anyhow::Result<()> { if !self.allow_git_fallback { return Err( RuntimeException::new("Fallback to git driver disabled".to_string()).into(), @@ -1283,7 +1283,7 @@ impl GitHubDriver { Ok(()) } - pub(crate) fn get_next_page(&self, response: &Response) -> Option<String> { + fn get_next_page(&self, response: &Response) -> Option<String> { let header = response.get_header("link")?; if header.is_empty() { return None; diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index 669f1376..df1ad686 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -26,7 +26,7 @@ use shirabe_php_shim::{ /// Driver for GitLab API, use the Git driver for local checkouts. #[derive(Debug)] pub struct GitLabDriver { - pub(crate) inner: VcsDriverBase, + inner: VcsDriverBase, /// @phpstan-var 'https'|'http' scheme: String, namespace: String, @@ -40,10 +40,10 @@ pub struct GitLabDriver { /// @var array<int|string, string> Map of branch name to identifier branches: Option<IndexMap<String, String>>, /// Git Driver - pub(crate) git_driver: Option<GitDriver>, + git_driver: Option<GitDriver>, /// Protocol to force use of for repository URLs. /// @var string One of ssh, http - pub(crate) protocol: String, + protocol: String, /// Defaults to true unless we can make sure it is public /// @var bool defines whether the repo is private or not is_private: bool, @@ -595,10 +595,7 @@ impl GitLabDriver { } /// @return string[] where keys are named references like tags or branches and the value a sha - pub(crate) fn get_references( - &mut self, - r#type: &str, - ) -> anyhow::Result<IndexMap<String, String>> { + fn get_references(&mut self, r#type: &str) -> anyhow::Result<IndexMap<String, String>> { let per_page = 100; let mut resource: Option<String> = Some(format!( "{}/repository/{}?per_page={}", @@ -661,7 +658,7 @@ impl GitLabDriver { Ok(references) } - pub(crate) fn fetch_project(&mut self) -> anyhow::Result<()> { + fn fetch_project(&mut self) -> anyhow::Result<()> { if self.project.is_some() { return Ok(()); } @@ -694,7 +691,7 @@ impl GitLabDriver { /// @phpstan-impure /// /// @throws \RuntimeException - pub(crate) fn attempt_clone_fallback(&mut self) -> anyhow::Result<bool> { + fn attempt_clone_fallback(&mut self) -> anyhow::Result<bool> { let url = if !self.is_private { self.generate_public_url() } else { @@ -723,7 +720,7 @@ impl GitLabDriver { } /// Generate an SSH URL - pub(crate) fn generate_ssh_url(&self) -> String { + fn generate_ssh_url(&self) -> String { if self.has_nonstandard_origin { return format!( "ssh://git@{}/{}/{}.git", @@ -737,14 +734,14 @@ impl GitLabDriver { ) } - pub(crate) fn generate_public_url(&self) -> String { + fn generate_public_url(&self) -> String { format!( "{}://{}/{}/{}.git", self.scheme, self.inner.origin_url, self.namespace, self.repository ) } - pub(crate) fn setup_git_driver(&mut self, url: &str) -> anyhow::Result<()> { + fn setup_git_driver(&mut self, url: &str) -> anyhow::Result<()> { let mut repo_config: IndexMap<String, PhpMixed> = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(url.to_string())); let mut git_driver = GitDriver::new( @@ -759,7 +756,7 @@ impl GitLabDriver { Ok(()) } - pub(crate) fn get_contents( + fn get_contents( &mut self, url: &str, fetching_repo_data: bool, @@ -1009,7 +1006,7 @@ impl GitLabDriver { Ok(self.project.clone()) } - pub(crate) fn get_next_page(&self, response: &Response) -> Option<String> { + fn get_next_page(&self, response: &Response) -> Option<String> { let header = response.get_header("link").unwrap_or_default(); let links = explode(",", &header); diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs index 56efd514..f4e02685 100644 --- a/crates/shirabe/src/repository/vcs/hg_driver.rs +++ b/crates/shirabe/src/repository/vcs/hg_driver.rs @@ -17,11 +17,11 @@ use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_writable, #[derive(Debug)] pub struct HgDriver { - pub(crate) inner: VcsDriverBase, - pub(crate) tags: Option<IndexMap<String, String>>, - pub(crate) branches: Option<IndexMap<String, String>>, - pub(crate) root_identifier: Option<String>, - pub(crate) repo_dir: String, + inner: VcsDriverBase, + tags: Option<IndexMap<String, String>>, + branches: Option<IndexMap<String, String>>, + root_identifier: Option<String>, + repo_dir: String, } impl HgDriver { diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs index 7425c7d4..ce9ffb49 100644 --- a/crates/shirabe/src/repository/vcs/perforce_driver.rs +++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs @@ -15,9 +15,9 @@ use shirabe_php_shim::{BadMethodCallException, PhpMixed, RuntimeException, php_r #[derive(Debug)] pub struct PerforceDriver { inner: VcsDriverBase, - pub(crate) depot: String, - pub(crate) branch: String, - pub(crate) perforce: Option<Box<dyn PerforceInterface>>, + depot: String, + branch: String, + perforce: Option<Box<dyn PerforceInterface>>, } impl PerforceDriver { diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index 6d767af5..dd74400d 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -21,25 +21,25 @@ use shirabe_php_shim::{ #[derive(Debug)] pub struct SvnDriver { - pub(crate) inner: VcsDriverBase, + inner: VcsDriverBase, /// @var string - pub(crate) base_url: String, + base_url: String, /// @var array<int|string, string> Map of tag name to identifier - pub(crate) tags: Option<IndexMap<String, String>>, + tags: Option<IndexMap<String, String>>, /// @var array<int|string, string> Map of branch name to identifier - pub(crate) branches: Option<IndexMap<String, String>>, + branches: Option<IndexMap<String, String>>, /// @var ?string - pub(crate) root_identifier: Option<String>, + root_identifier: Option<String>, - pub(crate) trunk_path: Option<String>, + trunk_path: Option<String>, /// @var string - pub(crate) branches_path: String, + branches_path: String, /// @var string - pub(crate) tags_path: String, + tags_path: String, /// @var string - pub(crate) package_path: String, + package_path: String, /// @var bool - pub(crate) cache_credentials: bool, + cache_credentials: bool, /// @var SvnUtil util: Option<SvnUtil>, @@ -152,7 +152,7 @@ impl SvnDriver { None } - pub(crate) fn should_cache(&self, identifier: &str) -> bool { + fn should_cache(&self, identifier: &str) -> bool { self.inner.cache.is_some() && Preg::is_match(php_regex!(r"{@\d+$}"), identifier) } @@ -530,7 +530,7 @@ impl SvnDriver { } /// An absolute path (leading '/') is converted to a file:// url. - pub(crate) fn normalize_url(url: &str) -> String { + fn normalize_url(url: &str) -> String { let fs = Filesystem::new(None); if fs.is_absolute_path(url) { return format!("file://{}", strtr(url, "\\", "/")); @@ -545,7 +545,7 @@ impl SvnDriver { /// @param non-empty-list<string> $command The svn command to run. /// @param string $url The SVN URL. /// @throws \RuntimeException - pub(crate) fn execute(&mut self, command: Vec<String>, url: &str) -> anyhow::Result<String> { + fn execute(&mut self, command: Vec<String>, url: &str) -> anyhow::Result<String> { if self.util.is_none() { self.util = Some(SvnUtil::new( self.base_url.clone(), @@ -589,7 +589,7 @@ impl SvnDriver { /// /// @param string $baseDir The path to trunk/branch/tag /// @param int $revision The revision mark to add to identifier - pub(crate) fn build_identifier(&self, base_dir: &str, revision: i64) -> String { + fn build_identifier(&self, base_dir: &str, revision: i64) -> String { format!( "{}{}/@{}", base_dir.trim_end_matches('/'), |
