Allow users to customize the default branch name #5
|
@ -74,6 +74,9 @@ mod tests {
|
|||
let res = super::read("testdata/basic.md".into(), "0.1.0".into());
|
||||
assert!(res.is_ok());
|
||||
let delta = res.unwrap();
|
||||
assert_eq!(delta, "Hi there this is a test\\!\n### ADDED\n - something\n")
|
||||
assert_eq!(
|
||||
delta,
|
||||
"Hi there this is a test\\!\n### ADDED\n - something\n"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ pub(crate) async fn run(env: DroneEnv) -> Result<()> {
|
|||
let default_branch = match &env.default_branch {
|
||||
None => {
|
||||
let cli = crate::client(&common)?;
|
||||
let repo = crate::gitea::get_repo(&cli, &common.server, &common.owner, &common.repo).await?;
|
||||
let repo =
|
||||
crate::gitea::get_repo(&cli, &common.server, &common.owner, &common.repo).await?;
|
||||
repo.default_branch
|
||||
}
|
||||
Some(branch) => branch.to_string(),
|
||||
|
|
|
@ -32,12 +32,10 @@ pub(crate) async fn run(
|
|||
cr.prerelease = rm.pre_release;
|
||||
|
||||
let resp = cli
|
||||
.post(
|
||||
&format!(
|
||||
"{}/api/v1/repos/{}/{}/releases/{}",
|
||||
common.server, common.owner, common.repo, release.id
|
||||
),
|
||||
)
|
||||
.post(&format!(
|
||||
"{}/api/v1/repos/{}/{}/releases/{}",
|
||||
common.server, common.owner, common.repo, release.id
|
||||
))
|
||||
.json(&cr)
|
||||
.send()
|
||||
.await?;
|
||||
|
|
|
@ -32,33 +32,33 @@ pub(crate) struct Common {
|
|||
pub(crate) struct DroneEnv {
|
||||
// Given by drone
|
||||
/// push URL
|
||||
#[structopt(long, env="DRONE_GIT_HTTP_URL")]
|
||||
#[structopt(long, env = "DRONE_GIT_HTTP_URL")]
|
||||
pub push_url: String,
|
||||
/// repo owner
|
||||
#[structopt(long, env="DRONE_REPO_OWNER")]
|
||||
#[structopt(long, env = "DRONE_REPO_OWNER")]
|
||||
pub owner: String,
|
||||
/// repo name
|
||||
#[structopt(long, env="DRONE_REPO_NAME")]
|
||||
#[structopt(long, env = "DRONE_REPO_NAME")]
|
||||
pub repo: String,
|
||||
/// branch
|
||||
#[structopt(long, env="DRONE_REPO_BRANCH")]
|
||||
#[structopt(long, env = "DRONE_REPO_BRANCH")]
|
||||
pub branch: String,
|
||||
|
||||
// Given by the user
|
||||
/// auth username
|
||||
#[structopt(long, env="PLUGIN_AUTH_USERNAME")]
|
||||
#[structopt(long, env = "PLUGIN_AUTH_USERNAME")]
|
||||
pub auth_user: String,
|
||||
/// Gitea server
|
||||
#[structopt(long, env="PLUGIN_GITEA_SERVER")]
|
||||
#[structopt(long, env = "PLUGIN_GITEA_SERVER")]
|
||||
pub server: String,
|
||||
/// Gitea token
|
||||
#[structopt(long, env="PLUGIN_GITEA_TOKEN")]
|
||||
#[structopt(long, env = "PLUGIN_GITEA_TOKEN")]
|
||||
pub token: String,
|
||||
/// CHANGELOG path
|
||||
#[structopt(long, env="PLUGIN_CHANGELOG_PATH", default_value="./CHANGELOG.md")]
|
||||
#[structopt(long, env = "PLUGIN_CHANGELOG_PATH", default_value = "./CHANGELOG.md")]
|
||||
pub changelog_path: PathBuf,
|
||||
/// Default branch name
|
||||
#[structopt(long, env="PLUGIN_DEFAULT_BRANCH")]
|
||||
#[structopt(long, env = "PLUGIN_DEFAULT_BRANCH")]
|
||||
pub default_branch: Option<String>,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue