forked from metercai/SimpleSDXL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David Sage <162500231+DavidDragonsage@users.noreply.github.com>
- Loading branch information
1 parent
ad9ab0e
commit 6d64868
Showing
5 changed files
with
280 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--port", type=int, default=None, help="Set the listen port.") | ||
parser.add_argument( | ||
"--share", action="store_true", help="Set whether to share on Gradio." | ||
) | ||
parser.add_argument("--auth", type=str, help="Set credentials username/password.") | ||
parser.add_argument( | ||
"--listen", | ||
type=str, | ||
default=None, | ||
metavar="IP", | ||
nargs="?", | ||
const="0.0.0.0", | ||
help="Set the listen interface.", | ||
) | ||
parser.add_argument( | ||
"--nobrowser", action="store_true", help="Do not launch in browser." | ||
) | ||
parser.add_argument("--gpu-device-id", type=int, default=None, metavar="DEVICE_ID") | ||
|
||
|
||
args = parser.parse_args() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,49 @@ | ||
import os | ||
import sys | ||
|
||
|
||
root = os.path.dirname(os.path.abspath(__file__)) | ||
sys.path.append(root) | ||
os.chdir(root) | ||
|
||
|
||
try: | ||
import pygit2 | ||
pygit2.option(pygit2.GIT_OPT_SET_OWNER_VALIDATION, 0) | ||
|
||
repo = pygit2.Repository(os.path.abspath(os.path.dirname(__file__))) | ||
|
||
branch_name = repo.head.shorthand | ||
|
||
remote_name = 'origin' | ||
remote = repo.remotes[remote_name] | ||
|
||
remote.fetch() | ||
|
||
origin_name = 'FooocusPlus' | ||
main_name = 'FooocusPlus' | ||
dev_name = 'FooocusPlus_dev' | ||
local_branch_ref = f'refs/heads/{branch_name}' | ||
if '--dev' in (sys.argv): | ||
if branch_name != dev_name: | ||
branch_name = dev_name | ||
print(f'Ready to checkout {branch_name}') | ||
local_branch_ref = f'refs/heads/{branch_name}' | ||
if local_branch_ref not in list(repo.references): | ||
remote_reference = f'refs/remotes/{remote_name}/{branch_name}' | ||
remote_branch = repo.references[remote_reference] | ||
new_branch = repo.create_branch(branch_name, repo[remote_branch.target]) | ||
new_branch.upstream = remote_branch | ||
else: | ||
new_branch = repo.lookup_branch(branch_name) | ||
repo.checkout(new_branch) | ||
local_branch_ref = f'refs/heads/{branch_name}' | ||
elif '--main' in (sys.argv): | ||
if branch_name != origin_name: | ||
branch_name = origin_name | ||
print(f'Ready to checkout Fooocus') | ||
local_branch_ref = f'refs/heads/{branch_name}' | ||
if local_branch_ref not in list(repo.references): | ||
remote_reference = f'refs/remotes/{remote_name}/{branch_name}' | ||
remote_branch = repo.references[remote_reference] | ||
new_branch = repo.create_branch(branch_name, repo[remote_branch.target]) | ||
new_branch.upstream = remote_branch | ||
else: | ||
new_branch = repo.lookup_branch(branch_name) | ||
repo.checkout(new_branch) | ||
local_branch_ref = f'refs/heads/{branch_name}' | ||
else: | ||
if branch_name != main_name: | ||
branch_name = main_name | ||
print(f'Ready to checkout {branch_name}') | ||
local_branch_ref = f'refs/heads/{branch_name}' | ||
new_branch = repo.lookup_branch(branch_name) | ||
repo.checkout(new_branch) | ||
|
||
local_branch = repo.lookup_reference(local_branch_ref) | ||
local_commit = repo.revparse_single(local_branch_ref) | ||
|
||
remote_reference = f'refs/remotes/{remote_name}/{branch_name}' | ||
remote_commit = repo.revparse_single(remote_reference) | ||
|
||
merge_result, _ = repo.merge_analysis(remote_commit.id) | ||
|
||
if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE: | ||
print(f'{branch_name if branch_name!="main" else "Fooocus"}: Already up-to-date, {str(local_commit.id)[:7]}') | ||
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD: | ||
local_branch.set_target(remote_commit.id) | ||
repo.head.set_target(remote_commit.id) | ||
repo.checkout_tree(repo.get(remote_commit.id)) | ||
repo.reset(local_branch.target, pygit2.GIT_RESET_HARD) | ||
print(f'{branch_name if branch_name!="main" else "Fooocus"}: Fast-forward merge, {str(local_commit.id)[:7]} <- {str(remote_commit.id)[:7]}') | ||
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL: | ||
print(f'{branch_name if branch_name!="main" else "Fooocus"}: Update failed - Did you modify any file? {str(local_commit.id)[:7]} <- {str(remote_commit.id)[:7]}') | ||
except Exception as e: | ||
print(f'{branch_name if branch_name!="main" else "Fooocus"}: Update failed.') | ||
print(str(e)) | ||
|
||
|
||
if __name__ == '__main__': | ||
import multiprocessing as mp | ||
mp.set_start_method('spawn') | ||
|
||
from launch import * | ||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
root = Path(__file__).resolve().parent | ||
sys.path.append(str(root)) | ||
os.chdir(root) | ||
|
||
bupdated = False | ||
try: | ||
import pygit2 | ||
|
||
pygit2.option(pygit2.GIT_OPT_SET_OWNER_VALIDATION, 0) | ||
|
||
repo_path = Path(__file__).resolve().parent | ||
repo = pygit2.Repository(str(repo_path)) | ||
|
||
branch_name = repo.head.shorthand | ||
|
||
remote_name = "origin" | ||
remote = repo.remotes[remote_name] | ||
|
||
remote.fetch() | ||
|
||
local_branch_ref = f"refs/heads/{branch_name}" | ||
local_branch = repo.lookup_reference(local_branch_ref) | ||
|
||
remote_reference = f"refs/remotes/{remote_name}/{branch_name}" | ||
remote_commit = repo.revparse_single(remote_reference) | ||
|
||
merge_result, _ = repo.merge_analysis(remote_commit.id) | ||
|
||
if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE: | ||
print("You have the latest version") | ||
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD: | ||
local_branch.set_target(remote_commit.id) | ||
repo.head.set_target(remote_commit.id) | ||
repo.checkout_tree(repo.get(remote_commit.id)) | ||
repo.reset(local_branch.target, pygit2.GIT_RESET_HARD) | ||
print("Updating Files") | ||
bupdated = True | ||
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL: | ||
print("Update failed, Did you modify any files?") | ||
except Exception as e: | ||
print("Update failed...") | ||
print(str(e)) | ||
if bupdated: | ||
print("Update succeeded!!") | ||
from launch import * |
Oops, something went wrong.