Expand description
Detect Git hosting service from file path
This library provides APIs to detect Git hosting service used for given file path. Service is detected based on a URL of remote repository of the path.
use std::path::Path;
use detect_git_service::GitService;
let path = Path::new(".");
let service = detect_git_service::detect(&path).unwrap();
assert_eq!(service.user(), "rhysd");
assert_eq!(service.repo(), "detect_git_service");
assert!(service.branch().is_some());
if let GitService::GitHub{user, repo, branch} = service {
assert_eq!(user, "rhysd");
assert_eq!(repo, "detect_git_service");
assert!(branch.is_some());
}
Enums§
- Error caused by APIs in detect_git_service crate.
- Enum variants of Git hosting services which this library supports.
Functions§
- Detect Git hosting service from a file path. Path can be both file path and directory path. It returns an error when input was invalid or no service was detected.
- Almost the same as
detect
, but with explicitly specifying Git command.