1#!/usr/bin/env python3 2 3# Applies a commit or commits on branch or branches 4# USAGE: 5# patch.py -c <commit-list> -b <branch-list> [-p] [-t] 6# - <commit-list>: list of commit SHAs to apply. 7# - <branch-list>: branches where the commit should be applied. * can be used as wildchar 8# - p: push the changes to <branch-list> 9# - t: increment version number and create a tag 10 11 12import os, subprocess, com, re 13 14push = False 15 16def clone(repo): 17 com.cmd("git clone --recurse-submodules https://github.com/lvgl/" + repo) 18 os.chdir("./" + repo) 19 com.cmd("git checkout master") 20 com.cmd("git remote update origin --prune") 21 com.cmd("git pull origin --tags") 22 os.chdir("..") 23 24# Get the list of related minor version branches 25 26#clone("lvgl") 27os.chdir("lvgl") 28 29cmd = "git branch --remotes | grep origin/release/v8" 30branches, error = subprocess.Popen(cmd, shell=True, executable="/bin/bash", stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() 31 32branches = str(branches) 33branches = branches.replace("b'", "") 34branches = branches.replace("'", "") 35branches = branches.replace("origin/", "") 36branches = branches.replace(" ", " ") 37branches = branches.replace("\\n", "") 38branches = branches.split(" ") 39branches = list(filter(len, branches)) 40 41commits = [] 42with open('../commits.txt') as f: 43 for line in f: 44 commits.insert(0, line) 45 46print(commits) 47 48for br in branches: 49 com.cmd("git checkout " + br) 50 51 print("Applying commits") 52 for c in commits: 53 h = c.split(" ") 54 com.cmd("git cherry-pick " + h[0]) 55 56 ver = com.get_lvgl_version(br) 57 ver_new = ver.copy() 58 ver_new[2] = str(int(ver_new[2]) + 1) 59 print("Updating branch '" + br + "' from '" + com.ver_format(ver) + "' to '" + com.ver_format(ver_new) + "'") 60 com.update_version(ver_new) 61 com.cmd("git tag -a " + com.ver_format(ver_new) + "-m \"Release " + com.ver_format(ver_new) + "\"") 62 63 if push: 64 com.cmd("git push origin " + br + "--tags") 65 66com.cmd("git checkout master") 67ver = com.get_lvgl_version("master") 68ver = com.get_lvgl_version(br) 69ver_new[2] = str(int(ver_new[2]) + 1) 70t = com.ver_format(ver_new) + "-dev" 71com.cmd("git tag -a " + t + " -m \"Start " + t + "\"") 72 73if push: 74 com.cmd("git push origin master --tags") 75