mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #4521 from wschaeferB/4690-MatchAutopsyBranchToTskBranch
4690 match autopsy branch to tsk branch
This commit is contained in:
commit
2452b87b8e
@ -12,9 +12,12 @@ import subprocess
|
|||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
TSK_HOME=os.getenv("TSK_HOME",False)
|
TSK_HOME=os.getenv("TSK_HOME",False)
|
||||||
|
ORIGIN_OWNER="origin"
|
||||||
|
DEVELOP_BRANCH='develop'
|
||||||
|
|
||||||
passed = 1
|
passed = 1
|
||||||
|
|
||||||
def getSleuthkitBranchList():
|
def getSleuthkitBranchList(branchOwner):
|
||||||
# Returns the list of sleuthkit branches
|
# Returns the list of sleuthkit branches
|
||||||
cmd = ['git','branch','-a']
|
cmd = ['git','branch','-a']
|
||||||
retdir = os.getcwd()
|
retdir = os.getcwd()
|
||||||
@ -22,12 +25,12 @@ def getSleuthkitBranchList():
|
|||||||
output = subprocess.check_output(cmd)
|
output = subprocess.check_output(cmd)
|
||||||
branches = []
|
branches = []
|
||||||
for branch in output.strip().split():
|
for branch in output.strip().split():
|
||||||
if branch.startswith('remotes/origin'):
|
if branch.startswith('remotes/'+branchOwner):
|
||||||
branches.append(branch.split('/')[2])
|
branches.append(branch.split('/')[2])
|
||||||
os.chdir(retdir)
|
os.chdir(retdir)
|
||||||
return branches
|
return branches
|
||||||
|
|
||||||
def gitSleuthkitCheckout(branch):
|
def gitSleuthkitCheckout(branch, branchOwner):
|
||||||
'''
|
'''
|
||||||
Checksout sleuthkit branch
|
Checksout sleuthkit branch
|
||||||
Args:
|
Args:
|
||||||
@ -36,7 +39,16 @@ def gitSleuthkitCheckout(branch):
|
|||||||
# passed is a global variable that gets set to non-zero integer
|
# passed is a global variable that gets set to non-zero integer
|
||||||
# When an error occurs
|
# When an error occurs
|
||||||
global passed
|
global passed
|
||||||
cmd = ['git','checkout',branch]
|
if (branchOwner==ORIGIN_OWNER):
|
||||||
|
cmd = ['git','checkout', branch]
|
||||||
|
else:
|
||||||
|
#add the remotes
|
||||||
|
checkout=['git','checkout','-b',branchOwner+'-'+branch]
|
||||||
|
passed = subprocess.call(checkout, stdout=sys.stdout,cwd=TSK_HOME)
|
||||||
|
cmd = ['git','pull', "/".join(["https://github.com", branchOwner, "sleuthkit.git"]), branch]
|
||||||
|
if passed != 0: #0 would be success
|
||||||
|
#unable to create new branch return instead of pulling
|
||||||
|
return
|
||||||
passed = subprocess.call(cmd,stdout=sys.stdout,cwd=TSK_HOME)
|
passed = subprocess.call(cmd,stdout=sys.stdout,cwd=TSK_HOME)
|
||||||
|
|
||||||
def parseXML(xmlFile):
|
def parseXML(xmlFile):
|
||||||
@ -64,14 +76,16 @@ def main():
|
|||||||
TRAVIS=os.getenv("TRAVIS",False)
|
TRAVIS=os.getenv("TRAVIS",False)
|
||||||
APPVEYOR=os.getenv("APPVEYOR",False)
|
APPVEYOR=os.getenv("APPVEYOR",False)
|
||||||
if TRAVIS == "true":
|
if TRAVIS == "true":
|
||||||
CURRENT_BRANCH=os.getenv("TRAVIS_BRANCH",False)
|
CURRENT_BRANCH=os.getenv("TRAVIS_PULL_REQUEST_BRANCH",False)
|
||||||
|
BRANCH_OWNER=os.getenv("TRAVIS_PULL_REQUEST_SLUG", False).split('/')[0]
|
||||||
elif APPVEYOR:
|
elif APPVEYOR:
|
||||||
CURRENT_BRANCH=os.getenv("APPVEYOR_REPO_BRANCH",False)
|
CURRENT_BRANCH=os.getenv("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH",False)
|
||||||
|
BRANCH_OWNER=os.getenv("APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME", False).split('/')[0]
|
||||||
else:
|
else:
|
||||||
cmd=['git','rev-parse','--abbrev-ref','HEAD']
|
cmd=['git','rev-parse','--abbrev-ref','HEAD']
|
||||||
output = subprocess.check_output(cmd)
|
output = subprocess.check_output(cmd)
|
||||||
CURRENT_BRANCH=output.strip()
|
CURRENT_BRANCH=output.strip()
|
||||||
|
BRANCH_OWNER=ORIGIN_OWNER
|
||||||
# If we are in an Autopsy release branch, then use the
|
# If we are in an Autopsy release branch, then use the
|
||||||
# info in TSKVersion.xml to find the corresponding TSK
|
# info in TSKVersion.xml to find the corresponding TSK
|
||||||
# release branch. For other branches, we don't always
|
# release branch. For other branches, we don't always
|
||||||
@ -79,14 +93,17 @@ def main():
|
|||||||
if CURRENT_BRANCH.startswith('release'):
|
if CURRENT_BRANCH.startswith('release'):
|
||||||
version = parseXML('TSKVersion.xml')
|
version = parseXML('TSKVersion.xml')
|
||||||
RELEASE_BRANCH = "release-"+version
|
RELEASE_BRANCH = "release-"+version
|
||||||
gitSleuthkitCheckout(RELEASE_BRANCH)
|
gitSleuthkitCheckout(RELEASE_BRANCH, BRANCH_OWNER)
|
||||||
|
#If it failed try the origin release branch
|
||||||
|
if passed != 0:
|
||||||
|
gitSleuthkitCheckout(RELEASE_BRANCH, ORIGIN_OWNER)
|
||||||
# Check if the same branch exists in TSK (develop->develop, custom1->custom1, etc.)
|
# Check if the same branch exists in TSK (develop->develop, custom1->custom1, etc.)
|
||||||
elif CURRENT_BRANCH in getSleuthkitBranchList():
|
else:
|
||||||
gitSleuthkitCheckout(CURRENT_BRANCH)
|
gitSleuthkitCheckout(CURRENT_BRANCH, BRANCH_OWNER)
|
||||||
|
|
||||||
# Otherwise, default to develop
|
# Otherwise, default to origin develop
|
||||||
if passed != 0:
|
if passed != 0:
|
||||||
gitSleuthkitCheckout('develop')
|
gitSleuthkitCheckout(DEVELOP_BRANCH, ORIGIN_OWNER)
|
||||||
|
|
||||||
if passed != 0:
|
if passed != 0:
|
||||||
print('Error checking out a Sleuth Kit branch')
|
print('Error checking out a Sleuth Kit branch')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user