moat-src 0.5.1__py3-none-any.whl → 0.6.0__py3-none-any.whl

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.
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ set -x
4
+ ## pre-commit hook to catch editing in "deb" branch without modifying the changelog
5
+ B="$(git rev-parse --abbrev-ref HEAD)"
6
+ if test "$B" = "deb" || test "$B" = "debian" ; then
7
+ S="$(git status -s -- debian/changelog | head -c2 | sed -e 's/ //g')"
8
+ if test "$S" != "A" && test "$S" != "M" ; then
9
+ echo "You can't commit to Debian without a changelog entry."
10
+ exit 1
11
+ fi
12
+ fi
moat/src/_main.py CHANGED
@@ -49,8 +49,12 @@ class Repo(git.Repo):
49
49
  try:
50
50
  res = self._subrepo_cache[r.path]
51
51
  except KeyError:
52
- p = Path(self.working_dir) / r.path
53
- self._subrepo_cache[r.path] = res = Repo(p)
52
+ try:
53
+ p = Path(self.working_dir) / r.path
54
+ self._subrepo_cache[r.path] = res = Repo(p)
55
+ except git.exc.InvalidGitRepositoryError:
56
+ logger.info("%s: invalid, skipping.", p)
57
+ continue
54
58
  res.submod = r
55
59
  if recurse:
56
60
  yield from res.subrepos(depth=depth)
@@ -265,6 +269,28 @@ def encomma(proj, path):
265
269
  """list > comma-delimited string"""
266
270
  _mangle(proj, path, lambda x: ",".join(x)) # pylint: disable=unnecessary-lambda
267
271
 
272
+ def apply_hooks(repo, force=False):
273
+ h = Path(repo.git_dir)/"hooks"
274
+ drop = set()
275
+ seen = set()
276
+ for f in h.iterdir():
277
+ if f.suffix == ".sample":
278
+ drop.add(f)
279
+ continue
280
+ seen.add(f.name)
281
+ for f in drop:
282
+ f.unlink()
283
+
284
+ pt = (Path(__file__).parent / "_hooks")
285
+ for f in pt.iterdir():
286
+ if not force:
287
+ if f.name in seen:
288
+ continue
289
+ t = h/f.name
290
+ d = f.read_text()
291
+ t.write_text(d)
292
+ t.chmod(0o755)
293
+
268
294
 
269
295
  def apply_templates(repo):
270
296
  """
@@ -429,6 +455,8 @@ By default, changes amend the HEAD commit if the text didn't change.
429
455
  @click.option("-D", "--no-dirty", is_flag=True, help="don't check for dirtiness (DANGER)")
430
456
  @click.option("-C", "--no-commit", is_flag=True, help="don't commit")
431
457
  @click.option("-s", "--skip", type=str, multiple=True, help="skip this repo")
458
+ @click.option("--hooks", is_flag=True, help="only update hooks")
459
+ @click.option("--HOOKS", "fhooks", is_flag=True, help="force-update hooks")
432
460
  @click.option(
433
461
  "-m",
434
462
  "--message",
@@ -437,7 +465,7 @@ By default, changes amend the HEAD commit if the text didn't change.
437
465
  default="Update from MoaT template",
438
466
  )
439
467
  @click.option("-o", "--only", type=str, multiple=True, help="affect only this repo")
440
- async def setup(no_dirty, no_commit, skip, only, message, amend, no_amend):
468
+ async def setup(no_dirty, no_commit, skip, only, message, amend, no_amend, hooks, fhooks):
441
469
  """
442
470
  Set up projects using templates.
443
471
 
@@ -451,6 +479,11 @@ async def setup(no_dirty, no_commit, skip, only, message, amend, no_amend):
451
479
  repos = (x for x in repo.subrepos(depth=True) if x.moat_name[5:] not in skip)
452
480
 
453
481
  for r in repos:
482
+ apply_hooks(r, fhooks)
483
+ if hooks or fhooks:
484
+ print(r.working_dir)
485
+ continue
486
+
454
487
  if not is_clean(r, not no_dirty):
455
488
  if not no_dirty:
456
489
  continue
@@ -459,7 +492,7 @@ async def setup(no_dirty, no_commit, skip, only, message, amend, no_amend):
459
492
  if proj.is_file():
460
493
  apply_templates(r)
461
494
  else:
462
- logger.info("%s: no pyproject.toml file. Skipping.")
495
+ logger.info("%s: no pyproject.toml file. Skipping.", r.working_dir)
463
496
  continue
464
497
 
465
498
  if no_commit:
@@ -797,5 +830,5 @@ async def build(version, no_test, no_commit, no_dirty, cache):
797
830
  add_repr(tomlkit.items.String)
798
831
  add_repr(tomlkit.items.Integer)
799
832
  add_repr(tomlkit.items.Bool, bool)
800
- add_repr(tomlkit.items.MutableMapping)
801
- add_repr(tomlkit.items.MutableSequence)
833
+ add_repr(tomlkit.items.AbstractTable)
834
+ add_repr(tomlkit.items.Array)
@@ -75,7 +75,7 @@ pytest:
75
75
  format:
