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
|
||||
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
|
||||
ROOT = abspath(join(dirname(__file__), "../.."))
|
||||
|
|
@ -21,7 +25,7 @@ def del_file(name):
|
|||
result.append(os.path.join(root, name))
|
||||
for file in result:
|
||||
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):
|
||||
""" Copy contents of folder in mbed-os listed path
|
||||
|
|
@ -75,16 +79,15 @@ def get_curr_sha(repo_path):
|
|||
sha - last commit SHA
|
||||
"""
|
||||
cwd = os.getcwd()
|
||||
sha = None
|
||||
os.chdir(abspath(repo_path))
|
||||
|
||||
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)
|
||||
return sha
|
||||
|
||||
def check_branch(name):
|
||||
def branch_exists(name):
|
||||
""" Check if branch already exists in mbed-os local repository.
|
||||
It will not verify if branch is present in remote repository.
|
||||
Args:
|
||||
|
|
@ -92,7 +95,7 @@ def check_branch(name):
|
|||
Returns:
|
||||
True - If branch is already present
|
||||
"""
|
||||
branches = []
|
||||
|
||||
cmd = "git branch"
|
||||
_, output = run_cmd_with_output(cmd, exit_on_failure=False)
|
||||
if name in output:
|
||||
|
|
@ -120,16 +123,15 @@ def get_last_cherry_pick_sha(branch):
|
|||
cmd = "git checkout " + branch
|
||||
run_cmd_with_output(cmd, exit_on_failure=False)
|
||||
|
||||
SHA = None
|
||||
sha = None
|
||||
get_commit = "git log -n 1"
|
||||
_, output = run_cmd_with_output(get_commit, exit_on_failure=True)
|
||||
lines = output.split('\n')
|
||||
for line in lines:
|
||||
if 'cherry picked from' in line:
|
||||
SHA = line.split(' ')[-1]
|
||||
SHA = SHA[:-1]
|
||||
return SHA
|
||||
#for words in output.split('\n') if 'origin' in line and not '->' in line]
|
||||
sha = line.split(' ')[-1]
|
||||
return sha[:-1]
|
||||
return sha
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
|
@ -185,7 +187,7 @@ if __name__ == "__main__":
|
|||
we will skip all file transfer and merge operations and will
|
||||
jump to cherry-pick
|
||||
'''
|
||||
if check_branch(branch):
|
||||
if branch_exists(branch):
|
||||
rel_log.info("Branch present = %s", branch)
|
||||
else:
|
||||
data_files = json_data["files"]
|
||||
|
|
@ -219,7 +221,7 @@ if __name__ == "__main__":
|
|||
|
||||
## Create new branch with all changes
|
||||
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)
|
||||
|
||||
add_files = "git add -A"
|
||||
|
|
|
|||
Loading…
Reference in New Issue