[Diff] Added option to force the checkouts
This commit is contained in:
parent
a4abb65ef3
commit
e34d4a01e0
|
|
@ -1487,7 +1487,8 @@ Notes:
|
|||
|
||||
* Diff
|
||||
* Type: `diff`
|
||||
* Description: Generates a PDF with the differences between two PCBs or schematics
|
||||
* Description: Generates a PDF with the differences between two PCBs or schematics.
|
||||
Recursive git submodules aren't supported (submodules inside submodules)
|
||||
* Valid keys:
|
||||
- **`comment`**: [string=''] A comment for documentation purposes.
|
||||
- **`dir`**: [string='./'] Output directory for the generated files.
|
||||
|
|
@ -1512,6 +1513,11 @@ Notes:
|
|||
- `diff_mode`: [string='red_green'] [red_green,stats] In the `red_green` mode added stuff is green and red when removed.
|
||||
The `stats` mode is used to meassure the amount of difference. In this mode all
|
||||
changes are red, but you can abort if the difference is bigger than certain threshold.
|
||||
- `force_checkout`: [boolean=false] When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point.
|
||||
Before doing it KiBot will stash any change. Under some circumstances git could fail
|
||||
to do a checkout, even after stashing, this option can workaround the problem.
|
||||
Note that using it you could potentially lose modified files. For more information
|
||||
read https://stackoverflow.com/questions/1248029/git-pull-error-entry-foo-not-uptodate-cannot-merge.
|
||||
- `fuzz`: [number=5] [0,100] Color tolerance (fuzzyness) for the `stats` mode.
|
||||
- `new`: [string=''] The file you want to compare. Leave it blank for the current PCB/SCH.
|
||||
- `new_type`: [string='file'] [git,file] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
|
||||
|
|
|
|||
|
|
@ -410,8 +410,9 @@ outputs:
|
|||
output: '%f-%i%I%v.%x'
|
||||
# `remove_files` is an alias for `move_files`
|
||||
# Diff:
|
||||
# Recursive git submodules aren't supported (submodules inside submodules)
|
||||
- name: 'diff_example'
|
||||
comment: 'Generates a PDF with the differences between two PCBs or schematics'
|
||||
comment: 'Generates a PDF with the differences between two PCBs or schematics.'
|
||||
type: 'diff'
|
||||
dir: 'Example/diff_dir'
|
||||
options:
|
||||
|
|
@ -428,6 +429,12 @@ outputs:
|
|||
# The `stats` mode is used to meassure the amount of difference. In this mode all
|
||||
# changes are red, but you can abort if the difference is bigger than certain threshold
|
||||
diff_mode: 'red_green'
|
||||
# [boolean=false] When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point.
|
||||
# Before doing it KiBot will stash any change. Under some circumstances git could fail
|
||||
# to do a checkout, even after stashing, this option can workaround the problem.
|
||||
# Note that using it you could potentially lose modified files. For more information
|
||||
# read https://stackoverflow.com/questions/1248029/git-pull-error-entry-foo-not-uptodate-cannot-merge
|
||||
force_checkout: false
|
||||
# [number=5] [0,100] Color tolerance (fuzzyness) for the `stats` mode
|
||||
fuzz: 5
|
||||
# [string=''] The file you want to compare. Leave it blank for the current PCB/SCH
|
||||
|
|
|
|||
|
|
@ -76,6 +76,12 @@ class DiffOptions(BaseOptions):
|
|||
self.copy_instead_of_link = False
|
||||
""" When `add_link_id` is enabled creates a copy of the file instead of a symlink.
|
||||
Useful for some Windows setups """
|
||||
self.force_checkout = False
|
||||
""" When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point.
|
||||
Before doing it KiBot will stash any change. Under some circumstances git could fail
|
||||
to do a checkout, even after stashing, this option can workaround the problem.
|
||||
Note that using it you could potentially lose modified files. For more information
|
||||
read https://stackoverflow.com/questions/1248029/git-pull-error-entry-foo-not-uptodate-cannot-merge """
|
||||
super().__init__()
|
||||
self._expand_id = 'diff'
|
||||
self._expand_ext = 'pdf'
|
||||
|
|
@ -169,7 +175,7 @@ class DiffOptions(BaseOptions):
|
|||
def undo_git(self):
|
||||
if self.checkedout:
|
||||
logger.debug('Restoring point '+self.branch)
|
||||
self.run_git(['checkout', '--recurse-submodules', self.branch])
|
||||
self.run_git(['checkout', '--force', '--recurse-submodules', self.branch])
|
||||
if self.stashed:
|
||||
logger.debug('Restoring changes')
|
||||
self.stash_pop()
|
||||
|
|
@ -230,7 +236,10 @@ class DiffOptions(BaseOptions):
|
|||
name_ori = name
|
||||
name = self.solve_git_name(name)
|
||||
logger.debug('Changing to '+name)
|
||||
self.run_git(['checkout', '--recurse-submodules', name])
|
||||
ops = ['checkout']
|
||||
if self.force_checkout:
|
||||
ops.append('--force')
|
||||
self.run_git(ops+['--recurse-submodules', name])
|
||||
self.checkedout = True
|
||||
# A short version of the current hash
|
||||
self.git_hash = '{}({})'.format(name_ori, self.run_git(['rev-parse', '--short', 'HEAD']))
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ outputs:
|
|||
new: HEAD
|
||||
new_type: git
|
||||
cache_dir: .cache
|
||||
force_checkout: true
|
||||
add_link_id: true
|
||||
|
||||
- name: result
|
||||
|
|
|
|||
Loading…
Reference in New Issue