style: improve code formatting and whitespace
- Remove trailing whitespaces in Step class - Improve formatting in GitHub and GitLab commit modules - Fix indentation in error message output - Add proper line spacing between functions
This commit is contained in:
parent
bb0ed153c7
commit
083c714ac0
@ -34,4 +34,3 @@ class Step(AbstractContextManager):
|
|||||||
IDEService().ide_logging(
|
IDEService().ide_logging(
|
||||||
"debug", f"Step {self.title} took {end_time - self.enter_time:.2f} seconds"
|
"debug", f"Step {self.title} took {end_time - self.enter_time:.2f} seconds"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -358,36 +358,41 @@ def check_git_installed():
|
|||||||
def ask_for_push():
|
def ask_for_push():
|
||||||
"""
|
"""
|
||||||
询问用户是否要推送(push)更改到远程仓库
|
询问用户是否要推送(push)更改到远程仓库
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: 用户是否选择推送
|
bool: 用户是否选择推送
|
||||||
"""
|
"""
|
||||||
from lib.chatmark import Button
|
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"Step 3/3: Would you like to push your commit to the remote repository?",
|
"Step 3/3: Would you like to push your commit to the remote repository?",
|
||||||
end="\n\n",
|
end="\n\n",
|
||||||
flush=True,
|
flush=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
button = Button(["Yes, push now", "No, I'll push later"])
|
button = Button(["Yes, push now", "No, I'll push later"])
|
||||||
button.render()
|
button.render()
|
||||||
|
|
||||||
return button.clicked == 0 # 如果用户点击第一个按钮(Yes),则返回True
|
return button.clicked == 0 # 如果用户点击第一个按钮(Yes),则返回True
|
||||||
|
|
||||||
|
|
||||||
def push_changes():
|
def push_changes():
|
||||||
"""
|
"""
|
||||||
推送更改到远程仓库
|
推送更改到远程仓库
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: 推送是否成功
|
bool: 推送是否成功
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
current_branch = get_current_branch()
|
current_branch = get_current_branch()
|
||||||
if not current_branch:
|
if not current_branch:
|
||||||
print("Could not determine current branch. Push failed.", end="\n\n", file=sys.stderr, flush=True)
|
print(
|
||||||
|
"Could not determine current branch. Push failed.",
|
||||||
|
end="\n\n",
|
||||||
|
file=sys.stderr,
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
print(f"Pushing changes to origin/{current_branch}...", end="\n\n", flush=True)
|
print(f"Pushing changes to origin/{current_branch}...", end="\n\n", flush=True)
|
||||||
result = subprocess_run(
|
result = subprocess_run(
|
||||||
["git", "push", "origin", current_branch],
|
["git", "push", "origin", current_branch],
|
||||||
@ -408,6 +413,7 @@ def push_changes():
|
|||||||
print(f"An unexpected error occurred: {str(e)}", end="\n\n", file=sys.stderr, flush=True)
|
print(f"An unexpected error occurred: {str(e)}", end="\n\n", file=sys.stderr, flush=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global language
|
global language
|
||||||
try:
|
try:
|
||||||
@ -476,7 +482,7 @@ def main():
|
|||||||
if not push_changes():
|
if not push_changes():
|
||||||
print("Push failed.", flush=True)
|
print("Push failed.", flush=True)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
print("Commit completed.", flush=True)
|
print("Commit completed.", flush=True)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -358,36 +358,41 @@ def check_git_installed():
|
|||||||
def ask_for_push():
|
def ask_for_push():
|
||||||
"""
|
"""
|
||||||
询问用户是否要推送(push)更改到远程仓库
|
询问用户是否要推送(push)更改到远程仓库
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: 用户是否选择推送
|
bool: 用户是否选择推送
|
||||||
"""
|
"""
|
||||||
from lib.chatmark import Button
|
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"Step 3/3: Would you like to push your commit to the remote repository?",
|
"Step 3/3: Would you like to push your commit to the remote repository?",
|
||||||
end="\n\n",
|
end="\n\n",
|
||||||
flush=True,
|
flush=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
button = Button(["Yes, push now", "No, I'll push later"])
|
button = Button(["Yes, push now", "No, I'll push later"])
|
||||||
button.render()
|
button.render()
|
||||||
|
|
||||||
return button.clicked == 0 # 如果用户点击第一个按钮(Yes),则返回True
|
return button.clicked == 0 # 如果用户点击第一个按钮(Yes),则返回True
|
||||||
|
|
||||||
|
|
||||||
def push_changes():
|
def push_changes():
|
||||||
"""
|
"""
|
||||||
推送更改到远程仓库
|
推送更改到远程仓库
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: 推送是否成功
|
bool: 推送是否成功
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
current_branch = get_current_branch()
|
current_branch = get_current_branch()
|
||||||
if not current_branch:
|
if not current_branch:
|
||||||
print("Could not determine current branch. Push failed.", end="\n\n", file=sys.stderr, flush=True)
|
print(
|
||||||
|
"Could not determine current branch. Push failed.",
|
||||||
|
end="\n\n",
|
||||||
|
file=sys.stderr,
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
print(f"Pushing changes to origin/{current_branch}...", end="\n\n", flush=True)
|
print(f"Pushing changes to origin/{current_branch}...", end="\n\n", flush=True)
|
||||||
result = subprocess_run(
|
result = subprocess_run(
|
||||||
["git", "push", "origin", current_branch],
|
["git", "push", "origin", current_branch],
|
||||||
@ -408,6 +413,7 @@ def push_changes():
|
|||||||
print(f"An unexpected error occurred: {str(e)}", end="\n\n", file=sys.stderr, flush=True)
|
print(f"An unexpected error occurred: {str(e)}", end="\n\n", file=sys.stderr, flush=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global language
|
global language
|
||||||
try:
|
try:
|
||||||
@ -476,7 +482,7 @@ def main():
|
|||||||
if not push_changes():
|
if not push_changes():
|
||||||
print("Push failed.", flush=True)
|
print("Push failed.", flush=True)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
print("Commit completed.", flush=True)
|
print("Commit completed.", flush=True)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user