Skip to content

Commit 419de58

Browse files
committed
Update check and i18n
* Incorporate shell=True directly into _run when on windows and modifying path/env * Fix _get_bin_path to resolve the build_dir to absolute path * Fix _git_branches_related to ignore non-zero return code * Fix double naming of transifex resource
1 parent 356a4b1 commit 419de58

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

.tx/config

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ host = https://app.transifex.com
44
[o:keepassxc:p:keepassxc:r:share-translations-keepassxc-en-ts--develop]
55
file_filter = share/translations/keepassxc_<lang>.ts
66
source_file = share/translations/keepassxc_en.ts
7-
source_lang = en
87
type = QT
8+
minimum_perc = 60
9+
resource_name = keepassxc_en.ts (develop)
910
replace_edited_strings = false
1011
keep_translations = false
1112

1213
[o:keepassxc:p:keepassxc:r:share-translations-keepassxc-en-ts--master]
1314
file_filter = share/translations/keepassxc_<lang>.ts
1415
source_file = share/translations/keepassxc_en.ts
15-
source_lang = en
1616
type = QT
17+
minimum_perc = 60
18+
resource_name = keepassxc_en.ts (2.7.x stable)
1719
replace_edited_strings = false
1820
keep_translations = false
1921

release-tool.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def format(self, record):
111111
def _get_bin_path(build_dir=None):
112112
if not build_dir:
113113
return os.getenv('PATH')
114-
build_dir = Path(build_dir)
114+
build_dir = Path(build_dir).absolute()
115115
path_sep = ';' if sys.platform == 'win32' else ':'
116116
return path_sep.join(list(map(str, build_dir.rglob('vcpkg_installed/*/tools/**/bin'))) + [os.getenv('PATH')])
117117

@@ -152,6 +152,10 @@ def _run(cmd, *args, cwd, path=None, env=None, input=None, capture_output=True,
152152
env['PATH'] = path
153153
if _term_colors_on():
154154
env['FORCE_COLOR'] = '1'
155+
156+
# Windows needs shell=True if env or path is modified
157+
if sys.platform == 'win32' and (env or path):
158+
run_kwargs['shell'] = True
155159

156160
if docker_image:
157161
docker_cmd = ['docker', 'run', '--rm', '--tty=true', f'--workdir={cwd}', f'--user={os.getuid()}:{os.getgid()}']
@@ -209,8 +213,8 @@ def _git_get_branch(*, cwd):
209213

210214
def _git_branches_related(branch1, branch2, *, cwd):
211215
"""Check whether branch is ancestor or descendant of another."""
212-
return (_run(['git', 'merge-base', '--is-ancestor', branch1, branch2], cwd=cwd).returncode == 0 or
213-
_run(['git', 'merge-base', '--is-ancestor', branch2, branch1], cwd=cwd).returncode == 0)
216+
return (_run(['git', 'merge-base', '--is-ancestor', branch1, branch2], cwd=cwd, check=False).returncode == 0 or
217+
_run(['git', 'merge-base', '--is-ancestor', branch2, branch1], cwd=cwd, check=False).returncode == 0)
214218

215219

216220
_GIT_ORIG_BRANCH_CWD = None
@@ -443,10 +447,12 @@ def check_app_stream_info(version, cwd):
443447
appstream = Path(cwd) / appstream
444448
if not appstream.is_file():
445449
raise Error('File not found: %s', appstream)
446-
major, minor, patch = _split_version(version)
447-
if not re.search(rf'^\s*<release version="{major}\.{minor}\.{patch}" date=".+?">',
448-
appstream.read_text(), re.MULTILINE):
449-
raise Error(f'{appstream} has not been updated to the "%s" release.', version)
450+
regex = re.compile(rf'^\s*<release version="{version}" date=".+?">')
451+
with appstream.open('r', encoding='utf-8') as f:
452+
for line in f:
453+
if regex.search(line):
454+
return
455+
raise Error(f'{appstream} has not been updated to the "%s" release.', version)
450456

451457
@staticmethod
452458
def check_git():
@@ -682,15 +688,14 @@ def build_windows(self, version, src_dir, output_dir, *, parallelism, cmake_opts
682688

683689
# Start the build
684690
with tempfile.TemporaryDirectory() as build_dir:
685-
# NOTE: Shell must be True on Windows to run the command in the provided vs_env
686691
logger.info('Configuring build...')
687-
_run(['cmake', *cmake_opts, str(src_dir)], cwd=build_dir, env=vs_env, shell=True, capture_output=False)
692+
_run(['cmake', *cmake_opts, str(src_dir)], cwd=build_dir, env=vs_env, capture_output=False)
688693

689694
logger.info('Compiling sources...')
690-
_run(['cmake', '--build', '.', f'--parallel', str(parallelism)], cwd=build_dir, env=vs_env, shell=True, capture_output=False)
695+
_run(['cmake', '--build', '.', f'--parallel', str(parallelism)], cwd=build_dir, env=vs_env, capture_output=False)
691696

692697
logger.info('Packaging application...')
693-
_run(['cpack', '-G', 'ZIP;WIX'], cwd=build_dir, env=vs_env, shell=True, capture_output=False)
698+
_run(['cpack', '-G', 'ZIP;WIX'], cwd=build_dir, env=vs_env, capture_output=False)
694699

695700
output_files = list(Path(build_dir).glob("*.zip")) + list(Path(build_dir).glob("*.msi"))
696701
for output_file in output_files:
@@ -1092,7 +1097,6 @@ def run(self, subcmd, src_dir, branch, **kwargs):
10921097
self.check_transifex_config_exists(src_dir)
10931098

10941099
kwargs['resource'] = self.derive_resource_name(kwargs['resource'], cwd=src_dir)
1095-
kwargs['resource'] = self.TRANSIFEX_RESOURCE.format(kwargs['resource'])
10961100
kwargs['tx_args'] = kwargs['tx_args'][1:]
10971101
if subcmd == 'tx-push':
10981102
self.run_tx_push(src_dir, **kwargs)

0 commit comments

Comments
 (0)