Skip to content

Commit

Permalink
quick test for recording config history
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sasatani committed Dec 7, 2024
1 parent 3469bc7 commit 56dddc0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/history/config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
File Version Information
========================

- **sd-layout-battery.yaml**: Updated in `v0.5.0-17-g9d698e6`
- **sd-layout.yaml**: Updated in `v0.5.0-17-g9d698e6`
- **stream-buffer-header.yaml**: Updated in `v0.5.0-17-g9d698e6`
- **wireless-200px.yml**: Updated in `v0.5.0-17-g9d698e6`
38 changes: 38 additions & 0 deletions helper_scripts/config_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import subprocess
from pathlib import Path

def get_last_commit_id(file_path):
result = subprocess.run(
["git", "log", "-1", "--format=%H", "--", str(file_path)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True
)
return result.stdout.strip()

def get_version_from_commit(commit_id):
result = subprocess.run(
["git", "describe", "--tags", commit_id],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True
)
return result.stdout.strip()

def gen_rst(directory, output_file):
with open(output_file, 'w') as f:
f.write("Config History\n")
f.write("========================\n\n")
for file_path in Path(directory).rglob('*'):
if file_path.is_file():
commit_id = get_last_commit_id(file_path)
if commit_id:
version = get_version_from_commit(commit_id)
f.write(f"- **{file_path.name}**: Updated in `{version}`\n")

if __name__ == "__main__":
dir = "miniscope_io/data/config"
rst = "docs/history/config.rst"
gen_rst(dir, rst)
14 changes: 14 additions & 0 deletions miniscope_io/data/config/wireless/sample_made_in_this_branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
id: stream-buffer-header
mio_model: miniscope_io.models.stream.StreamBufferHeaderFormat
mio_version: "v5.0.0"
linked_list: 0
frame_num: 1
buffer_count: 2
frame_buffer_count: 3
write_buffer_count: 4
dropped_buffer_count: 5
timestamp: 6
write_timestamp: 8
pixel_count: 7
battery_voltage_raw: 9
input_voltage_raw: 10

0 comments on commit 56dddc0

Please sign in to comment.