[Diff][Fixed] Assumption that all tags are in the trunk
- As stated by @matthijskooijman in 91ffb04661c40102bfb856669039f0825ecc6883#r113724588 comment using --tags isn't necessary and includes *all* tags - The code also assumed nothing was added before the "tag: " label, but this isn't true if the HEAD is tagged.
This commit is contained in:
parent
8eabeafd95
commit
e7cde1164c
|
|
@ -254,21 +254,22 @@ class DiffOptions(BaseOptions):
|
||||||
def process_tags(self, num):
|
def process_tags(self, num):
|
||||||
# Get a list of all tags ... and commits (how can I filter it?)
|
# Get a list of all tags ... and commits (how can I filter it?)
|
||||||
logger.debug('Looking for git tags')
|
logger.debug('Looking for git tags')
|
||||||
res = self.run_git(['rev-list', '--tags', '--format=format:%D'])
|
res = self.run_git(['rev-list', '--format=format:%D', 'HEAD'])
|
||||||
if not res:
|
if not res:
|
||||||
return res
|
return res
|
||||||
res = res.split('\n')
|
res = res.split('\n')
|
||||||
commit = ''
|
commit = ''
|
||||||
skipped = 0
|
skipped = 0
|
||||||
for v in res:
|
for v in res:
|
||||||
if v.startswith('tag: '):
|
try:
|
||||||
tag = v.split(',')[0][4:]
|
tag = v[v.index('tag: '):].split(',')[0][4:]
|
||||||
logger.debugl(2, '- {}/{} tag: {} -> {}'.format(skipped, num, tag, commit))
|
logger.debugl(2, '- {}/{} tag: {} -> {}'.format(skipped, num, tag, commit))
|
||||||
if skipped == num:
|
if skipped == num:
|
||||||
return commit
|
return commit
|
||||||
skipped += 1
|
skipped += 1
|
||||||
elif v.startswith('commit '):
|
except ValueError:
|
||||||
commit = v[7:]
|
if v.startswith('commit '):
|
||||||
|
commit = v[7:]
|
||||||
|
|
||||||
def solve_kibot_magic(self, name, tag):
|
def solve_kibot_magic(self, name, tag):
|
||||||
# The magic KIBOT_*
|
# The magic KIBOT_*
|
||||||
|
|
|
||||||
|
|
@ -1479,6 +1479,54 @@ def test_diff_git_4(test_dir):
|
||||||
ctx.clean_up(keep_project=True)
|
ctx.clean_up(keep_project=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_diff_git_5(test_dir):
|
||||||
|
""" Difference between the two repo points, using tags """
|
||||||
|
prj = 'light_control'
|
||||||
|
yaml = 'diff_git_5'
|
||||||
|
ctx = context.TestContext(test_dir, prj, yaml)
|
||||||
|
# Create a git repo
|
||||||
|
git_init(ctx)
|
||||||
|
# Copy the "old" file
|
||||||
|
pcb = prj+'.kicad_pcb'
|
||||||
|
file = ctx.get_out_path(pcb)
|
||||||
|
shutil.copy2(ctx.board_file, file)
|
||||||
|
shutil.copy2(ctx.board_file.replace('.kicad_pcb', context.KICAD_SCH_EXT),
|
||||||
|
file.replace('.kicad_pcb', context.KICAD_SCH_EXT))
|
||||||
|
# Add it to the repo
|
||||||
|
ctx.run_command(['git', 'add', pcb], chdir_out=True)
|
||||||
|
ctx.run_command(['git', 'commit', '-m', 'Reference'], chdir_out=True)
|
||||||
|
# Tag it (this will be our target)
|
||||||
|
ctx.run_command(['git', 'tag', '-a', 't1', '-m', 't1'], chdir_out=True)
|
||||||
|
# Add an extra commit
|
||||||
|
dummy = ctx.get_out_path('dummy')
|
||||||
|
with open(dummy, 'wt') as f:
|
||||||
|
f.write('dummy\n')
|
||||||
|
ctx.run_command(['git', 'add', 'dummy'], chdir_out=True)
|
||||||
|
ctx.run_command(['git', 'commit', '-m', 'Dummy noise'], chdir_out=True)
|
||||||
|
# Add a noisy branch
|
||||||
|
ctx.run_command(['git', 'switch', '-c', 'a_branch'], chdir_out=True)
|
||||||
|
# Copy the "new" file
|
||||||
|
with open(file, 'wt') as f:
|
||||||
|
f.write('broken\n')
|
||||||
|
# Add it to the repo
|
||||||
|
ctx.run_command(['git', 'commit', '-a', '-m', 'New version'], chdir_out=True)
|
||||||
|
# Tag it (this shouldn't be a problem)
|
||||||
|
ctx.run_command(['git', 'tag', '-a', 't2', '-m', 't2'], chdir_out=True)
|
||||||
|
# Back to the master
|
||||||
|
ctx.run_command(['git', 'checkout', 'master'], chdir_out=True)
|
||||||
|
# Copy the "new" file
|
||||||
|
shutil.copy2(ctx.board_file.replace(prj, prj+'_diff'), file)
|
||||||
|
# Add it to the repo
|
||||||
|
ctx.run_command(['git', 'add', pcb], chdir_out=True)
|
||||||
|
ctx.run_command(['git', 'commit', '-m', 'New version'], chdir_out=True)
|
||||||
|
# Tag it (this shouldn't be a problem)
|
||||||
|
ctx.run_command(['git', 'tag', '-a', 't3', '-m', 't3'], chdir_out=True)
|
||||||
|
# Run the test
|
||||||
|
ctx.run(extra=['-b', file], no_board_file=True, extra_debug=True)
|
||||||
|
ctx.compare_pdf(prj+'-diff_pcb.pdf', off_y=OFFSET_Y, tol=DIFF_TOL)
|
||||||
|
ctx.clean_up(keep_project=True)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.slow
|
||||||
@pytest.mark.eeschema
|
@pytest.mark.eeschema
|
||||||
def test_diff_file_sch_1(test_dir):
|
def test_diff_file_sch_1(test_dir):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue