mirror of
https://github.com/clockworkpi/launcher_deot.git
synced 2025-12-12 23:48:52 +01:00
Add git.py (Sync Ver.200626)
This commit is contained in:
parent
28dd06f751
commit
3d7fd76b58
26
Menu/GameShell/10_Settings/BranchSelect/git.py
Normal file
26
Menu/GameShell/10_Settings/BranchSelect/git.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
def get_branches(path):
|
||||||
|
branches = subprocess.check_output(["git", "branch"], cwd=path).decode("utf-8").split("\n")[0:-1]
|
||||||
|
current = ""
|
||||||
|
result = []
|
||||||
|
for branch in branches:
|
||||||
|
if branch[0] == "*":
|
||||||
|
current = branch
|
||||||
|
result.append(branch[2:])
|
||||||
|
return result, current
|
||||||
|
|
||||||
|
def checkout_branch(path, branch):
|
||||||
|
return subprocess.check_call(["git", "checkout", branch], cwd=path)
|
||||||
|
|
||||||
|
def get_games():
|
||||||
|
result = []
|
||||||
|
for filename in os.listdir("/home/cpi/games"):
|
||||||
|
filename = os.path.join("/home/cpi/games", filename)
|
||||||
|
if os.path.isdir(filename) and is_git(filename):
|
||||||
|
result.append(filename)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def is_git(path):
|
||||||
|
return os.path.join(path, ".git")
|
||||||
Loading…
x
Reference in New Issue
Block a user