Merge branch 'sunwukonga-fix-spaces-n-notgitroot'

Added seperate linux executable.
Added functionality to manage situations where the *.kicad_pcb is not in the root directory of a git repository. This does not affect SVN or Fossil repos.
Deal with spaces in path names
This commit is contained in:
John Pateman 2020-05-07 14:37:37 +01:00
commit ee216429b4
3 changed files with 1638 additions and 2 deletions

View File

@ -658,6 +658,36 @@ a:hover {
# ----------------------Main Functions begin here--------------------------------------- # ----------------------Main Functions begin here---------------------------------------
# #
def getGitPath(prjctName, prjctPath):
gitRootCmd = 'cd ' + prjctPath + ' && ' + gitProg + ' rev-parse --show-toplevel'
gitRootProcess = Popen(
gitRootCmd,
shell=True,
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
close_fds=True)
stdout, stderr = gitRootProcess.communicate()
gitRoot = stdout.decode('utf-8')
gitPathCmd = 'cd ' + _escape_string(gitRoot) + ' && ' + gitProg + ' ls-tree -r --name-only HEAD | ' + grepProg + ' -m 1 ' + prjctName
gitPathProcess = Popen(
gitPathCmd,
shell=True,
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
close_fds=True)
stdout, stderr = gitPathProcess.communicate()
gitPathProcess.wait()
return stdout.decode('utf-8')
def getGitDiff(diff1, diff2, prjctName, prjctPath): def getGitDiff(diff1, diff2, prjctName, prjctPath):
'''Given two git artifacts, write out two kicad_pcb files to their respective '''Given two git artifacts, write out two kicad_pcb files to their respective
directories (named after the artifact). Returns the date and time of both commits''' directories (named after the artifact). Returns the date and time of both commits'''
@ -694,11 +724,13 @@ def getGitDiff(diff1, diff2, prjctName, prjctPath):
if not os.path.exists(outputDir2): if not os.path.exists(outputDir2):
os.makedirs(outputDir2) os.makedirs(outputDir2)
gitPath = getGitPath(prjctName, prjctPath)
gitArtifact1 = 'cd ' + prjctPath + ' && ' + gitProg + ' show ' + artifact1 + \ gitArtifact1 = 'cd ' + prjctPath + ' && ' + gitProg + ' show ' + artifact1 + \
':' + prjctName + ' > ' + outputDir1 + '/' + prjctName ':' + gitPath + ' > ' + outputDir1 + '/' + prjctName
gitArtifact2 = 'cd ' + prjctPath + ' && ' + gitProg + ' show ' + artifact2 + \ gitArtifact2 = 'cd ' + prjctPath + ' && ' + gitProg + ' show ' + artifact2 + \
':' + prjctName + ' > ' + outputDir2 + '/' + prjctName ':' + gitPath + ' > ' + outputDir2 + '/' + prjctName
print(gitArtifact1, gitArtifact2) print(gitArtifact1, gitArtifact2)

1603
kidiff_linux.py Executable file

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@ Kicad plot pcb file.
Plot variety of svg files in plot directory Plot variety of svg files in plot directory
''' '''
import sys
import pcbnew import pcbnew
from pcbnew import * from pcbnew import *