76
76
  ${RQ} || black $(CODE) $(TESTS) $(SETUP)
77
77
  ${RQ} || python3 -misort $(CODE) $(TESTS) $(SETUP)
78
- ${RQ} && ruff format --check $(CODE) $(TESTS) $(SETUP)
78
+ ${RQ} && ruff format $(CODE) $(TESTS) $(SETUP)
79
79
  ${RQ} && ruff check --fix $(CODE) $(TESTS) $(SETUP)
80
80
 
81
81
  precommit: format test
moat/src/test.py CHANGED
@@ -53,10 +53,9 @@ async def run(*args, expect_exit=0, do_stdout=True):
53
53
  assert expect_exit == 0
54
54
  return res
55
55
  finally:
56
- if res is None:
57
- res = attrdict()
58
56
  if do_stdout:
59
- res.stdout = out.getvalue()
57
+ if res is not None:
58
+ res.stdout = out.getvalue()
60
59
  CFG["_stdout"] = sys.stdout
61
60
 
62
61
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: moat-src
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Summary: Tools for managing the MoaT sources
5
5
  Author-email: Matthias Urlichs <matthias@urlichs.de>
6
6
  Project-URL: homepage, https://m-o-a-t.org
@@ -19,5 +19,5 @@ Requires-Dist: anyio (~=3.0)
19
19
  Requires-Dist: asyncclick
20
20
  Requires-Dist: gitpython
21
21
  Requires-Dist: packaging
22
- Requires-Dist: tomlkit (~=0.11)
22
+ Requires-Dist: tomlkit (~=0.12)
23
23
 
@@ -1,16 +1,17 @@
1
1
  moat/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- moat/src/_main.py,sha256=F_lZOP0pTSD_iPb01LHfeyqaobPjpYkWxSKtJo_rqVI,24501
2
+ moat/src/_main.py,sha256=mIWguSJeHJtS46ndtWZCvHXIK34rXFZKTeRj35QdmnY,25486
3
3
  moat/src/inspect.py,sha256=Rb5x7Qgyb7W1UpGRTPMHB-XLy6J9yZ4Iw4sOhATrOHA,1452
4
- moat/src/test.py,sha256=VB0ZG5svsIJHGtANRYg9KIK4NQHDfkm25t7dJWgfTGc,2166
4
+ moat/src/test.py,sha256=7jOUUwgrbtPS3clwiUgf6sIS7Kb1Yv3XcpZc-hajBP0,2149
5
+ moat/src/_hooks/pre-commit,sha256=_2IeAh-Gq5YjHtA08TBYAMbrDslNSRue59a1Y6mykns,412
5
6
  moat/src/_templates/LICENSE.txt,sha256=X6cpfPmXmOftxOF5o9xedKUWPzU69OiCRrOW1CmRBjs,528
6
7
  moat/src/_templates/Makefile,sha256=fdTxSrMJbQO02XTRatmM-QA6iibYw_il4UrNff0Nkss,268
7
8
  moat/src/_templates/gitignore,sha256=F1dVTKg7mLHLp--Z-KBwU-HyyPOGm-uN0qfS_yK8vz0,436
8
9
  moat/src/_templates/pyproject.default.yaml,sha256=0ImapzFaJhs-dJXngnGpk--hPDeUAsDk_EXALWJBjvE,2665
9
10
  moat/src/_templates/pyproject.forced.yaml,sha256=djfcy3hgfoIgrn2pRrxDWTyN3EEsA1y5NhkzYrGjgNY,1427
10
11
  moat/src/_templates/test_basic_py,sha256=Lr5dq8C04DiRabA0rCURsZdcc2mVAUGPzjLU6iR8LTE,174
11
- moat/src/_templates/make/py,sha256=WAjOWpWaAM9v4oO4zmIaNZ8HdKf2ZvKiplyOxiaZLi0,2730
12
+ moat/src/_templates/make/py,sha256=UbEujNqUNcMTzPfO4nKkJtu6JfvyBnQBe6S-m-GFf3E,2722
12
13
  moat/src/_templates/moat/__init__.py,sha256=DDN1IA3oN2R1OTIhJCNOOSCpfbqXIByh2WUNYDFcuzw,105
13
- moat_src-0.5.1.dist-info/METADATA,sha256=VMRJarKiyjZRw1bb53mskCvU9YfvZ_nJCkIufVrU1x8,732
14
- moat_src-0.5.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
15
- moat_src-0.5.1.dist-info/top_level.txt,sha256=pcs9fl5w5AB5GVi4SvBqIVmFrkRwQkVw_dEvW0Q0cSA,5
16
- moat_src-0.5.1.dist-info/RECORD,,
14
+ moat_src-0.6.0.dist-info/METADATA,sha256=sBz66pkWn7Nkg1LyFHcbI9joQj-UXckP-wlWaJfBePU,732
15
+ moat_src-0.6.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
16
+ moat_src-0.6.0.dist-info/top_level.txt,sha256=pcs9fl5w5AB5GVi4SvBqIVmFrkRwQkVw_dEvW0Q0cSA,5
17
+ moat_src-0.6.0.dist-info/RECORD,,