-
Notifications
You must be signed in to change notification settings - Fork 20
/
git_pr_work_items.rs
42 lines (34 loc) · 1.27 KB
/
git_pr_work_items.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// git_pr_work_items.rs
// Example: Getting work items(s) associated with a PR
use anyhow::Result;
use azure_devops_rust_api::git;
use std::env;
mod utils;
#[tokio::main]
async fn main() -> Result<()> {
// Get authentication credential
let credential = utils::get_credential()?;
// Get ADO server configuration via environment variables
let organization = env::var("ADO_ORGANIZATION").expect("Must define ADO_ORGANIZATION");
let repository_name = env::args()
.nth(1)
.expect("Usage: git_pr_work_items <repository-name> <pull_request_id>");
let pull_request_id: i32 = env::args()
.nth(2)
.expect("Usage: git_pr_work_items <repository-name> <pull_request_id>")
.parse()
.unwrap();
let project = env::var("ADO_PROJECT").expect("Must define ADO_PROJECT");
// Create a "git" client
let git_client = git::ClientBuilder::new(credential).build();
// Get work item(s) associated with PR
let pr_work_items = git_client
.pull_request_work_items_client()
.list(&organization, &repository_name, pull_request_id, &project)
.await?;
println!("PR work items:");
println!("{:#?}", pr_work_items);
Ok(())
}