Skip to content

Commit

Permalink
Merge pull request #13 from udzura/fix-release-optional
Browse files Browse the repository at this point in the history
Cover optionals
  • Loading branch information
udzura authored Jul 1, 2021
2 parents 47bf86d + 01e2749 commit e189e94
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "octx"
version = "0.4.4"
version = "0.4.5"
authors = ["Uchio Kondo <[email protected]>"]
repository = "https://github.com/udzura/octx"
keywords = ["github", "cli", "etl"]
Expand Down
36 changes: 30 additions & 6 deletions src/releases.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
use chrono::{DateTime, Utc};
use octocrab::models::repos::*;
use octocrab::models::repos::Asset;
use reqwest::Url;
use serde::*;

use crate::*;

// use octocrab::models::repos::Release;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct Release {
pub url: Url,
pub html_url: Url,
pub assets_url: Url,
pub upload_url: Url,
pub tarball_url: Option<Url>,
pub zipball_url: Option<Url>,
pub id: i64,
pub node_id: String,
pub tag_name: String,
pub target_commitish: String,
pub name: Option<String>,
pub body: Option<String>,
pub draft: bool,
pub prerelease: bool,
pub created_at: DateTime<Utc>,
pub published_at: Option<DateTime<Utc>>,
pub author: Option<octocrab::models::User>,
pub assets: Vec<Asset>,
}

#[derive(Serialize, Debug)]
pub struct ReleaseRec {
pub url: Url,
pub html_url: Url,
pub assets_url: Url,
pub upload_url: Url,
pub tarball_url: Url,
pub zipball_url: Url,
pub tarball_url: Option<Url>,
pub zipball_url: Option<Url>,
pub id: i64,
pub node_id: String,
pub tag_name: String,
Expand All @@ -22,8 +46,8 @@ pub struct ReleaseRec {
pub draft: bool,
pub prerelease: bool,
pub created_at: DateTime<Utc>,
pub published_at: DateTime<Utc>,
pub author_id: i64,
pub published_at: Option<DateTime<Utc>>,
pub author_id: Option<i64>,
pub assets: String,

pub sdc_repository: String,
Expand All @@ -48,7 +72,7 @@ impl From<Release> for ReleaseRec {
prerelease: from.prerelease,
created_at: from.created_at,
published_at: from.published_at,
author_id: from.author.id,
author_id: from.author.map(|u| u.id),
assets: from
.assets
.iter()
Expand Down

0 comments on commit e189e94

Please sign in to comment.