-
Notifications
You must be signed in to change notification settings - Fork 20
/
git_items_get_items_batch.rs
57 lines (48 loc) · 1.72 KB
/
git_items_get_items_batch.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// git_items_get_items_batch.rs
// Git get items (files and folders) batch example.
use anyhow::Result;
use azure_devops_rust_api::git;
use azure_devops_rust_api::git::models::{GitItemDescriptor, GitItemRequestData};
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 project = env::var("ADO_PROJECT").expect("Must define ADO_PROJECT");
let repository_name = env::args()
.nth(1)
.expect("Usage: git_items_get <repository-name> <file_path>");
let file_path = env::args()
.nth(2)
.expect("Usage: git_items_get <repository-name> <file_path>");
let git_item_request_data = GitItemRequestData {
include_content_metadata: Some(true),
include_links: Some(true),
item_descriptors: vec![GitItemDescriptor {
path: Some(file_path.clone()),
recursion_level: None,
version: None,
version_options: None,
version_type: None,
}],
latest_processed_change: Some(true),
};
// Create a git client
let git_client = git::ClientBuilder::new(credential.clone()).build();
let items_batch = git_client
.items_client()
.get_items_batch(
&organization,
git_item_request_data,
&repository_name,
&project,
)
.await?;
println!("\n{file_path} metadata items batch:\n{:#?}", items_batch);
Ok(())
}