Skip to content

Commit 27629cc

Browse files
authoredSep 20, 2018
Keep track of the checks changed at every Datadog Agent release (DataDog#2277)
1 parent d836a6c commit 27629cc

File tree

5 files changed

+302
-10
lines changed

5 files changed

+302
-10
lines changed
 

‎AGENT_CHANGELOG.md

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
## Datadog Agent version [6.5.0](https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#650)
2+
3+
* datadog_checks_base [2.2.0](https://github.com/DataDog/integrations-core/blob/master/datadog_checks_base/CHANGELOG.md)
4+
* Amazon Fargate [1.2.1](https://github.com/DataDog/integrations-core/blob/master/ecs_fargate/CHANGELOG.md)
5+
* Postgres [2.2.1](https://github.com/DataDog/integrations-core/blob/master/postgres/CHANGELOG.md)
6+
* vSphere [3.1.0](https://github.com/DataDog/integrations-core/blob/master/vsphere/CHANGELOG.md)
7+
8+
## Datadog Agent version [6.4.2](https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#642)
9+
10+
* Active Directory [1.1.0](https://github.com/DataDog/integrations-core/blob/master/active_directory/CHANGELOG.md)
11+
* ActiveMQ XML [1.0.0](https://github.com/DataDog/integrations-core/blob/master/activemq_xml/CHANGELOG.md)
12+
* Apache [1.3.0](https://github.com/DataDog/integrations-core/blob/master/apache/CHANGELOG.md)
13+
* ASP.NET [0.1.2](https://github.com/DataDog/integrations-core/blob/master/aspdotnet/CHANGELOG.md)
14+
* Btrfs [1.2.0](https://github.com/DataDog/integrations-core/blob/master/btrfs/CHANGELOG.md)
15+
* Cacti [1.1.1](https://github.com/DataDog/integrations-core/blob/master/cacti/CHANGELOG.md)
16+
* Cassandra Nodetool [0.1.2](https://github.com/DataDog/integrations-core/blob/master/cassandra_nodetool/CHANGELOG.md)
17+
* Ceph [1.3.0](https://github.com/DataDog/integrations-core/blob/master/ceph/CHANGELOG.md)
18+
* Cisco ACI [1.1.0](https://github.com/DataDog/integrations-core/blob/master/cisco_aci/CHANGELOG.md)
19+
* Consul [1.5.0](https://github.com/DataDog/integrations-core/blob/master/consul/CHANGELOG.md)
20+
* CouchDB [2.6.0](https://github.com/DataDog/integrations-core/blob/master/couch/CHANGELOG.md)
21+
* Couchbase [1.5.0](https://github.com/DataDog/integrations-core/blob/master/couchbase/CHANGELOG.md)
22+
* datadog_checks_base [1.4.0](https://github.com/DataDog/integrations-core/blob/master/datadog_checks_base/CHANGELOG.md)
23+
* Directory [1.2.0](https://github.com/DataDog/integrations-core/blob/master/directory/CHANGELOG.md)
24+
* Disk [1.2.0](https://github.com/DataDog/integrations-core/blob/master/disk/CHANGELOG.md)
25+
* DNS [1.1.1](https://github.com/DataDog/integrations-core/blob/master/dns_check/CHANGELOG.md)
26+
* .NET CLR [1.0.0](https://github.com/DataDog/integrations-core/blob/master/dotnetclr/CHANGELOG.md)
27+
* Amazon Fargate [1.2.0](https://github.com/DataDog/integrations-core/blob/master/ecs_fargate/CHANGELOG.md)
28+
* Elasticsearch [1.7.0](https://github.com/DataDog/integrations-core/blob/master/elastic/CHANGELOG.md)
29+
* Envoy [1.2.1](https://github.com/DataDog/integrations-core/blob/master/envoy/CHANGELOG.md)
30+
* etcd [1.5.0](https://github.com/DataDog/integrations-core/blob/master/etcd/CHANGELOG.md)
31+
* Exchange Server [1.1.0](https://github.com/DataDog/integrations-core/blob/master/exchange_server/CHANGELOG.md)
32+
* fluentd [1.0.0](https://github.com/DataDog/integrations-core/blob/master/fluentd/CHANGELOG.md)
33+
* Gearman [1.1.0](https://github.com/DataDog/integrations-core/blob/master/gearmand/CHANGELOG.md)
34+
* Gitlab [1.1.0](https://github.com/DataDog/integrations-core/blob/master/gitlab/CHANGELOG.md)
35+
* Gitlab Runner [1.1.0](https://github.com/DataDog/integrations-core/blob/master/gitlab_runner/CHANGELOG.md)
36+
* Go-Expvar [1.0.3](https://github.com/DataDog/integrations-core/blob/master/go_expvar/CHANGELOG.md)
37+
* Gunicorn [1.2.0](https://github.com/DataDog/integrations-core/blob/master/gunicorn/CHANGELOG.md)
38+
* HAProxy [1.3.0](https://github.com/DataDog/integrations-core/blob/master/haproxy/CHANGELOG.md)
39+
* HDFS Datanode [1.3.0](https://github.com/DataDog/integrations-core/blob/master/hdfs_datanode/CHANGELOG.md)
40+
* HDFS Namenode [1.3.0](https://github.com/DataDog/integrations-core/blob/master/hdfs_namenode/CHANGELOG.md)
41+
* HTTP [2.2.0](https://github.com/DataDog/integrations-core/blob/master/http_check/CHANGELOG.md)
42+
* IIS [2.1.0](https://github.com/DataDog/integrations-core/blob/master/iis/CHANGELOG.md)
43+
* Istio [1.1.0](https://github.com/DataDog/integrations-core/blob/master/istio/CHANGELOG.md)
44+
* Kafka Consumer [1.4.0](https://github.com/DataDog/integrations-core/blob/master/kafka_consumer/CHANGELOG.md)
45+
* Kong [1.2.0](https://github.com/DataDog/integrations-core/blob/master/kong/CHANGELOG.md)
46+
* Kube DNS [1.4.0](https://github.com/DataDog/integrations-core/blob/master/kube_dns/CHANGELOG.md)
47+
* Kube Proxy [1.1.0](https://github.com/DataDog/integrations-core/blob/master/kube_proxy/CHANGELOG.md)
48+
* Kubelet [1.4.0](https://github.com/DataDog/integrations-core/blob/master/kubelet/CHANGELOG.md)
49+
* Kubernetes State [2.7.0](https://github.com/DataDog/integrations-core/blob/master/kubernetes_state/CHANGELOG.md)
50+
* Kyoto Tycoon [1.3.0](https://github.com/DataDog/integrations-core/blob/master/kyototycoon/CHANGELOG.md)
51+
* Lighttpd [1.2.0](https://github.com/DataDog/integrations-core/blob/master/lighttpd/CHANGELOG.md)
52+
* Linkerd [1.1.0](https://github.com/DataDog/integrations-core/blob/master/linkerd/CHANGELOG.md)
53+
* Linux proc extras [1.0.0](https://github.com/DataDog/integrations-core/blob/master/linux_proc_extras/CHANGELOG.md)
54+
* MapReduce [1.2.0](https://github.com/DataDog/integrations-core/blob/master/mapreduce/CHANGELOG.md)
55+
* Marathon [1.4.0](https://github.com/DataDog/integrations-core/blob/master/marathon/CHANGELOG.md)
56+
* Memcached [1.3.1](https://github.com/DataDog/integrations-core/blob/master/mcache/CHANGELOG.md)
57+
* Mesos Master [1.2.0](https://github.com/DataDog/integrations-core/blob/master/mesos_master/CHANGELOG.md)
58+
* Mesos Slave [1.2.0](https://github.com/DataDog/integrations-core/blob/master/mesos_slave/CHANGELOG.md)
59+
* MongoDB [1.6.0](https://github.com/DataDog/integrations-core/blob/master/mongo/CHANGELOG.md)
60+
* MySQL [1.3.0](https://github.com/DataDog/integrations-core/blob/master/mysql/CHANGELOG.md)
61+
* Nagios [1.1.0](https://github.com/DataDog/integrations-core/blob/master/nagios/CHANGELOG.md)
62+
* Network [1.6.0](https://github.com/DataDog/integrations-core/blob/master/network/CHANGELOG.md)
63+
* Nfsstat [0.2.0](https://github.com/DataDog/integrations-core/blob/master/nfsstat/CHANGELOG.md)
64+
* Nginx [2.2.0](https://github.com/DataDog/integrations-core/blob/master/nginx/CHANGELOG.md)
65+
* OpenStack [1.3.0](https://github.com/DataDog/integrations-core/blob/master/openstack/CHANGELOG.md)
66+
* Oracle Database [1.3.0](https://github.com/DataDog/integrations-core/blob/master/oracle/CHANGELOG.md)
67+
* PDH [1.2.0](https://github.com/DataDog/integrations-core/blob/master/pdh_check/CHANGELOG.md)
68+
* PGBouncer [1.2.1](https://github.com/DataDog/integrations-core/blob/master/pgbouncer/CHANGELOG.md)
69+
* PHP-FPM [1.2.0](https://github.com/DataDog/integrations-core/blob/master/php_fpm/CHANGELOG.md)
70+
* Postfix [1.2.1](https://github.com/DataDog/integrations-core/blob/master/postfix/CHANGELOG.md)
71+
* Postgres [2.1.3](https://github.com/DataDog/integrations-core/blob/master/postgres/CHANGELOG.md)
72+
* PowerDNS Recursor [1.0.0](https://github.com/DataDog/integrations-core/blob/master/powerdns_recursor/CHANGELOG.md)
73+
* Process [1.3.0](https://github.com/DataDog/integrations-core/blob/master/process/CHANGELOG.md)
74+
* Prometheus [1.0.0](https://github.com/DataDog/integrations-core/blob/master/prometheus/CHANGELOG.md)
75+
* RabbitMQ [1.5.1](https://github.com/DataDog/integrations-core/blob/master/rabbitmq/CHANGELOG.md)
76+
* Redis [1.6.0](https://github.com/DataDog/integrations-core/blob/master/redisdb/CHANGELOG.md)
77+
* Riak [1.3.0](https://github.com/DataDog/integrations-core/blob/master/riak/CHANGELOG.md)
78+
* Riak CS [1.1.0](https://github.com/DataDog/integrations-core/blob/master/riakcs/CHANGELOG.md)
79+
* SNMP [1.4.0](https://github.com/DataDog/integrations-core/blob/master/snmp/CHANGELOG.md)
80+
* Spark [1.4.0](https://github.com/DataDog/integrations-core/blob/master/spark/CHANGELOG.md)
81+
* SQL Server [1.5.0](https://github.com/DataDog/integrations-core/blob/master/sqlserver/CHANGELOG.md)
82+
* Squid [1.0.1](https://github.com/DataDog/integrations-core/blob/master/squid/CHANGELOG.md)
83+
* SSH [1.3.0](https://github.com/DataDog/integrations-core/blob/master/ssh_check/CHANGELOG.md)
84+
* Supervisord [1.1.2](https://github.com/DataDog/integrations-core/blob/master/supervisord/CHANGELOG.md)
85+
* System Core [1.0.0](https://github.com/DataDog/integrations-core/blob/master/system_core/CHANGELOG.md)
86+
* System Swap [1.1.0](https://github.com/DataDog/integrations-core/blob/master/system_swap/CHANGELOG.md)
87+
* TCP [2.0.1](https://github.com/DataDog/integrations-core/blob/master/tcp_check/CHANGELOG.md)
88+
* Teamcity [1.1.0](https://github.com/DataDog/integrations-core/blob/master/teamcity/CHANGELOG.md)
89+
* TokuMX [1.2.0](https://github.com/DataDog/integrations-core/blob/master/tokumx/CHANGELOG.md)
90+
* Twemproxy [1.2.0](https://github.com/DataDog/integrations-core/blob/master/twemproxy/CHANGELOG.md)
91+
* Varnish [1.2.0](https://github.com/DataDog/integrations-core/blob/master/varnish/CHANGELOG.md)
92+
* vSphere [2.2.0](https://github.com/DataDog/integrations-core/blob/master/vsphere/CHANGELOG.md)
93+
* Win32 [1.1.1](https://github.com/DataDog/integrations-core/blob/master/win32_event_log/CHANGELOG.md)
94+
* win32_service [1.2.0](https://github.com/DataDog/integrations-core/blob/master/win32_service/CHANGELOG.md) **BREAKING CHANGE**
95+
* WMI [1.1.1](https://github.com/DataDog/integrations-core/blob/master/wmi_check/CHANGELOG.md)
96+
* Yarn [1.3.0](https://github.com/DataDog/integrations-core/blob/master/yarn/CHANGELOG.md)
97+
* ZooKeeper [1.2.0](https://github.com/DataDog/integrations-core/blob/master/zk/CHANGELOG.md)
98+
99+
## Datadog Agent version [6.4.1](https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#641)
100+
101+
* There were no integration updates for this version of the Agent.
102+
103+
## Datadog Agent version [6.4.0](https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#640)
104+
105+
* There were no integration updates for this version of the Agent.
106+
107+
## Datadog Agent version [6.3.3](https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#633)
108+
109+
* Cacti [1.1.0](https://github.com/DataDog/integrations-core/blob/master/cacti/CHANGELOG.md)
110+
* Cassandra Nodetool [0.1.1](https://github.com/DataDog/integrations-core/blob/master/cassandra_nodetool/CHANGELOG.md)
111+
* Cisco ACI [1.0.0](https://github.com/DataDog/integrations-core/blob/master/cisco_aci/CHANGELOG.md)
112+
* Couchbase [1.4.0](https://github.com/DataDog/integrations-core/blob/master/couchbase/CHANGELOG.md)
113+
* datadog_checks_base [1.3.0](https://github.com/DataDog/integrations-core/blob/master/datadog_checks_base/CHANGELOG.md)
114+
* DNS [1.1.0](https://github.com/DataDog/integrations-core/blob/master/dns_check/CHANGELOG.md)
115+
* Envoy [1.2.0](https://github.com/DataDog/integrations-core/blob/master/envoy/CHANGELOG.md)
116+
* etcd [1.4.0](https://github.com/DataDog/integrations-core/blob/master/etcd/CHANGELOG.md)
117+
* Kube DNS [1.3.0](https://github.com/DataDog/integrations-core/blob/master/kube_dns/CHANGELOG.md)
118+
* Memcached [1.3.0](https://github.com/DataDog/integrations-core/blob/master/mcache/CHANGELOG.md)
119+
* MongoDB [1.5.4](https://github.com/DataDog/integrations-core/blob/master/mongo/CHANGELOG.md)
120+
* PHP-FPM [1.1.0](https://github.com/DataDog/integrations-core/blob/master/php_fpm/CHANGELOG.md)
121+
* Postfix [1.1.0](https://github.com/DataDog/integrations-core/blob/master/postfix/CHANGELOG.md)
122+
* Postgres [2.1.2](https://github.com/DataDog/integrations-core/blob/master/postgres/CHANGELOG.md)
123+
* SQL Server [1.4.0](https://github.com/DataDog/integrations-core/blob/master/sqlserver/CHANGELOG.md)
124+
* SSH [1.2.0](https://github.com/DataDog/integrations-core/blob/master/ssh_check/CHANGELOG.md)
125+
* TCP [2.0.0](https://github.com/DataDog/integrations-core/blob/master/tcp_check/CHANGELOG.md)
126+
* vSphere [2.1.0](https://github.com/DataDog/integrations-core/blob/master/vsphere/CHANGELOG.md)
127+
128+
## Datadog Agent version [6.3.2](https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#632)
129+
130+
* There were no integration updates for this version of the Agent.
131+
132+
## Datadog Agent version [6.3.1](https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#631)
133+
134+
* There were no integration updates for this version of the Agent.
135+
136+
## Datadog Agent version [6.3.0](https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#630)
137+
138+
* HTTP [2.1.0](https://github.com/DataDog/integrations-core/blob/master/http_check/CHANGELOG.md)
139+
* Kubelet [1.3.1](https://github.com/DataDog/integrations-core/blob/master/kubelet/CHANGELOG.md)
140+
* Kubernetes State [2.5.0](https://github.com/DataDog/integrations-core/blob/master/kubernetes_state/CHANGELOG.md)
141+

‎datadog_checks_dev/datadog_checks/dev/tooling/commands/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .create import create
77
from .dep import dep
88
from .manifest import manifest
9-
from .release import release
9+
from .release import release, agent_changelog
1010
from .test import test
1111

1212
ALL_COMMANDS = (
@@ -17,4 +17,5 @@
1717
manifest,
1818
release,
1919
test,
20+
agent_changelog,
2021
)

‎datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py

+105-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Licensed under a 3-clause BSD style license (see LICENSE)
44
import os
55
import time
6+
import json
67
from collections import OrderedDict, namedtuple
78
from datetime import datetime
89

@@ -12,13 +13,15 @@
1213

1314
from .dep import freeze as dep_freeze
1415
from .utils import (
15-
CONTEXT_SETTINGS, abort, echo_failure, echo_info, echo_success, echo_waiting, echo_warning
16+
CONTEXT_SETTINGS, abort, echo_failure, echo_info, echo_success, echo_waiting,
17+
echo_warning
1618
)
1719
from ..constants import (
1820
AGENT_REQ_FILE, AGENT_V5_ONLY, CHANGELOG_TYPE_NONE, get_root
1921
)
2022
from ..git import (
21-
get_current_branch, parse_pr_numbers, get_diff, git_tag, git_commit
23+
get_current_branch, parse_pr_numbers, get_commits_since, git_tag, git_commit,
24+
git_show_file, git_tag_list
2225
)
2326
from ..github import from_contributor, get_changelog_types, get_pr, get_pr_from_hash
2427
from ..release import (
@@ -28,13 +31,13 @@
2831
from ..trello import TrelloClient
2932
from ..utils import (
3033
get_bump_function, get_current_agent_version, get_valid_checks,
31-
get_version_string, format_commit_id, parse_pr_number
34+
get_version_string, format_commit_id, parse_pr_number, parse_agent_req_file
3235
)
3336
from ...structures import EnvVars
3437
from ...subprocess import run_command
3538
from ...utils import (
3639
basepath, chdir, ensure_unicode, get_next, remove_path, stream_file_lines,
37-
write_file, write_file_lines
40+
write_file, write_file_lines, read_file
3841
)
3942

4043
ChangelogEntry = namedtuple('ChangelogEntry', 'number, title, url, author, author_url, from_contributor')
@@ -91,7 +94,7 @@ def ready(ctx, quiet):
9194
target_tag = get_release_tag_string(target, cur_version)
9295

9396
# get the diff from HEAD
94-
diff_lines = get_diff(target, target_tag)
97+
diff_lines = get_commits_since(target, target_tag)
9598

9699
# get the number of PRs that could be potentially released
97100
# Only show the ones that have a changelog label that isn't no-changelog
@@ -156,7 +159,7 @@ def changes(ctx, check, dry_run):
156159
target_tag = get_release_tag_string(check, cur_version)
157160

158161
# get the diff from HEAD
159-
diff_lines = get_diff(check, target_tag)
162+
diff_lines = get_commits_since(check, target_tag)
160163

161164
# for each PR get the title, we'll use it to populate the changelog
162165
pr_numbers = parse_pr_numbers(diff_lines)
@@ -598,7 +601,7 @@ def changelog(ctx, check, version, old_version, quiet, dry_run):
598601
target_tag = get_release_tag_string(check, cur_version)
599602

600603
# get the diff from HEAD
601-
diff_lines = get_diff(check, target_tag)
604+
diff_lines = get_commits_since(check, target_tag)
602605

603606
# for each PR get the title, we'll use it to populate the changelog
604607
pr_numbers = parse_pr_numbers(diff_lines)
@@ -756,3 +759,98 @@ def freeze(ctx, no_deps):
756759

757760
if not no_deps:
758761
ctx.invoke(dep_freeze)
762+
763+
764+
@release.command(
765+
context_settings=CONTEXT_SETTINGS,
766+
short_help="Provide a list of the updated checks on a given agent version, in changelog form"
767+
)
768+
@click.option('--since', help="Initial Agent version", default='6.3.0')
769+
@click.option('--to', help="Final Agent version")
770+
@click.option('--output', '-o', help="Path to the changelog file, if omitted contents will be printed to stdout")
771+
@click.option('--force', '-f', is_flag=True, default=False, help="Replace an existing file")
772+
@click.pass_context
773+
def agent_changelog(ctx, since, to, output, force):
774+
"""
775+
Generates a markdown file containing the list of checks that changed for a
776+
given Agent release. Agent version numbers are derived inspecting tags on
777+
`integrations-core` so running this tool might provide unexpected results
778+
if the repo is not up to date with the Agent release process.
779+
780+
If neither `--since` or `--to` are passed (the most common use case), the
781+
tool will generate the whole changelog since Agent version 6.3.0
782+
(before that point we don't have enough informations to build the log).
783+
"""
784+
agent_tags = git_tag_list(r'^\d+\.\d+\.\d+$')
785+
786+
# default value for --to is the latest tag
787+
if not to:
788+
to = agent_tags[-1]
789+
790+
# filter out versions according to the interval [since, to]
791+
agent_tags = [t for t in agent_tags if t >= since and t <= to]
792+
793+
# reverse so we have descendent order
794+
agent_tags = agent_tags[::-1]
795+
796+
# store the changes in a mapping {agent_version --> {check_name --> current_version}}
797+
changes_per_agent = OrderedDict()
798+
799+
for i in range(1, len(agent_tags)):
800+
contents_from = git_show_file(AGENT_REQ_FILE, agent_tags[i-1])
801+
catalog_from = parse_agent_req_file(contents_from)
802+
803+
contents_to = git_show_file(AGENT_REQ_FILE, agent_tags[i])
804+
catalog_to = parse_agent_req_file(contents_to)
805+
806+
changes = OrderedDict()
807+
changes_per_agent[agent_tags[i]] = changes
808+
809+
for name, ver in catalog_to.iteritems():
810+
old_ver = catalog_from.get(name, "")
811+
if old_ver != ver:
812+
# determine whether major version changed
813+
breaking = old_ver.split('.')[0] < ver.split('.')[0]
814+
changes[name] = (ver, breaking)
815+
816+
# store the changelog in memory
817+
changelog = StringIO()
818+
819+
# prepare the links
820+
agent_changelog_url = 'https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#{}'
821+
check_changelog_url = 'https://github.com/DataDog/integrations-core/blob/master/{}/CHANGELOG.md'
822+
823+
# go through all the agent releases
824+
for agent, changes in changes_per_agent.iteritems():
825+
url = agent_changelog_url.format(agent.replace('.', '')) # Github removes dots from the anchor
826+
changelog.write('## Datadog Agent version [{}]({})\n\n'.format(agent, url))
827+
828+
if not changes:
829+
changelog.write('* There were no integration updates for this version of the Agent.\n\n')
830+
else:
831+
for name, ver in changes.iteritems():
832+
# get the "display name" for the check
833+
manifest_file = os.path.join(get_root(), name, 'manifest.json')
834+
if os.path.exists(manifest_file):
835+
decoded = json.loads(read_file(manifest_file).strip(), object_pairs_hook=OrderedDict)
836+
display_name = decoded.get('display_name')
837+
else:
838+
display_name = name
839+
840+
breaking_notice = " **BREAKING CHANGE** " if ver[1] else ""
841+
changelog_url = check_changelog_url.format(name)
842+
changelog.write('* {} [{}]({}){}\n'.format(display_name, ver[0], changelog_url, breaking_notice))
843+
# add an extra line to separate the release block
844+
changelog.write('\n')
845+
846+
# save the changelog on disk if --output was passed
847+
if output:
848+
# don't overwrite an existing file
849+
if os.path.exists(output) and not force:
850+
msg = "Output file {} already exists, run the command again with --force to overwrite"
851+
echo_failure(msg.format(output))
852+
abort()
853+
854+
write_file(output, changelog.getvalue())
855+
else:
856+
echo_info(changelog.getvalue())

‎datadog_checks_dev/datadog_checks/dev/tooling/git.py

+30-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# All rights reserved
33
# Licensed under a 3-clause BSD style license (see LICENSE)
44
import os
5+
import re
56

67
from .constants import get_root
78
from .utils import parse_pr_number
@@ -47,9 +48,9 @@ def parse_pr_numbers(git_log_lines):
4748
return prs
4849

4950

50-
def get_diff(check_name, target_tag):
51+
def get_commits_since(check_name, target_tag):
5152
"""
52-
Get the git diff from HEAD for the given check
53+
Get the list of commits from `target_tag` to `HEAD` for the given check
5354
"""
5455
root = get_root()
5556
target_path = os.path.join(root, check_name)
@@ -59,6 +60,17 @@ def get_diff(check_name, target_tag):
5960
return run_command(command, capture=True).stdout.splitlines()
6061

6162

63+
def git_show_file(path, ref):
64+
"""
65+
Return the contents of a file at a given tag
66+
"""
67+
root = get_root()
68+
command = 'git show {}:{}'.format(ref, path)
69+
70+
with chdir(root):
71+
return run_command(command, capture=True).stdout
72+
73+
6274
def git_commit(targets, message):
6375
"""
6476
Commit the changes for the given targets.
@@ -89,3 +101,19 @@ def git_tag(tag_name, push=False):
89101
return run_command('git push origin {}'.format(tag_name))
90102

91103
return result
104+
105+
106+
def git_tag_list(pattern=None):
107+
"""
108+
Return a list of all the tags in the git repo matching a regex passed in
109+
`pattern`. If `pattern` is None, return all the tags.
110+
"""
111+
with chdir(get_root()):
112+
result = run_command('git tag', capture=True).stdout
113+
result = result.splitlines()
114+
115+
if not pattern:
116+
return result
117+
118+
regex = re.compile(pattern)
119+
return filter(regex.search, result)

‎datadog_checks_dev/datadog_checks/dev/tooling/utils.py

+24
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import re
77
from ast import literal_eval
8+
from collections import OrderedDict
89

910
import requests
1011
import semver
@@ -123,3 +124,26 @@ def get_bump_function(changelog_types):
123124
minor_bump = True
124125

125126
return semver.bump_minor if minor_bump else semver.bump_patch
127+
128+
129+
def parse_agent_req_file(contents):
130+
"""
131+
Returns a dictionary mapping {check_name --> pinned_version} from the
132+
given file contents. We can assume lines are in the form:
133+
134+
active_directory==1.1.1; sys_platform == 'win32'
135+
136+
"""
137+
catalog = OrderedDict()
138+
for line in contents.splitlines():
139+
toks = line.split('==', 1)
140+
if len(toks) != 2 or not toks[0] or not toks[1]:
141+
# if we get here, the requirements file is garbled but let's stay
142+
# resilient
143+
continue
144+
145+
name, other = toks
146+
version = other.split(';')
147+
catalog[name] = version[0]
148+
149+
return catalog

0 commit comments

Comments
 (0)
Please sign in to comment.