-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from keirlawson/repo-forking
Add method for forking repos
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::env; | ||
|
||
use tokio::runtime::Runtime; | ||
|
||
use hubcaps::{Credentials, Github, Result}; | ||
|
||
fn main() -> Result<()> { | ||
pretty_env_logger::init(); | ||
match env::var("GITHUB_TOKEN").ok() { | ||
Some(token) => { | ||
let mut rt = Runtime::new()?; | ||
let github = Github::new( | ||
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")), | ||
Credentials::Token(token), | ||
)?; | ||
|
||
let repo = github.repo("softprops", "hubcaps"); | ||
|
||
let forked = rt.block_on(repo.fork())?; | ||
|
||
println!("Forked repository to {}", forked.full_name); | ||
|
||
Ok(()) | ||
} | ||
_ => Err("example missing GITHUB_TOKEN".into()), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters