Minor error catching updates Pt 1
This commit is contained in:
parent
34dbf96878
commit
123a27d6b1
@ -36,7 +36,7 @@ def initialize_git_repo():
|
||||
else:
|
||||
git_init_output = os.popen("git init .").read().strip()
|
||||
print(add_indent(git_init_output, 15, '➖'))
|
||||
|
||||
|
||||
################################################################################
|
||||
def add_allspice_remote():
|
||||
print(add_indent("Adding AllSpice remote", 8, '➕'))
|
||||
@ -50,7 +50,7 @@ def add_allspice_remote():
|
||||
|
||||
################################################################################
|
||||
def fetch_from_allspice():
|
||||
print(add_indent("Fetching from AllSpice remote", 8, '🔄'))
|
||||
print(add_indent("Fetching from AllSpice remote", 8, '🔄'))
|
||||
git_fetch_process = subprocess.Popen(['git fetch'], stdout = subprocess.PIPE, stderr = subprocess.PIPE, text = True, shell = True)
|
||||
std_out, std_err = git_fetch_process.communicate()
|
||||
if std_out or std_err:
|
||||
@ -100,6 +100,18 @@ def get_list_of_untracked_files():
|
||||
print(add_indent("None", 15, '🔹'))
|
||||
return untracked_files
|
||||
|
||||
################################################################################
|
||||
def get_list_of_added_files_not_yet_committed():
|
||||
print(add_indent("Added files for commit found:", 8, '▪️'))
|
||||
git_changes_to_be_committed_output = os.popen("git diff --cached --name-only").read().strip()
|
||||
added_files = git_changes_to_be_committed_output.split('\n') if git_changes_to_be_committed_output else []
|
||||
if added_files:
|
||||
for cur_file in added_files:
|
||||
print(add_indent(str(cur_file), 15, '📄'))
|
||||
else:
|
||||
print(add_indent("None", 15, '🔹'))
|
||||
return added_files
|
||||
|
||||
################################################################################
|
||||
def add_modified_or_untracked_files_for_commit():
|
||||
git_add_output = os.popen("git add .").read().strip()
|
||||
@ -121,7 +133,7 @@ def commit_changes(commit_message):
|
||||
|
||||
################################################################################
|
||||
def push_commit_to_allspice():
|
||||
print(add_indent("Pushing to AllSpice on the develop branch...", 8, '📤'))
|
||||
print(add_indent("Pushing changes to AllSpice on the develop branch...", 8, '📤'))
|
||||
git_push_process = subprocess.Popen(['git push'], stdout = subprocess.PIPE, stderr = subprocess.PIPE, text = True, shell = True)
|
||||
std_out, std_err = git_push_process.communicate()
|
||||
print(add_indent(std_err.strip(), 15, '➖'))
|
||||
@ -160,22 +172,22 @@ if __name__ == "__main__":
|
||||
modified_files = get_list_of_modified_files()
|
||||
# Get list of untracked files
|
||||
untracked_files = get_list_of_untracked_files()
|
||||
# If there are any untracked or modified files, start pushing to AllSpice
|
||||
# If there are any untracked or modified files, add them for commit
|
||||
if modified_files or untracked_files:
|
||||
# Add files to commit
|
||||
add_modified_or_untracked_files_for_commit()
|
||||
# If there added files to be committed, prompt for a commit message and commit
|
||||
# This step/check ensures that any previously halted commits are taken care of
|
||||
added_files = get_list_of_added_files_not_yet_committed()
|
||||
if added_files:
|
||||
# Ask user for a commit message
|
||||
commit_message = prompt_user_for_commit_message()
|
||||
# Prepare a commit with the commit message
|
||||
commit_changes(commit_message)
|
||||
# Push commit to allspice
|
||||
push_commit_to_allspice()
|
||||
print(add_indent("Completed processing project folder " + proj_dir, 8, '☑️'))
|
||||
else:
|
||||
print(add_indent("Nothing new to push to AllSpice", 8, '🤖'))
|
||||
print(add_indent("Completed processing project folder " + proj_dir, 8, '☑️'))
|
||||
# Push commit to allspice
|
||||
push_commit_to_allspice()
|
||||
print(add_indent("Completed processing project folder " + proj_dir, 8, '☑️'))
|
||||
# Change directory back to depot root
|
||||
os.chdir("..")
|
||||
print("\n--------------------------------------------------\n")
|
||||
print("✅ Perforce->AllSpice sync completed!")
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
@ -39,7 +39,7 @@ def initialize_git_repo():
|
||||
else:
|
||||
git_init_process = subprocess.run("git init", capture_output=True, text=True, shell=True)
|
||||
print(add_indent(git_init_process.stdout.strip(), 15, '>>'))
|
||||
|
||||
|
||||
################################################################################
|
||||
def add_allspice_remote():
|
||||
print(add_indent("Adding AllSpice remote", 8, '-'))
|
||||
@ -125,7 +125,7 @@ def commit_changes(commit_message):
|
||||
|
||||
################################################################################
|
||||
def push_commit_to_allspice():
|
||||
print(add_indent("Pushing to AllSpice on the develop branch...", 8, '-'))
|
||||
print(add_indent("Pushing changes to AllSpice on the develop branch...", 8, '-'))
|
||||
git_push_process = subprocess.run("git push", capture_output=True, text=True, shell=True)
|
||||
print(add_indent(git_push_process.stdout.strip(), 15, '>>'))
|
||||
print(add_indent(git_push_process.stderr.strip(), 15, '>>'))
|
||||
@ -171,14 +171,10 @@ if __name__ == "__main__":
|
||||
commit_message = prompt_user_for_commit_message()
|
||||
# Prepare a commit with the commit message
|
||||
commit_changes(commit_message)
|
||||
# Push commit to allspice
|
||||
push_commit_to_allspice()
|
||||
print(add_indent("Completed processing project folder " + proj_dir, 8, '-'))
|
||||
else:
|
||||
print(add_indent("Nothing new to push to AllSpice", 8, '-'))
|
||||
print(add_indent("Completed processing project folder " + proj_dir, 8, '-'))
|
||||
# Push commit to allspice
|
||||
push_commit_to_allspice()
|
||||
print(add_indent("Completed processing project folder " + proj_dir, 8, '-'))
|
||||
# Change directory back to depot root
|
||||
os.chdir("..")
|
||||
print("\n--------------------------------------------------\n")
|
||||
print("- Perforce->AllSpice sync completed!")
|
||||
|
Loading…
Reference in New Issue
Block a user