forked from microsoft/azure-devops-python-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.py
More file actions
38 lines (23 loc) · 781 Bytes
/
git.py
File metadata and controls
38 lines (23 loc) · 781 Bytes
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
"""
Git samples.
"""
import logging
from samples import resource
from utils import emit, find_any_project, find_any_repo
logger = logging.getLogger(__name__)
@resource('repositories')
def get_repos(context):
project = find_any_project(context)
git_client = context.connection.get_client("vsts.git.v4_1.git_client.GitClient")
repos = git_client.get_repositories(project.id)
for repo in repos:
emit(repo.id + ": " + repo.name)
return repos
@resource('refs')
def get_refs(context):
repo = find_any_repo(context)
git_client = context.connection.get_client("vsts.git.v4_1.git_client.GitClient")
refs = git_client.get_refs(repo.id, repo.project.id)
for ref in refs:
emit(ref.name + ": " + ref.object_id)
return refs