mirror of https://github.com/ARMmbed/mbed-os.git
parent
43251e162d
commit
51430cdeb3
|
|
@ -1,6 +1,10 @@
|
||||||
import os, json, stat, sys, shutil, errno, subprocess, logging, re
|
import os
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
from os.path import dirname, abspath, basename, join
|
from os.path import dirname, abspath, join
|
||||||
|
|
||||||
# Be sure that the tools directory is in the search path
|
# Be sure that the tools directory is in the search path
|
||||||
ROOT = abspath(join(dirname(__file__), "../.."))
|
ROOT = abspath(join(dirname(__file__), "../.."))
|
||||||
|
|
@ -21,7 +25,7 @@ def del_file(name):
|
||||||
result.append(os.path.join(root, name))
|
result.append(os.path.join(root, name))
|
||||||
for file in result:
|
for file in result:
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
rel_log.debug("Deleted: %s", os.path.relpath(file, ROOT));
|
rel_log.debug("Deleted: %s", os.path.relpath(file, ROOT))
|
||||||
|
|
||||||
def copy_folder(src, dest):
|
def copy_folder(src, dest):
|
||||||
""" Copy contents of folder in mbed-os listed path
|
""" Copy contents of folder in mbed-os listed path
|
||||||
|
|
@ -75,16 +79,15 @@ def get_curr_sha(repo_path):
|
||||||
sha - last commit SHA
|
sha - last commit SHA
|
||||||
"""
|
"""
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
sha = None
|
|
||||||
os.chdir(abspath(repo_path))
|
os.chdir(abspath(repo_path))
|
||||||
|
|
||||||
cmd = "git log --pretty=format:%h -n 1"
|
cmd = "git log --pretty=format:%h -n 1"
|
||||||
ret, sha = run_cmd_with_output(cmd, exit_on_failure=True)
|
_, sha = run_cmd_with_output(cmd, exit_on_failure=True)
|
||||||
|
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
return sha
|
return sha
|
||||||
|
|
||||||
def check_branch(name):
|
def branch_exists(name):
|
||||||
""" Check if branch already exists in mbed-os local repository.
|
""" Check if branch already exists in mbed-os local repository.
|
||||||
It will not verify if branch is present in remote repository.
|
It will not verify if branch is present in remote repository.
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -92,7 +95,7 @@ def check_branch(name):
|
||||||
Returns:
|
Returns:
|
||||||
True - If branch is already present
|
True - If branch is already present
|
||||||
"""
|
"""
|
||||||
branches = []
|
|
||||||
cmd = "git branch"
|
cmd = "git branch"
|
||||||
_, output = run_cmd_with_output(cmd, exit_on_failure=False)
|
_, output = run_cmd_with_output(cmd, exit_on_failure=False)
|
||||||
if name in output:
|
if name in output:
|
||||||
|
|
@ -120,16 +123,15 @@ def get_last_cherry_pick_sha(branch):
|
||||||
cmd = "git checkout " + branch
|
cmd = "git checkout " + branch
|
||||||
run_cmd_with_output(cmd, exit_on_failure=False)
|
run_cmd_with_output(cmd, exit_on_failure=False)
|
||||||
|
|
||||||
SHA = None
|
sha = None
|
||||||
get_commit = "git log -n 1"
|
get_commit = "git log -n 1"
|
||||||
_, output = run_cmd_with_output(get_commit, exit_on_failure=True)
|
_, output = run_cmd_with_output(get_commit, exit_on_failure=True)
|
||||||
lines = output.split('\n')
|
lines = output.split('\n')
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if 'cherry picked from' in line:
|
if 'cherry picked from' in line:
|
||||||
SHA = line.split(' ')[-1]
|
sha = line.split(' ')[-1]
|
||||||
SHA = SHA[:-1]
|
return sha[:-1]
|
||||||
return SHA
|
return sha
|
||||||
#for words in output.split('\n') if 'origin' in line and not '->' in line]
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
|
@ -185,7 +187,7 @@ if __name__ == "__main__":
|
||||||
we will skip all file transfer and merge operations and will
|
we will skip all file transfer and merge operations and will
|
||||||
jump to cherry-pick
|
jump to cherry-pick
|
||||||
'''
|
'''
|
||||||
if check_branch(branch):
|
if branch_exists(branch):
|
||||||
rel_log.info("Branch present = %s", branch)
|
rel_log.info("Branch present = %s", branch)
|
||||||
else:
|
else:
|
||||||
data_files = json_data["files"]
|
data_files = json_data["files"]
|
||||||
|
|
@ -219,7 +221,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
## Create new branch with all changes
|
## Create new branch with all changes
|
||||||
create_branch = "git checkout -b "+ branch
|
create_branch = "git checkout -b "+ branch
|
||||||
run_cmd_with_output(create_branch, exit_on_failure=False)
|
run_cmd_with_output(create_branch, exit_on_failure=True)
|
||||||
rel_log.info("Branch created = %s", branch)
|
rel_log.info("Branch created = %s", branch)
|
||||||
|
|
||||||
add_files = "git add -A"
|
add_files = "git add -A"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue