SuperRealCo commited on
Commit
8d014f8
·
verified ·
1 Parent(s): 55aeec7

Delete .ci/update_windows/update.py

Browse files
Files changed (1) hide show
  1. .ci/update_windows/update.py +0 -151
.ci/update_windows/update.py DELETED
@@ -1,151 +0,0 @@
1
- import pygit2
2
- from datetime import datetime
3
- import sys
4
- import os
5
- import shutil
6
- import filecmp
7
-
8
- def pull(repo, remote_name='origin', branch='master'):
9
- for remote in repo.remotes:
10
- if remote.name == remote_name:
11
- remote.fetch()
12
- remote_master_id = repo.lookup_reference('refs/remotes/origin/%s' % (branch)).target
13
- merge_result, _ = repo.merge_analysis(remote_master_id)
14
- # Up to date, do nothing
15
- if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE:
16
- return
17
- # We can just fastforward
18
- elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD:
19
- repo.checkout_tree(repo.get(remote_master_id))
20
- try:
21
- master_ref = repo.lookup_reference('refs/heads/%s' % (branch))
22
- master_ref.set_target(remote_master_id)
23
- except KeyError:
24
- repo.create_branch(branch, repo.get(remote_master_id))
25
- repo.head.set_target(remote_master_id)
26
- elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL:
27
- repo.merge(remote_master_id)
28
-
29
- if repo.index.conflicts is not None:
30
- for conflict in repo.index.conflicts:
31
- print('Conflicts found in:', conflict[0].path) # noqa: T201
32
- raise AssertionError('Conflicts, ahhhhh!!')
33
-
34
- user = repo.default_signature
35
- tree = repo.index.write_tree()
36
- repo.create_commit('HEAD',
37
- user,
38
- user,
39
- 'Merge!',
40
- tree,
41
- [repo.head.target, remote_master_id])
42
- # We need to do this or git CLI will think we are still merging.
43
- repo.state_cleanup()
44
- else:
45
- raise AssertionError('Unknown merge analysis result')
46
-
47
- pygit2.option(pygit2.GIT_OPT_SET_OWNER_VALIDATION, 0)
48
- repo_path = str(sys.argv[1])
49
- repo = pygit2.Repository(repo_path)
50
- ident = pygit2.Signature('comfyui', 'comfy@ui')
51
- try:
52
- print("stashing current changes") # noqa: T201
53
- repo.stash(ident)
54
- except KeyError:
55
- print("nothing to stash") # noqa: T201
56
- backup_branch_name = 'backup_branch_{}'.format(datetime.today().strftime('%Y-%m-%d_%H_%M_%S'))
57
- print("creating backup branch: {}".format(backup_branch_name)) # noqa: T201
58
- try:
59
- repo.branches.local.create(backup_branch_name, repo.head.peel())
60
- except:
61
- pass
62
-
63
- print("checking out master branch") # noqa: T201
64
- branch = repo.lookup_branch('master')
65
- if branch is None:
66
- try:
67
- ref = repo.lookup_reference('refs/remotes/origin/master')
68
- except:
69
- print("pulling.") # noqa: T201
70
- pull(repo)
71
- ref = repo.lookup_reference('refs/remotes/origin/master')
72
- repo.checkout(ref)
73
- branch = repo.lookup_branch('master')
74
- if branch is None:
75
- repo.create_branch('master', repo.get(ref.target))
76
- else:
77
- ref = repo.lookup_reference(branch.name)
78
- repo.checkout(ref)
79
-
80
- print("pulling latest changes") # noqa: T201
81
- pull(repo)
82
-
83
- if "--stable" in sys.argv:
84
- def latest_tag(repo):
85
- versions = []
86
- for k in repo.references:
87
- try:
88
- prefix = "refs/tags/v"
89
- if k.startswith(prefix):
90
- version = list(map(int, k[len(prefix):].split(".")))
91
- versions.append((version[0] * 10000000000 + version[1] * 100000 + version[2], k))
92
- except:
93
- pass
94
- versions.sort()
95
- if len(versions) > 0:
96
- return versions[-1][1]
97
- return None
98
- latest_tag = latest_tag(repo)
99
- if latest_tag is not None:
100
- repo.checkout(latest_tag)
101
-
102
- print("Done!") # noqa: T201
103
-
104
- self_update = True
105
- if len(sys.argv) > 2:
106
- self_update = '--skip_self_update' not in sys.argv
107
-
108
- update_py_path = os.path.realpath(__file__)
109
- repo_update_py_path = os.path.join(repo_path, ".ci/update_windows/update.py")
110
-
111
- cur_path = os.path.dirname(update_py_path)
112
-
113
-
114
- req_path = os.path.join(cur_path, "current_requirements.txt")
115
- repo_req_path = os.path.join(repo_path, "requirements.txt")
116
-
117
-
118
- def files_equal(file1, file2):
119
- try:
120
- return filecmp.cmp(file1, file2, shallow=False)
121
- except:
122
- return False
123
-
124
- def file_size(f):
125
- try:
126
- return os.path.getsize(f)
127
- except:
128
- return 0
129
-
130
-
131
- if self_update and not files_equal(update_py_path, repo_update_py_path) and file_size(repo_update_py_path) > 10:
132
- shutil.copy(repo_update_py_path, os.path.join(cur_path, "update_new.py"))
133
- exit()
134
-
135
- if not os.path.exists(req_path) or not files_equal(repo_req_path, req_path):
136
- import subprocess
137
- try:
138
- subprocess.check_call([sys.executable, '-s', '-m', 'pip', 'install', '-r', repo_req_path])
139
- shutil.copy(repo_req_path, req_path)
140
- except:
141
- pass
142
-
143
-
144
- stable_update_script = os.path.join(repo_path, ".ci/update_windows/update_comfyui_stable.bat")
145
- stable_update_script_to = os.path.join(cur_path, "update_comfyui_stable.bat")
146
-
147
- try:
148
- if not file_size(stable_update_script_to) > 10:
149
- shutil.copy(stable_update_script, stable_update_script_to)
150
- except:
151
- pass