#file-path #detect #service #git #hosting #remote #url

detect_git_service

Detect Git hosting service from file path

1 stable release

1.0.0 Feb 6, 2019

#14 in #hosting

23 downloads per month

MIT license

18KB
425 lines

detect_git_service crate

crates.io documentation CI on Linux and macOS CI on Windows

detect_git_service is a small crate to detect the Git hosting service from a path.

The service is detected based on a URL of remote repository of the path.

extern crate detect_git_service;

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());
}

Please read the documentation for more details.

Installation

Add detect_git_service to your crate's dependencies.

"detect_git_service" = "1"

License

Distributed under the MIT License.

Dependencies

~3.5MB
~108K SLoC