ae-shell 0.3.4__tar.gz → 0.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.57 -->
1
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.58 -->
2
2
  ### GNU GENERAL PUBLIC LICENSE
3
3
 
4
4
  Version 3, 29 June 2007
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ae_shell
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: ae namespace module portion shell: shell execution and environment helpers
5
5
  Home-page: https://gitlab.com/ae-group/ae_shell
6
6
  Author: AndiEcker
@@ -63,15 +63,15 @@ Dynamic: provides-extra
63
63
  Dynamic: requires-python
64
64
  Dynamic: summary
65
65
 
66
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.97 -->
67
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.19 -->
68
- # shell 0.3.4
66
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.101 -->
67
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.22 -->
68
+ # shell 0.3.6
69
69
 
70
70
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/develop?logo=python)](
71
71
  https://gitlab.com/ae-group/ae_shell)
72
72
  [![LatestPyPIrelease](
73
- https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.4?logo=python)](
74
- https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.4)
73
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.6?logo=python)](
74
+ https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.6)
75
75
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_shell)](
76
76
  https://pypi.org/project/ae-shell/#history)
77
77
 
@@ -1,12 +1,12 @@
1
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.97 -->
2
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.19 -->
3
- # shell 0.3.4
1
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.101 -->
2
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.22 -->
3
+ # shell 0.3.6
4
4
 
5
5
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/develop?logo=python)](
6
6
  https://gitlab.com/ae-group/ae_shell)
7
7
  [![LatestPyPIrelease](
8
- https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.4?logo=python)](
9
- https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.4)
8
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.6?logo=python)](
9
+ https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.6)
10
10
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_shell)](
11
11
  https://pypi.org/project/ae-shell/#history)
12
12
 
@@ -174,6 +174,7 @@ this section includes various other utility functions and classes.
174
174
  - :func:`get_main_app`: retrieves the main application instance, or a mock instance if one does not exist.
175
175
  - :func:`get_pypi_versions`: determines all available release versions of a package on PyPI.
176
176
  - :func:`hint`: provides a hint message based on the provided arguments.
177
+ - :func:`mask_token`: hide/mask tokens in a text block, to prevent to show them in logs or error messages.
177
178
  - :func:`prg_git_project_path`: determines the project root path from the current working directory.
178
179
 
179
180
  - :class:`MockedMainApp`: a mock class for a main application instance.
@@ -192,7 +193,7 @@ import tempfile
192
193
 
193
194
  from contextlib import contextmanager
194
195
  from urllib.parse import urlparse
195
- from typing import Optional, Iterator, Iterable, cast, Callable, Any, Union, MutableMapping
196
+ from typing import Any, Callable, Iterable, Iterator, MutableMapping, Optional, Union, cast, overload
196
197
 
197
198
  import requests
198
199
  from packaging.version import Version
@@ -204,7 +205,7 @@ from ae.core import main_app_instance
204
205
  from ae.console import MAIN_SECTION_NAME, ConsoleApp # type: ignore
205
206
 
206
207
 
207
- __version__ = '0.3.4'
208
+ __version__ = '0.3.6'
208
209
 
209
210
 
210
211
  COMMIT_MSG_FILE_NAME = '.commit_msg.txt' #: name of the file containing the commit message
@@ -1033,12 +1034,37 @@ def in_venv(name: str = "") -> Iterator[None]:
1033
1034
  activate_venv(old_venv)
1034
1035
 
1035
1036
 
1036
- def on_ci_host() -> bool:
1037
- """ check and return True if this tool is running on the GitLab/GitHub CI host/server.
1037
+ @overload
1038
+ def mask_token(text: str) -> str: ...
1038
1039
 
1039
- :return: True if running on CI host, else False
1040
+
1041
+ @overload
1042
+ def mask_token(text: list[str]) -> list[str]: ...
1043
+
1044
+
1045
+ def mask_token(text: Union[str, list[str]]) -> Union[str, list[str]]:
1046
+ """ hide most parts of any GitHub/GitHub tokens found in the specified text/-lines.
1047
+
1048
+ :param text: text block, specified either as str object or an iterable of str objects (lines),
1049
+ to detect tokens within, to hide/mask the most part of them.
1050
+ :return: text block with without the complete tokens.
1051
+
1052
+ .. note:: see also :func:`ae.base.mask_url` to hide passwords and tokens in URLs.
1040
1053
  """
1041
- return 'CI' in os.environ or 'CI_PROJECT_ID' in os.environ
1054
+ if is_str_arg := isinstance(text, str):
1055
+ lines = [text]
1056
+ else:
1057
+ lines = list(text) # copy to not change text list content
1058
+
1059
+ for tok_beg, tok_end in (('glpat-', '@gitlab.com'), ('ghp_', '@github.com')):
1060
+ for idx, line in enumerate(lines):
1061
+ while tok_beg in line: # hide the GitLab/GitHub private token, e.g. from git-push-urls with authentication
1062
+ start = line.index(tok_beg)
1063
+ end = line.index(tok_end, start)
1064
+ line = line[:start + 3] + "***-masked-token-***" + line[end - 3:]
1065
+ lines[idx] = line
1066
+
1067
+ return lines[0] if is_str_arg else lines
1042
1068
 
1043
1069
 
1044
1070
  def owner_project_from_url(remote_url: str) -> str:
@@ -1077,7 +1103,7 @@ def project_name_version(imp_or_pkg_name: str, packages_versions: Iterable[str])
1077
1103
 
1078
1104
 
1079
1105
  # pylint: disable-next=too-many-arguments,too-many-positional-arguments
1080
- def sh_exec(command_line: str, extra_args: Iterable = (), console_input: str = "",
1106
+ def sh_exec(command_line: str, extra_args: Iterable[str] = (), console_input: str = "",
1081
1107
  lines_output: Optional[list[str]] = None, main_app: Optional[Any] = None, shell: bool = False,
1082
1108
  env_vars: Optional[dict[str, str]] = None) -> int:
1083
1109
  """ execute command in the current working directory of the OS console/shell.
@@ -1101,7 +1127,7 @@ def sh_exec(command_line: str, extra_args: Iterable = (), console_input: str = "
1101
1127
  merge_err = bool(lines_output) # == -''- and len(lines_output) > 0
1102
1128
  print_out = main_app.po if main_app else print if main_app is None else dummy_function
1103
1129
  debug_out = main_app.dpo if main_app else dummy_function
1104
- debug_out(f" . executing at {os.getcwd()}: {args}")
1130
+ debug_out(f" . executing at {os.getcwd()}: {mask_token(args)}")
1105
1131
 
1106
1132
  result: Union[subprocess.CompletedProcess, subprocess.CalledProcessError] # having: stdout/stderr/returncode
1107
1133
  try:
@@ -1113,10 +1139,10 @@ def sh_exec(command_line: str, extra_args: Iterable = (), console_input: str = "
1113
1139
  shell=shell,
1114
1140
  env=env_vars)
1115
1141
  except subprocess.CalledProcessError as ex: # pragma: no cover
1116
- debug_out(f"**** subprocess.run({args=}) returned non-zero exit code {ex.returncode}; {ex=}")
1142
+ debug_out(f"**** subprocess.run({mask_token(args)}) returned non-zero exit code {ex.returncode}; {ex=}")
1117
1143
  result = ex
1118
1144
  except Exception as ex: # pylint: disable=broad-except # pragma: no cover
1119
- print_out(f"**** subprocess.run({args}) raised exception {ex}")
1145
+ print_out(f"**** subprocess.run({mask_token(args)}) raised exception {ex}")
1120
1146
  return 126
1121
1147
 
1122
1148
  if ret_out:
@@ -1133,7 +1159,7 @@ def sh_exec(command_line: str, extra_args: Iterable = (), console_input: str = "
1133
1159
 
1134
1160
  # pylint: disable-next=too-many-arguments,too-many-positional-arguments
1135
1161
  def sh_exit_if_exec_err(err_code: int, command_line: str,
1136
- extra_args: Iterable = (), lines_output: Optional[list[str]] = None,
1162
+ extra_args: Iterable[str] = (), lines_output: Optional[list[str]] = None,
1137
1163
  exit_on_err: bool = True, exit_msg: str = "", shell: bool = False,
1138
1164
  env_vars: Optional[dict[str, str]] = None) -> int:
1139
1165
  """ execute command in the current working directory of the OS console/shell, dump error, and exit app if needed.
@@ -1168,19 +1194,19 @@ def sh_exit_if_exec_err(err_code: int, command_line: str,
1168
1194
  main_app.po(" " * 6 + line)
1169
1195
  msg = f"command: {command_line} " + " ".join('"' + arg + '"' if " " in arg else arg for arg in extra_args)
1170
1196
  if not sh_err:
1171
- main_app.dpo(f" = successfully executed {msg}")
1197
+ main_app.dpo(f" = successfully executed {mask_token(msg)}")
1172
1198
  else:
1173
1199
  if exit_msg:
1174
1200
  main_app.po(f" {exit_msg}")
1175
- check_if(err_code, not exit_on_err, f"sh_exit_if_exec_err error {sh_err} in {msg}") # app exit
1201
+ check_if(err_code, not exit_on_err, f"sh_exit_if_exec_err error {sh_err} in {mask_token(msg)}") # app exit
1176
1202
 
1177
1203
  return sh_err
1178
1204
 
1179
1205
 
1180
1206
  # pylint: disable-next=too-many-arguments,too-many-positional-arguments,too-many-locals
1181
1207
  def sh_exit_if_git_err(err_code: int, command_line: str,
1182
- extra_args: Iterable = (), lines_output: Optional[list[str]] = None, exit_on_err: bool = False,
1183
- log_enable_dir: str = "") -> list[str]:
1208
+ extra_args: Iterable[str] = (), lines_output: Optional[list[str]] = None,
1209
+ exit_on_err: bool = False, log_enable_dir: str = "") -> list[str]:
1184
1210
  """ execute git command with optional git trace output, returning the stdout lines cleaned from any trace messages.
1185
1211
 
1186
1212
  :param err_code: error code to pass to the console as exit code if :paramref:`.exit_on_err` is True.
@@ -1219,8 +1245,9 @@ def sh_exit_if_git_err(err_code: int, command_line: str,
1219
1245
  sh_log(command_line, extra_args=extra_args, cl_err=cl_err, lines_output=lines_output, log_file_paths=log_files)
1220
1246
 
1221
1247
  if cl_err: # if cl_err and exit_on_err then it would have exit the Python interpreter (so never would run to here)
1222
- main_app.vpo(f" # ignored error {cl_err} of {command_line=} with {extra_args=} and git trace {env_vars=}")
1223
- lines_output.insert(0, EXEC_GIT_ERR_PREFIX + str(cl_err) + f" in {command_line=} with {extra_args=}")
1248
+ cmd_line = mask_token([command_line] + list(extra_args))
1249
+ main_app.vpo(f" # ignored error {cl_err} of `{cmd_line}` and git trace {env_vars=}")
1250
+ lines_output.insert(0, EXEC_GIT_ERR_PREFIX + str(cl_err) + f" in {cmd_line}")
1224
1251
 
1225
1252
  if STDERR_BEG_MARKER in lines_output and ( # output marker only if stderr not got merged/called w/ lines_output==[]
1226
1253
  git_debug or any(os.environ.get(_, "0") in ("true", "1", "2") for _ in git_trace_vars)):
@@ -1232,7 +1259,7 @@ def sh_exit_if_git_err(err_code: int, command_line: str,
1232
1259
  main_app.po(sep + lines_output[line_no])
1233
1260
  lines_output[:] = lines_output[:start] # del output[start:]
1234
1261
 
1235
- return lines_output
1262
+ return list(mask_token(lines_output))
1236
1263
 
1237
1264
 
1238
1265
  # pylint: disable-next=too-many-arguments,too-many-positional-arguments
@@ -1258,11 +1285,7 @@ def sh_log(comment_or_command: str, extra_args: Iterable[str] = (), cl_err: int
1258
1285
  (f" * {cl_err=}" + sep if cl_err else "") +
1259
1286
  (" " + (sep + " ").join(lines_output) + sep if lines_output else ""))
1260
1287
 
1261
- for tok_beg, tok_end in (('glpat-', '@gitlab.com'), ('ghp_', '@github.com')):
1262
- while tok_beg in log_lines: # hide the gitlab private token, e.g. from git-push-urls with authentication
1263
- start = log_lines.index(tok_beg)
1264
- end = log_lines.index(tok_end, start)
1265
- log_lines = log_lines[:start] + "private-token-" + log_lines[end - 3:]
1288
+ log_lines = mask_token(log_lines)
1266
1289
 
1267
1290
  for log_path in log_file_paths or sh_logs(log_name_prefix=log_name_prefix):
1268
1291
  write_file(log_path, log_lines, extra_mode='a')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ae_shell
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: ae namespace module portion shell: shell execution and environment helpers
5
5
  Home-page: https://gitlab.com/ae-group/ae_shell
6
6
  Author: AndiEcker
@@ -63,15 +63,15 @@ Dynamic: provides-extra
63
63
  Dynamic: requires-python
64
64
  Dynamic: summary
65
65
 
66
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.97 -->
67
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.19 -->
68
- # shell 0.3.4
66
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.101 -->
67
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.22 -->
68
+ # shell 0.3.6
69
69
 
70
70
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/develop?logo=python)](
71
71
  https://gitlab.com/ae-group/ae_shell)
72
72
  [![LatestPyPIrelease](
73
- https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.4?logo=python)](
74
- https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.4)
73
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.6?logo=python)](
74
+ https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.6)
75
75
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_shell)](
76
76
  https://pypi.org/project/ae-shell/#history)
77
77
 
@@ -1,4 +1,4 @@
1
- # THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.57
1
+ # THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.58
2
2
  [build-system]
3
3
  requires = ["setuptools>=42", "wheel"]
4
4
  build-backend = "setuptools.build_meta"
@@ -1,4 +1,4 @@
1
- # THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.57
1
+ # THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.58
2
2
  """ setup of ae namespace module portion shell: shell execution and environment helpers. """
3
3
  # noinspection PyUnresolvedReferences
4
4
  import sys
@@ -23,15 +23,15 @@ setup_kwargs = {
23
23
  'install_requires': [],
24
24
  'keywords': ['configuration', 'development', 'environment', 'productivity'],
25
25
  'license': 'GPL-3.0-or-later',
26
- 'long_description': ('<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.97 -->\n'
27
- '<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.19 -->\n'
28
- '# shell 0.3.4\n'
26
+ 'long_description': ('<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.101 -->\n'
27
+ '<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.22 -->\n'
28
+ '# shell 0.3.6\n'
29
29
  '\n'
30
30
  '[![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/develop?logo=python)](\n'
31
31
  ' https://gitlab.com/ae-group/ae_shell)\n'
32
32
  '[![LatestPyPIrelease](\n'
33
- ' https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.4?logo=python)](\n'
34
- ' https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.4)\n'
33
+ ' https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.6?logo=python)](\n'
34
+ ' https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.6)\n'
35
35
  '[![PyPIVersions](https://img.shields.io/pypi/v/ae_shell)](\n'
36
36
  ' https://pypi.org/project/ae-shell/#history)\n'
37
37
  '\n'
@@ -108,7 +108,7 @@ setup_kwargs = {
108
108
  'Source': 'https://ae.readthedocs.io/en/latest/_modules/ae/shell.html'},
109
109
  'python_requires': '>=3.9',
110
110
  'url': 'https://gitlab.com/ae-group/ae_shell',
111
- 'version': '0.3.4',
111
+ 'version': '0.3.6',
112
112
  'zip_safe': True,
113
113
  }
114
114
 
@@ -18,7 +18,7 @@ from tests.conftest import skip_gitlab_ci
18
18
 
19
19
  from ae.base import (
20
20
  DEF_PROJECT_PARENT_FOLDER, PY_CACHE_FOLDER,
21
- camel_to_snake, in_wd, load_dotenvs, load_env_var_defaults, norm_name, norm_path,
21
+ camel_to_snake, in_wd, load_dotenvs, load_env_var_defaults, norm_name, norm_path, on_ci_host,
22
22
  os_path_basename, os_path_dirname, os_path_isdir, os_path_isfile, os_path_join, os_path_relpath,
23
23
  project_main_file, read_file, write_file, UNSET)
24
24
  from ae.core import DEBUG_LEVEL_DISABLED, DEBUG_LEVEL_ENABLED, DEBUG_LEVEL_VERBOSE
@@ -39,7 +39,7 @@ from ae.shell import (
39
39
  git_current_branch, git_diff, git_fetch, git_init_if_needed, git_merge, git_push,
40
40
  git_remote_domain_group, git_remotes, git_renew_remotes, git_status,
41
41
  git_tag_add, git_ref_in_branch, git_tag_list, git_tag_remotes, git_uncommitted,
42
- hint, in_os_env, in_prj_dir_venv, in_venv, on_ci_host, owner_project_from_url, project_name_version,
42
+ hint, in_os_env, in_prj_dir_venv, in_venv, mask_token, owner_project_from_url, project_name_version,
43
43
  sh_exec, sh_exit_if_exec_err, sh_exit_if_git_err, sh_log, sh_logs,
44
44
  temp_context_cleanup, temp_context_folders, temp_context_get_or_create, _temp_folders, venv_bin_path,
45
45
  MockedMainApp)
@@ -465,90 +465,45 @@ class TestGitCommands:
465
465
 
466
466
  @skip_gitlab_ci
467
467
  def test_git_branch_files_between_versions(self):
468
- prj_path = norm_path("../aedev_git_repo_manager") # ?!?!? CHANGE to pjm after switch: prj_path->"" version..v
469
- exp = last_exp = {
470
- 'README.md',
471
- 'aedev/git_repo_manager.py',
472
- 'tests/test_git_repo_manager.py',
473
- }
474
-
475
- assert git_branch_files(prj_path, branch_or_tag="v0.3.59..v0.3.60") == exp
476
-
477
- extra_61 = {'requirements.txt'}
478
- exp = extra_61 | {
479
- 'README.md',
480
- 'aedev/git_repo_manager.py',
481
- }
482
-
483
- assert git_branch_files(prj_path, branch_or_tag="v0.3.60..v0.3.61") == exp
484
-
485
- assert git_branch_files(prj_path, branch_or_tag="v0.3.59..v0.3.61") == exp | last_exp
486
-
468
+ prj_path = norm_path("../ae_base")
487
469
  exp = {
488
470
  'README.md',
489
- 'aedev/git_repo_manager/__init__.py',
490
- 'aedev/git_repo_manager/__main__.py',
491
- 'tests/test_git_repo_manager.py',
471
+ 'ae/base.py',
472
+ 'setup.py',
473
+ 'tests/test_base.py',
492
474
  }
493
475
 
494
- assert git_branch_files(prj_path, branch_or_tag="v0.3.65..v0.3.66") == exp
476
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.69..v0.3.70") == exp
477
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.70..v0.3.71") == exp
478
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.71..v0.3.72") == exp
479
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.69..v0.3.72") == exp
480
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.69..v0.3.71") == exp
481
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.70..v0.3.72") == exp
495
482
 
496
- assert git_branch_files(prj_path, branch_or_tag="v0.3.65...v0.3.66") == exp
497
-
498
- most = git_branch_files(prj_path, branch_or_tag="v0.3.65...v0.3.66", untracked=True,
499
- skip_file_path=lambda _:
500
- PY_CACHE_FOLDER in _
501
- or _.startswith(".idea")
502
- or _.startswith(".mypy_cache")
503
- or _.startswith(".pylint")
504
- or _.startswith(".pytest_cache")
505
- or _.startswith("htmlcov")
506
- or _.startswith("mypy_report")
507
- or _.startswith("aedev_git_repo_manager.egg-info")
508
- )
509
- assert all(_ in most for _ in exp)
510
-
511
- exp = big_exp = {
483
+ exp = {
512
484
  '.gitignore',
513
485
  '.gitlab-ci.yml',
514
486
  'CONTRIBUTING.rst',
515
487
  'LICENSE.md',
516
488
  'README.md',
517
489
  'SECURITY.md',
518
- 'aedev/git_repo_manager/__init__.py',
519
- 'aedev/git_repo_manager/__main__.py',
490
+ 'ae/base.py',
520
491
  'dev_requirements.txt',
521
492
  'setup.py',
522
493
  'tests/conftest.py',
523
494
  'tests/requirements.txt',
495
+ 'tests/test_base.py',
524
496
  }
525
497
 
526
- assert git_branch_files(prj_path, branch_or_tag="v0.3.66..v0.3.67") == exp
527
-
528
- assert git_branch_files(prj_path, branch_or_tag="v0.3.66...v0.3.67") == exp
529
-
530
- extra_62 = {'pev.updates', 'tests/test_git_repo_manager.py'}
531
-
532
- assert git_branch_files(prj_path, branch_or_tag="v0.3.61...v0.3.62") == exp | extra_62 # pkg __init__/__main__
533
-
534
- assert git_branch_files(prj_path, branch_or_tag="v0.3.62...v0.3.63") == exp # changed in v0.3.63
535
-
536
- assert git_branch_files(prj_path, branch_or_tag="v0.3.66...v0.3.69") == exp # 3 versions
537
-
538
- exp = {
539
- 'README.md',
540
- 'aedev/git_repo_manager/__init__.py',
541
- 'aedev/git_repo_manager/__main__.py',
542
- }
543
- assert git_branch_files(prj_path, branch_or_tag="v0.3.67..v0.3.68") == exp
544
-
545
- assert git_branch_files(prj_path, branch_or_tag="v0.3.67..v0.3.68") == exp
546
-
547
- assert git_branch_files(prj_path, branch_or_tag="v0.3.68..v0.3.69") == exp
548
-
549
- assert git_branch_files(prj_path, branch_or_tag="v0.3.68...v0.3.69") == exp
498
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.64..v0.3.65") == exp
499
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.65..v0.3.66") == exp
500
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.66..v0.3.67") == exp | {'pyproject.toml'}
501
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.67..v0.3.68") == exp | {'pyproject.toml'}
502
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.68..v0.3.69") == (
503
+ exp | {'pyproject.toml'}) - {'tests/test_base.py'}
550
504
 
551
- assert git_branch_files(prj_path, branch_or_tag="v0.3.59...v0.3.69") == extra_61 | extra_62 | big_exp
505
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.64..v0.3.69") == exp | {'pyproject.toml'}
506
+ assert git_branch_files(prj_path, branch_or_tag="v0.3.64..v0.3.72") == exp | {'pyproject.toml'}
552
507
 
553
508
  def test_git_branch_files_excludes(self, changed_repo_path):
554
509
  assert git_branch_files(changed_repo_path) == {'ChangeD.y', 'deleteD.x', 'rename.it'}
@@ -1497,26 +1452,18 @@ class TestHelpers:
1497
1452
  assert not hint("hint command", _hint_tst_callable, "extra message")
1498
1453
  assert not hint("hint command", _hint_tst_callable.__name__, "extra message")
1499
1454
 
1500
- @skip_gitlab_ci
1501
- def test_on_ci_host_local(self):
1502
- assert not on_ci_host()
1455
+ def test_mask_token(self):
1456
+ token = "glpat-gitlab token format ending with an @/ampersand and the gitlab.com domain"
1457
+ text = "a text block containing a gitlab URL with a token: https://UsaNäm:" + token + "@gitlab.com"
1503
1458
 
1504
- def test_on_ci_host_on_gitlab(self):
1505
- assert on_ci_host() == ('CI_PROJECT_ID' in os.environ)
1459
+ assert token not in mask_token(text)
1460
+ assert token not in mask_token([text])[0]
1506
1461
 
1507
- @skip_gitlab_ci
1508
- def test_on_ci_host_with_ci_var(self, monkeypatch):
1509
- assert not on_ci_host()
1510
-
1511
- monkeypatch.setenv('CI', "any value")
1512
- assert on_ci_host()
1513
-
1514
- @skip_gitlab_ci
1515
- def test_on_ci_host_with_ci_project_id(self, monkeypatch):
1516
- assert not on_ci_host()
1462
+ token = "ghp_-github token format ending with an @/ampersand and the github.com domain"
1463
+ text = "a text block containing a github URL with a token: https://YouSaNem:" + token + "@github.com"
1517
1464
 
1518
- monkeypatch.setenv('CI_PROJECT_ID', "any value")
1519
- assert on_ci_host()
1465
+ assert token not in mask_token(text)
1466
+ assert token not in mask_token([text])[0]
1520
1467
 
1521
1468
  def test_owner_project_from_url(self):
1522
1469
  assert owner_project_from_url("owner/project") == "owner/project"
File without changes