aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-28 17:45:06 +0900
committernsfisis <nsfisis@gmail.com>2026-06-28 17:45:26 +0900
commit53f1fb395f33e0fb8db9aebd09ea9082f650f9f1 (patch)
treef9e8bf0e9d4b1e98cce383574fb6a13b684fff08 /crates/shirabe/src/repository/vcs
parent212f5cd75b1403ee75ffa44d7ebdb181174340c0 (diff)
downloadphp-shirabe-53f1fb395f33e0fb8db9aebd09ea9082f650f9f1.tar.gz
php-shirabe-53f1fb395f33e0fb8db9aebd09ea9082f650f9f1.tar.zst
php-shirabe-53f1fb395f33e0fb8db9aebd09ea9082f650f9f1.zip
refactor: add linter
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs15
-rw-r--r--crates/shirabe/src/repository/vcs/fossil_driver.rs11
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs21
-rw-r--r--crates/shirabe/src/repository/vcs/git_driver.rs19
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs21
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs21
-rw-r--r--crates/shirabe/src/repository/vcs/mod.rs154
-rw-r--r--crates/shirabe/src/repository/vcs/perforce_driver.rs7
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs15
-rw-r--r--crates/shirabe/src/repository/vcs/vcs_driver.rs9
10 files changed, 65 insertions, 228 deletions
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 4d66f37..9557847 100644
--- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs
+++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
@@ -1,18 +1,11 @@
//! ref: composer/src/Composer/Repository/Vcs/ForgejoDriver.php
-use crate::io::io_interface;
-use anyhow::Result;
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{
- PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode,
-};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
+use crate::io::io_interface;
use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
@@ -21,6 +14,12 @@ use crate::util::Forgejo;
use crate::util::ForgejoRepositoryData;
use crate::util::ForgejoUrl;
use crate::util::http::Response;
+use anyhow::Result;
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
+use shirabe_php_shim::{
+ PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode,
+};
#[derive(Debug)]
pub struct ForgejoDriver {
diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs
index be3beff..840a2ae 100644
--- a/crates/shirabe/src/repository/vcs/fossil_driver.rs
+++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs
@@ -1,19 +1,18 @@
//! ref: composer/src/Composer/Repository/Vcs/FossilDriver.php
-use crate::io::io_interface;
-use chrono::{DateTime, FixedOffset, Utc};
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::Preg;
-use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
+use crate::io::io_interface;
use crate::repository::vcs::VcsDriverBase;
use crate::util::Filesystem;
use crate::util::ProcessExecutor;
+use chrono::{DateTime, FixedOffset, Utc};
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::Preg;
+use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable};
#[derive(Debug)]
pub struct FossilDriver {
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index 7a570bc..f28a005 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -1,21 +1,11 @@
//! ref: composer/src/Composer/Repository/Vcs/GitBitbucketDriver.php
-use crate::io::io_interface;
-use anyhow::Result;
-use chrono::{DateTime, FixedOffset};
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{
- InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
- array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array, is_array,
- strpos,
-};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
+use crate::io::io_interface;
use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
@@ -23,6 +13,15 @@ use crate::repository::vcs::VcsDriverBase;
use crate::repository::vcs::VcsDriverInterface;
use crate::util::Bitbucket;
use crate::util::http::Response;
+use anyhow::Result;
+use chrono::{DateTime, FixedOffset};
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
+use shirabe_php_shim::{
+ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
+ array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array, is_array,
+ strpos,
+};
#[derive(Debug)]
pub struct GitBitbucketDriver {
diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs
index cd08117..1455383 100644
--- a/crates/shirabe/src/repository/vcs/git_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_driver.rs
@@ -1,26 +1,25 @@
//! ref: composer/src/Composer/Repository/Vcs/GitDriver.php
-use crate::io::io_interface;
-use chrono::TimeZone;
-use chrono::{DateTime, FixedOffset, Utc};
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{
- InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath,
- sys_get_temp_dir,
-};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
+use crate::io::io_interface;
use crate::repository::vcs::VcsDriverBase;
use crate::util::Filesystem;
use crate::util::Git as GitUtil;
use crate::util::ProcessExecutor;
use crate::util::Url;
+use chrono::TimeZone;
+use chrono::{DateTime, FixedOffset, Utc};
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::PhpMixed;
+use shirabe_php_shim::{
+ InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath,
+ sys_get_temp_dir,
+};
#[derive(Debug)]
pub struct GitDriver {
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index e45096d..e8e67ea 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -1,27 +1,26 @@
//! ref: composer/src/Composer/Repository/Vcs/GitHubDriver.php
-use crate::io::io_interface;
-use anyhow::Result;
-use chrono::{DateTime, FixedOffset};
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{
- InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_key_exists, array_map,
- array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array,
- parse_url_all, strpos, strtolower, substr, trim, urlencode,
-};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
+use crate::io::io_interface;
use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
use crate::repository::vcs::VcsDriverBase;
use crate::util::GitHub;
use crate::util::http::Response;
+use anyhow::Result;
+use chrono::{DateTime, FixedOffset};
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
+use shirabe_php_shim::{
+ InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_key_exists, array_map,
+ array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array,
+ parse_url_all, strpos, strtolower, substr, trim, urlencode,
+};
#[derive(Debug)]
pub struct GitHubDriver {
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
index a9a2fdb..136d0d6 100644
--- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs
+++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
@@ -1,21 +1,11 @@
//! ref: composer/src/Composer/Repository/Vcs/GitLabDriver.php
-use crate::io::io_interface;
-use anyhow::Result;
-use chrono::{DateTime, FixedOffset};
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{
- InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed,
- array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array, is_array,
- is_string, ord, strpos, strtolower,
-};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
+use crate::io::io_interface;
use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
@@ -23,6 +13,15 @@ use crate::repository::vcs::VcsDriverBase;
use crate::util::GitLab;
use crate::util::HttpDownloader;
use crate::util::http::Response;
+use anyhow::Result;
+use chrono::{DateTime, FixedOffset};
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
+use shirabe_php_shim::{
+ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed,
+ array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array, is_array,
+ is_string, ord, strpos, strtolower,
+};
/// Driver for GitLab API, use the Git driver for local checkouts.
#[derive(Debug)]
diff --git a/crates/shirabe/src/repository/vcs/mod.rs b/crates/shirabe/src/repository/vcs/mod.rs
deleted file mode 100644
index 5c60e0a..0000000
--- a/crates/shirabe/src/repository/vcs/mod.rs
+++ /dev/null
@@ -1,154 +0,0 @@
-pub mod forgejo_driver;
-pub mod fossil_driver;
-pub mod git_bitbucket_driver;
-pub mod git_driver;
-pub mod github_driver;
-pub mod gitlab_driver;
-pub mod hg_driver;
-pub mod perforce_driver;
-pub mod svn_driver;
-pub mod vcs_driver;
-pub mod vcs_driver_interface;
-
-pub use forgejo_driver::*;
-pub use fossil_driver::*;
-pub use git_bitbucket_driver::*;
-pub use git_driver::*;
-pub use github_driver::*;
-pub use gitlab_driver::*;
-pub use hg_driver::*;
-pub use perforce_driver::*;
-pub use svn_driver::*;
-pub use vcs_driver::*;
-pub use vcs_driver_interface::*;
-
-use crate::config::Config;
-use crate::io::IOInterface;
-use crate::util::{HttpDownloader, ProcessExecutor};
-use indexmap::IndexMap;
-use shirabe_php_shim::PhpMixed;
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum VcsDriverKind {
- GitHub,
- GitLab,
- GitBitbucket,
- Forgejo,
- Git,
- Hg,
- Perforce,
- Fossil,
- Svn,
-}
-
-impl VcsDriverKind {
- pub fn instantiate(
- self,
- repo_config: IndexMap<String, PhpMixed>,
- io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
- config: std::rc::Rc<std::cell::RefCell<Config>>,
- http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>,
- process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>,
- ) -> Box<dyn VcsDriverInterface> {
- match self {
- VcsDriverKind::GitHub => Box::new(GitHubDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- VcsDriverKind::GitLab => Box::new(GitLabDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- VcsDriverKind::GitBitbucket => Box::new(GitBitbucketDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- VcsDriverKind::Forgejo => Box::new(ForgejoDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- VcsDriverKind::Git => Box::new(GitDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- VcsDriverKind::Hg => Box::new(HgDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- VcsDriverKind::Perforce => Box::new(PerforceDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- VcsDriverKind::Fossil => Box::new(FossilDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- VcsDriverKind::Svn => Box::new(SvnDriver::new(
- repo_config,
- io,
- config,
- http_downloader,
- process,
- )),
- }
- }
-
- pub fn supports(
- self,
- io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
- config: std::rc::Rc<std::cell::RefCell<Config>>,
- url: &str,
- deep: bool,
- ) -> anyhow::Result<bool> {
- match self {
- VcsDriverKind::GitHub => GitHubDriver::supports(io, config, url, deep),
- VcsDriverKind::GitLab => GitLabDriver::supports(io, config, url, deep),
- VcsDriverKind::GitBitbucket => GitBitbucketDriver::supports(io, config, url, deep),
- VcsDriverKind::Forgejo => ForgejoDriver::supports(io, config, url, deep),
- VcsDriverKind::Git => GitDriver::supports(io, config, url, deep),
- VcsDriverKind::Hg => HgDriver::supports(io, config, url, deep),
- VcsDriverKind::Perforce => PerforceDriver::supports(io, config, url, deep),
- VcsDriverKind::Fossil => FossilDriver::supports(io, config, url, deep),
- VcsDriverKind::Svn => SvnDriver::supports(io, config, url, deep),
- }
- }
-
- /// PHP fully-qualified `class-string`, used as the fallback driver name in `getRepoName()`.
- pub fn php_class_name(self) -> &'static str {
- match self {
- VcsDriverKind::GitHub => "Composer\\Repository\\Vcs\\GitHubDriver",
- VcsDriverKind::GitLab => "Composer\\Repository\\Vcs\\GitLabDriver",
- VcsDriverKind::GitBitbucket => "Composer\\Repository\\Vcs\\GitBitbucketDriver",
- VcsDriverKind::Forgejo => "Composer\\Repository\\Vcs\\ForgejoDriver",
- VcsDriverKind::Git => "Composer\\Repository\\Vcs\\GitDriver",
- VcsDriverKind::Hg => "Composer\\Repository\\Vcs\\HgDriver",
- VcsDriverKind::Perforce => "Composer\\Repository\\Vcs\\PerforceDriver",
- VcsDriverKind::Fossil => "Composer\\Repository\\Vcs\\FossilDriver",
- VcsDriverKind::Svn => "Composer\\Repository\\Vcs\\SvnDriver",
- }
- }
-}
diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs
index cb280e5..55a8eae 100644
--- a/crates/shirabe/src/repository/vcs/perforce_driver.rs
+++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs
@@ -1,9 +1,5 @@
//! ref: composer/src/Composer/Repository/Vcs/PerforceDriver.php
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::Preg;
-use shirabe_php_shim::{BadMethodCallException, PhpMixed, RuntimeException};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::io::IOInterface;
@@ -12,6 +8,9 @@ use crate::util::Perforce;
use crate::util::PerforceInterface;
use crate::util::ProcessExecutor;
use crate::util::http::Response;
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::Preg;
+use shirabe_php_shim::{BadMethodCallException, PhpMixed, RuntimeException};
#[derive(Debug)]
pub struct PerforceDriver {
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index 087ed9d..cb4ff87 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -1,13 +1,5 @@
//! ref: composer/src/Composer/Repository/Vcs/SvnDriver.php
-use anyhow::Result;
-use chrono::{DateTime, FixedOffset, Utc};
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{
- PhpMixed, RuntimeException, array_key_exists, stripos, strrpos, strtr, substr, trim,
-};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::downloader::TransportException;
@@ -19,6 +11,13 @@ use crate::util::Filesystem;
use crate::util::ProcessExecutor;
use crate::util::Svn as SvnUtil;
use crate::util::Url;
+use anyhow::Result;
+use chrono::{DateTime, FixedOffset, Utc};
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
+use shirabe_php_shim::{
+ PhpMixed, RuntimeException, array_key_exists, stripos, strrpos, strtr, substr, trim,
+};
#[derive(Debug)]
pub struct SvnDriver {
diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs
index 5e0715c..1dce856 100644
--- a/crates/shirabe/src/repository/vcs/vcs_driver.rs
+++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs
@@ -1,10 +1,5 @@
//! ref: composer/src/Composer/Repository/Vcs/VcsDriver.php
-use chrono::{DateTime, FixedOffset};
-use indexmap::IndexMap;
-use shirabe_external_packages::composer::pcre::Preg;
-use shirabe_php_shim::{DATE_RFC3339, PhpMixed, extension_loaded};
-
use crate::cache::Cache;
use crate::config::Config;
use crate::downloader::TransportException;
@@ -15,6 +10,10 @@ use crate::repository::vcs::VcsDriverInterface;
use crate::util::HttpDownloader;
use crate::util::ProcessExecutor;
use crate::util::http::Response;
+use chrono::{DateTime, FixedOffset};
+use indexmap::IndexMap;
+use shirabe_external_packages::composer::pcre::Preg;
+use shirabe_php_shim::{DATE_RFC3339, PhpMixed, extension_loaded};
#[derive(Debug)]
pub struct VcsDriverBase {