[KiKit Present] Now using the detected git binary
- Also added repository URL detection
This commit is contained in:
parent
6b253d3c52
commit
ae450b15a4
|
|
@ -187,6 +187,7 @@ Notes:
|
|||
[**Git**](https://git-scm.com/) [](https://git-scm.com/) [](https://packages.debian.org/bullseye/git) 
|
||||
- Optional to:
|
||||
- Compare with files in the repo for `diff`
|
||||
- Find commit hash and/or date for `kikit_present`
|
||||
- Find commit hash and/or date for `pcb_replace`
|
||||
- Find commit hash and/or date for `sch_replace`
|
||||
- Find commit hash and/or date for `set_text_variables`
|
||||
|
|
@ -2474,6 +2475,8 @@ Notes:
|
|||
If empty we use the name of the KiCad project.
|
||||
The default template uses it for things like the page title.
|
||||
- `repository`: [string=''] URL of the repository. Will be passed to the template.
|
||||
If empty we will try to find it using `git remote get-url origin`.
|
||||
The default template uses it to create an URL for the current commit.
|
||||
- `resources`: [string|list(string)=''] A list of file name patterns for additional resources to be included.
|
||||
I.e. images referenced in description.
|
||||
They will be copied relative to the output dir.
|
||||
|
|
|
|||
|
|
@ -1251,7 +1251,9 @@ outputs:
|
|||
# If empty we use the name of the KiCad project.
|
||||
# The default template uses it for things like the page title
|
||||
name: ''
|
||||
# [string=''] URL of the repository. Will be passed to the template
|
||||
# [string=''] URL of the repository. Will be passed to the template.
|
||||
# If empty we will try to find it using `git remote get-url origin`.
|
||||
# The default template uses it to create an URL for the current commit
|
||||
repository: ''
|
||||
# [string|list(string)=''] A list of file name patterns for additional resources to be included.
|
||||
# I.e. images referenced in description.
|
||||
|
|
|
|||
|
|
@ -205,4 +205,4 @@ This file comes from KiKit, but it has too much in common with `populate.py`.
|
|||
So now the images and gerbers come from outside.
|
||||
- Adapted Template._renderBoards to just copy the files (keeping the extensions)
|
||||
- Added listResources, with some changes to copyRelativeTo and _copyResources
|
||||
|
||||
- The command used for git is now configurable
|
||||
|
|
|
|||
|
|
@ -137,7 +137,9 @@ class Template:
|
|||
"""
|
||||
Return a git revision string if in git repo, None otherwise
|
||||
"""
|
||||
proc = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True)
|
||||
if self.git_command is None:
|
||||
return None
|
||||
proc = subprocess.run([self.git_command, "rev-parse", "HEAD"], capture_output=True)
|
||||
if proc.returncode:
|
||||
return None
|
||||
return proc.stdout.decode("utf-8")
|
||||
|
|
@ -177,9 +179,10 @@ class HtmlTemplate(Template):
|
|||
with open(os.path.join(outputDirectory, "index.html"),"w") as outFile:
|
||||
outFile.write(content)
|
||||
|
||||
def boardpage(outdir, description, board, resource, template, repository, name):
|
||||
def boardpage(outdir, description, board, resource, template, repository, name, git_command):
|
||||
Path(outdir).mkdir(parents=True, exist_ok=True)
|
||||
template = readTemplate(template)
|
||||
template.git_command = git_command
|
||||
template.addDescriptionFile(description)
|
||||
template.setRepository(repository)
|
||||
template.setName(name)
|
||||
|
|
|
|||
|
|
@ -10,10 +10,13 @@ Dependencies:
|
|||
debian: python3-markdown2
|
||||
arch: python-markdown2
|
||||
role: mandatory
|
||||
- from: Git
|
||||
role: Find commit hash and/or date
|
||||
"""
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from tempfile import NamedTemporaryFile, TemporaryDirectory, mkdtemp
|
||||
from .error import KiPlotConfigurationError
|
||||
|
|
@ -293,12 +296,21 @@ class KiKit_PresentOptions(BaseOptions):
|
|||
""" Path to a template directory or a name of built-in one.
|
||||
See KiKit's doc/present.md for template specification """
|
||||
self.repository = ''
|
||||
""" URL of the repository. Will be passed to the template """
|
||||
""" URL of the repository. Will be passed to the template.
|
||||
If empty we will try to find it using `git remote get-url origin`.
|
||||
The default template uses it to create an URL for the current commit """
|
||||
self.name = ''
|
||||
""" Name of the project. Will be passed to the template.
|
||||
If empty we use the name of the KiCad project.
|
||||
The default template uses it for things like the page title """
|
||||
super().__init__()
|
||||
self._git_solved = False
|
||||
|
||||
def get_git_command(self):
|
||||
if not self._git_solved:
|
||||
self._git_command = self.check_tool('Git')
|
||||
self._git_solved = True
|
||||
return self._git_command
|
||||
|
||||
def config(self, parent):
|
||||
super().config(parent)
|
||||
|
|
@ -326,6 +338,12 @@ class KiKit_PresentOptions(BaseOptions):
|
|||
self.template = GS.get_resource_path(os.path.join('pcbdraw', 'present', 'templates', self.template))
|
||||
except SystemExit:
|
||||
raise KiPlotConfigurationError('Missing template `{}`'.format(self.template))
|
||||
# Repo URL
|
||||
if not self.repository and self.get_git_command():
|
||||
try:
|
||||
self.repository = run_command([self.get_git_command(), 'remote', 'get-url', 'origin'], just_raise=True)
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
|
||||
def get_targets(self, out_dir):
|
||||
# The web page
|
||||
|
|
@ -374,7 +392,8 @@ class KiKit_PresentOptions(BaseOptions):
|
|||
else:
|
||||
self._description = self.description
|
||||
try:
|
||||
boardpage(dir_name, self._description, board, self.resources, self.template, self.repository, self.name)
|
||||
boardpage(dir_name, self._description, board, self.resources, self.template, self.repository, self.name,
|
||||
self.get_git_command())
|
||||
except RuntimeError as e:
|
||||
raise KiPlotConfigurationError('KiKit present error: '+str(e))
|
||||
finally:
|
||||
|
|
@ -408,12 +427,14 @@ class KiKit_Present(BaseOutput):
|
|||
'back_image': 'renderer_for_present',
|
||||
'gerbers': 'gerbers_for_present'}}
|
||||
# Renderer
|
||||
renderer = BaseOutput.simple_conf_examples('pcbdraw', 'Renderer for the presentation', 'Presentation/Render')
|
||||
renderer = BaseOutput.simple_conf_examples('pcbdraw', 'Renderer for the presentation', 'Render_for_presentation')
|
||||
renderer[0]['name'] = 'renderer_for_present'
|
||||
renderer[0]['run_by_default'] = False
|
||||
outs.append(renderer[0])
|
||||
# Gerbers
|
||||
gerber = BaseOutput.simple_conf_examples('gerber', 'Gerbers for the presentation', 'Presentation/Gerber')
|
||||
gerber = BaseOutput.simple_conf_examples('gerber', 'Gerbers for the presentation', 'Gerber_for_presentation')
|
||||
gerber[0]['name'] = 'gerbers_for_present'
|
||||
gerber[0]['layers'] = 'copper'
|
||||
gerber[0]['run_by_default'] = False
|
||||
outs.append(gerber[0])
|
||||
return outs
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ deps = '{\
|
|||
"extra_arch": null,\
|
||||
"extra_deb": null,\
|
||||
"help_option": "--version",\
|
||||
"importance": 4,\
|
||||
"importance": 5,\
|
||||
"in_debian": true,\
|
||||
"is_kicad_plugin": false,\
|
||||
"is_python": false,\
|
||||
|
|
@ -121,6 +121,13 @@ deps = '{\
|
|||
"output": "diff",\
|
||||
"version": null\
|
||||
},\
|
||||
{\
|
||||
"desc": "Find commit hash and/or date",\
|
||||
"mandatory": false,\
|
||||
"max_version": null,\
|
||||
"output": "kikit_present",\
|
||||
"version": null\
|
||||
},\
|
||||
{\
|
||||
"desc": "Find commit hash and/or date",\
|
||||
"mandatory": false,\
|
||||
|
|
|
|||
Loading…
Reference in New Issue