Skip to content

Commit 0b38a84

Browse files
committed
🚀 releasing version 3.1.0 @ 2023-03-01 14:30
[skip ci]
1 parent e6a032c commit 0b38a84

16 files changed

+114
-41
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@ This project was forked from version 1.7.4 of [mbed-tools-ci-scripts](https://gi
1717

1818
[//]: # (begin_release_notes)
1919

20+
21+
Features
22+
--------
23+
24+
- :sparkles: Extended `create-news` so that the reference number can be specified (#20230301133846)
25+
26+
27+
Bugfixes
28+
--------
29+
30+
- Dependency upgrade: mypy-1.0.0 (#20230207072240)
31+
- Dependency upgrade: mypy-1.0.1 (#20230220081601)
32+
- Dependency upgrade: coverage-7.2.0 (#20230223072638)
33+
- Dependency upgrade: setup-python-4 (#20230227080926)
34+
- :zap: Improved the performance of `assert news` for cases where news files are added to the current commit (#20230228103345)
35+
- Dependency upgrade: coverage-7.2.1 (#20230301081045)
36+
37+
38+
Misc
39+
----
40+
41+
- #20230228130522
42+
43+
2044
"3.0.7" (2023-01-25)
2145
====================
2246

continuous_delivery_scripts/_version.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
1111
This file is autogenerated, do not modify by hand.
1212
"""
13-
__version__ = "3.0.7"
14-
COMMIT = "76bfdb419b674ab645ddfbba05ac0ef061b50c0b"
13+
__version__ = "3.1.0"
14+
COMMIT = "e6a032c1434a9945d1d49843fc519d50a2e50283"
1515
MAJOR = 3
16-
MINOR = 0
17-
PATCH = 7
16+
MINOR = 1
17+
PATCH = 0

docs/assert_news.html

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
3838
&#34;&#34;&#34;Checks if valid news files are created for changes in the project.&#34;&#34;&#34;
3939
import argparse
4040
import logging
41+
import pathlib
4142
import re
4243
import sys
4344
from typing import List, Union
44-
import pathlib
4545

4646
from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
4747
from continuous_delivery_scripts.utils.git_helpers import ProjectTempClone, LocalProjectRepository, GitWrapper
@@ -104,10 +104,15 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
104104
Returns:
105105
list: list of absolute paths to news files
106106
&#34;&#34;&#34;
107-
files_changed = git.list_files_added_on_current_branch()
107+
files_changed = git.list_files_added_to_current_commit()
108+
# To speed up the process, we first look at files added to the current commit.
109+
# If no news files were added, then we check for addition on the branch.
108110
# Relies on the fact GitWrapper returns paths that are always relative
109111
# to the project root.
110112
added_news_files = [file_path for file_path in files_changed if file_path.startswith(news_dir)]
113+
if len(added_news_files) == 0:
114+
files_changed = git.list_files_added_on_current_branch()
115+
added_news_files = [file_path for file_path in files_changed if file_path.startswith(news_dir)]
111116
return [str(pathlib.Path(root_dir, file_path)) for file_path in added_news_files]
112117

113118

@@ -239,10 +244,15 @@ <h2 id="returns">Returns</h2>
239244
Returns:
240245
list: list of absolute paths to news files
241246
&#34;&#34;&#34;
242-
files_changed = git.list_files_added_on_current_branch()
247+
files_changed = git.list_files_added_to_current_commit()
248+
# To speed up the process, we first look at files added to the current commit.
249+
# If no news files were added, then we check for addition on the branch.
243250
# Relies on the fact GitWrapper returns paths that are always relative
244251
# to the project root.
245252
added_news_files = [file_path for file_path in files_changed if file_path.startswith(news_dir)]
253+
if len(added_news_files) == 0:
254+
files_changed = git.list_files_added_on_current_branch()
255+
added_news_files = [file_path for file_path in files_changed if file_path.startswith(news_dir)]
246256
return [str(pathlib.Path(root_dir, file_path)) for file_path in added_news_files]</code></pre>
247257
</details>
248258
</dd>

docs/create_news_file.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ <h2 id="usage">Usage</h2>
6464
parser.add_argument(
6565
&#34;-t&#34;, &#34;--type&#34;, help=&#34;News type to create.&#34;, choices=[t.name for t in NewsType], default=&#34;feature&#34;
6666
)
67+
parser.add_argument(&#34;-n&#34;, &#34;--ref-number&#34;, help=&#34;Reference number of the news file to use&#34;, required=False)
6768

6869
args = parser.parse_args()
69-
created_file = create_news_file(str(NEWS_DIR), args.news_text, NewsType[args.type])
70+
created_file = create_news_file(str(NEWS_DIR), args.ref_number, args.news_text, NewsType[args.type])
7071

7172
try:
7273
validate_news_file(created_file)
@@ -105,9 +106,10 @@ <h2 class="section-title" id="header-functions">Functions</h2>
105106
parser.add_argument(
106107
&#34;-t&#34;, &#34;--type&#34;, help=&#34;News type to create.&#34;, choices=[t.name for t in NewsType], default=&#34;feature&#34;
107108
)
109+
parser.add_argument(&#34;-n&#34;, &#34;--ref-number&#34;, help=&#34;Reference number of the news file to use&#34;, required=False)
108110

109111
args = parser.parse_args()
110-
created_file = create_news_file(str(NEWS_DIR), args.news_text, NewsType[args.type])
112+
created_file = create_news_file(str(NEWS_DIR), args.ref_number, args.news_text, NewsType[args.type])
111113

112114
try:
113115
validate_news_file(created_file)

docs/third_party_IP_report.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
</head>
6666
<body>
6767
<h1>Project's 3rd party IP report</h1>
68-
<p><i>2023-01-25 19:09:05.851526</i></p>
68+
<p><i>2023-03-01 14:30:50.921371</i></p>
6969
<h2>Summary</h2>
7070
<table>
7171
<thead>

docs/third_party_IP_report.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
3rd party IP report for continuous-delivery-scripts
22

3-
2023-01-25 19:09:05.851526
3+
2023-03-01 14:30:50.921371
44

55
# Summary:
66
Licence compliance: Not compliant

docs/utils/git_helpers.html

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.git_helpers</co
4040
import os
4141
import re
4242
import shutil
43-
from pathlib import Path
44-
from typing import Optional, List, Union, Any, Tuple
45-
4643
from git import Repo, Actor, GitCommandError
4744
from packaging import version
45+
from pathlib import Path
46+
from typing import Optional, List, Union, Any, Tuple
4847

4948
from .configuration import configuration, ConfigurationVariable
5049
from .filesystem_helpers import TemporaryDirectory
@@ -434,7 +433,13 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.git_helpers</co
434433
return self.get_remote_branch(branch_name) is not None
435434

436435
def _get_specific_changes(self, change_type: Optional[str], commit1: Any, commit2: Any) -&gt; List[str]:
437-
diff = commit1.diff(commit2)
436+
diff = None
437+
if commit1:
438+
diff = commit1.diff(commit2) if commit2 else commit1.diff()
439+
elif commit2:
440+
diff = commit2.diff()
441+
if not diff:
442+
return []
438443
if change_type:
439444
change_type = change_type.upper()
440445
change_type = change_type if change_type in diff.change_type else None
@@ -580,6 +585,14 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.git_helpers</co
580585
logger.warning(e)
581586
return None
582587

588+
def list_files_added_to_current_commit(self) -&gt; List[str]:
589+
&#34;&#34;&#34;Returns a list of files added in the current commit.&#34;&#34;&#34;
590+
current_commit = self.repo.head.commit
591+
previous_commit = self.repo.commit(&#34;HEAD~1&#34;)
592+
if not current_commit:
593+
current_commit = self.get_current_commit()
594+
return self.get_changes_list(previous_commit, current_commit, change_type=&#34;a&#34;)
595+
583596
def list_files_added_on_current_branch(self) -&gt; List[str]:
584597
&#34;&#34;&#34;Returns a list of files changed against master branch.&#34;&#34;&#34;
585598
master_branch = self.get_master_branch()
@@ -598,8 +611,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.git_helpers</co
598611
# The branch point off `beta` is more recent than off `master`.
599612
# Hence, the difference between current and `beta` should be considered.
600613
branch_point = beta_branch_point
601-
changes = self.get_changes_list(branch_point, current_branch_commit, change_type=&#34;a&#34;)
602-
return changes
614+
return self.get_changes_list(branch_point, current_branch_commit, change_type=&#34;a&#34;)
603615

604616
def is_current_branch_feature(self) -&gt; bool:
605617
&#34;&#34;&#34;Returns boolean indicating if current branch is considered a feature.&#34;&#34;&#34;
@@ -1012,6 +1024,7 @@ <h3>Inherited members</h3>
10121024
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.is_release_branch" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.is_release_branch">is_release_branch</a></code></li>
10131025
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_branches" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_branches">list_branches</a></code></li>
10141026
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_on_current_branch" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_on_current_branch">list_files_added_on_current_branch</a></code></li>
1027+
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_to_current_commit" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_to_current_commit">list_files_added_to_current_commit</a></code></li>
10151028
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.merge" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.merge">merge</a></code></li>
10161029
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull">pull</a></code></li>
10171030
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull_all" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull_all">pull_all</a></code></li>
@@ -1484,7 +1497,13 @@ <h2 id="args">Args</h2>
14841497
return self.get_remote_branch(branch_name) is not None
14851498

14861499
def _get_specific_changes(self, change_type: Optional[str], commit1: Any, commit2: Any) -&gt; List[str]:
1487-
diff = commit1.diff(commit2)
1500+
diff = None
1501+
if commit1:
1502+
diff = commit1.diff(commit2) if commit2 else commit1.diff()
1503+
elif commit2:
1504+
diff = commit2.diff()
1505+
if not diff:
1506+
return []
14881507
if change_type:
14891508
change_type = change_type.upper()
14901509
change_type = change_type if change_type in diff.change_type else None
@@ -1630,6 +1649,14 @@ <h2 id="args">Args</h2>
16301649
logger.warning(e)
16311650
return None
16321651

1652+
def list_files_added_to_current_commit(self) -&gt; List[str]:
1653+
&#34;&#34;&#34;Returns a list of files added in the current commit.&#34;&#34;&#34;
1654+
current_commit = self.repo.head.commit
1655+
previous_commit = self.repo.commit(&#34;HEAD~1&#34;)
1656+
if not current_commit:
1657+
current_commit = self.get_current_commit()
1658+
return self.get_changes_list(previous_commit, current_commit, change_type=&#34;a&#34;)
1659+
16331660
def list_files_added_on_current_branch(self) -&gt; List[str]:
16341661
&#34;&#34;&#34;Returns a list of files changed against master branch.&#34;&#34;&#34;
16351662
master_branch = self.get_master_branch()
@@ -1648,8 +1675,7 @@ <h2 id="args">Args</h2>
16481675
# The branch point off `beta` is more recent than off `master`.
16491676
# Hence, the difference between current and `beta` should be considered.
16501677
branch_point = beta_branch_point
1651-
changes = self.get_changes_list(branch_point, current_branch_commit, change_type=&#34;a&#34;)
1652-
return changes
1678+
return self.get_changes_list(branch_point, current_branch_commit, change_type=&#34;a&#34;)
16531679

16541680
def is_current_branch_feature(self) -&gt; bool:
16551681
&#34;&#34;&#34;Returns boolean indicating if current branch is considered a feature.&#34;&#34;&#34;
@@ -2760,8 +2786,25 @@ <h2 id="returns">Returns</h2>
27602786
# The branch point off `beta` is more recent than off `master`.
27612787
# Hence, the difference between current and `beta` should be considered.
27622788
branch_point = beta_branch_point
2763-
changes = self.get_changes_list(branch_point, current_branch_commit, change_type=&#34;a&#34;)
2764-
return changes</code></pre>
2789+
return self.get_changes_list(branch_point, current_branch_commit, change_type=&#34;a&#34;)</code></pre>
2790+
</details>
2791+
</dd>
2792+
<dt id="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_to_current_commit"><code class="name flex">
2793+
<span>def <span class="ident">list_files_added_to_current_commit</span></span>(<span>self) ‑> List[str]</span>
2794+
</code></dt>
2795+
<dd>
2796+
<div class="desc"><p>Returns a list of files added in the current commit.</p></div>
2797+
<details class="source">
2798+
<summary>
2799+
<span>Expand source code</span>
2800+
</summary>
2801+
<pre><code class="python">def list_files_added_to_current_commit(self) -&gt; List[str]:
2802+
&#34;&#34;&#34;Returns a list of files added in the current commit.&#34;&#34;&#34;
2803+
current_commit = self.repo.head.commit
2804+
previous_commit = self.repo.commit(&#34;HEAD~1&#34;)
2805+
if not current_commit:
2806+
current_commit = self.get_current_commit()
2807+
return self.get_changes_list(previous_commit, current_commit, change_type=&#34;a&#34;)</code></pre>
27652808
</details>
27662809
</dd>
27672810
<dt id="continuous_delivery_scripts.utils.git_helpers.GitWrapper.merge"><code class="name flex">
@@ -3049,6 +3092,7 @@ <h3>Inherited members</h3>
30493092
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.is_release_branch" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.is_release_branch">is_release_branch</a></code></li>
30503093
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_branches" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_branches">list_branches</a></code></li>
30513094
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_on_current_branch" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_on_current_branch">list_files_added_on_current_branch</a></code></li>
3095+
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_to_current_commit" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_to_current_commit">list_files_added_to_current_commit</a></code></li>
30523096
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.merge" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.merge">merge</a></code></li>
30533097
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull">pull</a></code></li>
30543098
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull_all" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull_all">pull_all</a></code></li>
@@ -3168,6 +3212,7 @@ <h4><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper" hr
31683212
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.is_release_branch" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.is_release_branch">is_release_branch</a></code></li>
31693213
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_branches" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_branches">list_branches</a></code></li>
31703214
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_on_current_branch" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_on_current_branch">list_files_added_on_current_branch</a></code></li>
3215+
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_to_current_commit" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.list_files_added_to_current_commit">list_files_added_to_current_commit</a></code></li>
31713216
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.merge" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.merge">merge</a></code></li>
31723217
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull">pull</a></code></li>
31733218
<li><code><a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull_all" href="#continuous_delivery_scripts.utils.git_helpers.GitWrapper.pull_all">pull_all</a></code></li>

0 commit comments

Comments
 (0)