Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: XAMPPRocky/octocrab
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6ac74b82155a8823e80a5558c72e6dddd84d4739
Choose a base ref
..
head repository: XAMPPRocky/octocrab
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3352dc07470891de65addf7642532943a2bddffb
Choose a head ref
Showing with 25 additions and 0 deletions.
  1. +1 −0 CHANGELOG.md
  2. +24 −0 examples/create_a_gist.rs
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.21.0](https://github.com/XAMPPRocky/octocrab/compare/v0.20.0...v0.21.0) - 2023-04-29

### Other
- Add an example showing gist creation (#329)
- Use CommitAuthor for Commit.author (#353)
- Create release-plz.toml
- Sort deps in cargo.toml (#352)
24 changes: 24 additions & 0 deletions examples/create_a_gist.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use octocrab::Octocrab;

#[tokio::main]
async fn main() -> octocrab::Result<()> {
let token = std::env::var("GITHUB_TOKEN").expect("GITHUB_TOKEN env variable is required");

let octocrab = Octocrab::builder().personal_token(token).build()?;

println!("Creating a gist with hello world in rust on your account");
let gist = octocrab
.gists()
.create()
.file(
"hello_world.rs",
"fn main() {\n println!(\"Hello World!\");\n}",
)
// Optional Parameters
.description("Hello World in Rust")
.public(false)
.send()
.await?;
println!("Done, created: {url}", url = gist.html_url.to_string());
Ok(())
}