pullup 0.0.13__tar.gz → 0.0.14__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,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pullup
3
- Version: 0.0.13
3
+ Version: 0.0.14
4
4
  Summary: build, release, and deploy projects
5
5
  Project-URL: Repository, https://github.com/vedicreader/pullup
6
6
  Project-URL: Documentation, https://vedicreader.github.io/pullup
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.13"
1
+ __version__ = "0.0.14"
2
2
 
3
3
  # The names a caller reaches for. The modules stay importable for everything else.
4
4
  from .env import EnvError, EnvStore, venv_env
@@ -100,7 +100,9 @@ d = { 'settings': { 'branch': 'main',
100
100
  'pullup.pipeline.notes_step': ('pipeline.html#notes_step', 'pullup/pipeline.py'),
101
101
  'pullup.pipeline.project_version': ('pipeline.html#project_version', 'pullup/pipeline.py'),
102
102
  'pullup.pipeline.quiet': ('pipeline.html#quiet', 'pullup/pipeline.py'),
103
+ 'pullup.pipeline.release_cmd': ('pipeline.html#release_cmd', 'pullup/pipeline.py'),
103
104
  'pullup.pipeline.resolve_script': ('pipeline.html#resolve_script', 'pullup/pipeline.py'),
105
+ 'pullup.pipeline.tree_clean': ('pipeline.html#tree_clean', 'pullup/pipeline.py'),
104
106
  'pullup.pipeline.uv_argv': ('pipeline.html#uv_argv', 'pullup/pipeline.py'),
105
107
  'pullup.pipeline.write_changelog': ('pipeline.html#write_changelog', 'pullup/pipeline.py')},
106
108
  'pullup.project': { 'pullup.project.Project': ('project.html#project', 'pullup/project.py'),
@@ -2,7 +2,7 @@
2
2
 
3
3
  # %% ../nbs/02_pipeline.ipynb #d7426f18
4
4
  from __future__ import annotations
5
- import asyncio, json, os, re, shlex, time
5
+ import asyncio, json, os, re, shlex, subprocess, time
6
6
  from dataclasses import replace
7
7
  from shutil import which
8
8
  from fastcore.all import L, Path, first
@@ -12,9 +12,9 @@ from .env import EnvStore, venv_env
12
12
  from .project import Step, default_steps, release_flow, app_project, _toml
13
13
 
14
14
  # %% auto #0
15
- __all__ = ['SCROLLBACK', 'DIR', 'NOTES_CMDS', 'QUIET', 'MARKER', 'PipelineError', 'resolve_script', 'uv_argv', 'Pipeline',
16
- 'project_version', 'changelog_state', 'claim_unreleased', 'write_changelog', 'notes_step', 'quiet',
17
- 'Release']
15
+ __all__ = ['SCROLLBACK', 'DIR', 'NOTES_CMDS', 'QUIET', 'CLEAN_CMD', 'MARKER', 'PipelineError', 'resolve_script', 'uv_argv',
16
+ 'Pipeline', 'project_version', 'changelog_state', 'claim_unreleased', 'write_changelog', 'notes_step',
17
+ 'quiet', 'tree_clean', 'release_cmd', 'Release']
18
18
 
19
19
  # %% ../nbs/02_pipeline.ipynb #18ee2a74
20
20
  SCROLLBACK = 200_000
@@ -242,6 +242,7 @@ class Pipeline:
242
242
  # %% ../nbs/02_pipeline.ipynb #7a1bd528
243
243
  NOTES_CMDS = ('nbdev-release-gh', 'nbdev_release_gh')
244
244
  QUIET = '--no-changelog --no-editor --yes'
245
+ CLEAN_CMD = 'nbdev-release-git'
245
246
  MARKER = '<!-- do not remove -->\n'
246
247
 
247
248
  def project_version(root):
@@ -299,6 +300,16 @@ def quiet(cmd):
299
300
  "The nbdev release command with the flags that stop it asking for an editor or a yes."
300
301
  return f'{cmd.strip()} {QUIET}'
301
302
 
303
+ def tree_clean(root):
304
+ "Whether git has no tracked change for `nbdev-release-gh` to commit; a folder git cannot read counts as not clean."
305
+ try: r = subprocess.run(['git', 'status', '--porcelain', '--untracked-files=no'], cwd=str(root), capture_output=True, text=True, stdin=subprocess.DEVNULL)
306
+ except OSError: return False
307
+ return r.returncode == 0 and not r.stdout.strip()
308
+
309
+ def release_cmd(root, cmd):
310
+ "`nbdev-release-git` when there is nothing to commit, as `nbdev-release-gh` would stop there; else the quiet `cmd`."
311
+ return CLEAN_CMD if tree_clean(root) else quiet(cmd)
312
+
302
313
 
303
314
  # %% ../nbs/02_pipeline.ipynb #e22f9231
304
315
  class Release(Pipeline):
@@ -317,7 +328,7 @@ class Release(Pipeline):
317
328
  'fastship': flow == 'fastship', 'app': app_project(self.root),
318
329
  'notes': first((r['notes'] for r in st['steps'] if r['status'] == 'needs_notes'))}
319
330
  async def _run(self, step):
320
- "Run `step`; the bare nbdev release command runs quiet once the changelog has its entry, and otherwise waits for notes."
331
+ "Run `step`; the bare nbdev release command runs quiet once the changelog has its entry (as `nbdev-release-git` when the tree is clean), and otherwise waits for notes."
321
332
  if not notes_step(step): return await super()._run(step)
322
333
  st = changelog_state(self.root)
323
334
  if not st['has']:
@@ -326,5 +337,5 @@ class Release(Pipeline):
326
337
  self._broadcast(f"\r\n\x1b[33m{step.label} waits for release notes for {st['version'] or 'this version'}\x1b[0m\r\n".encode())
327
338
  return
328
339
  if st['kind'] == 'unreleased': claim_unreleased(self.root, st['version'])
329
- await super()._run(replace(step, cmd=quiet(step.cmd)))
340
+ await super()._run(replace(step, cmd=release_cmd(self.root, step.cmd)))
330
341
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes