Update app.py
Browse files
app.py
CHANGED
@@ -1,67 +1,42 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
@app.route("/")
|
44 |
-
def index():
|
45 |
-
return f'''
|
46 |
-
<h2>ZIPファイルをダウンロード</h2>
|
47 |
-
<a href="/download">examplemods.zip をダウンロード</a>
|
48 |
-
'''
|
49 |
-
|
50 |
-
@app.route("/download")
|
51 |
-
def download_file():
|
52 |
-
return send_file(zip_name, as_attachment=True)
|
53 |
-
|
54 |
-
def start_flask():
|
55 |
-
app.run(host="0.0.0.0", port=7860)
|
56 |
-
|
57 |
-
if __name__ == "__main__":
|
58 |
-
try:
|
59 |
-
download_directory()
|
60 |
-
zip_directory()
|
61 |
-
finally:
|
62 |
-
shutil.rmtree(temp_dir)
|
63 |
-
|
64 |
-
print("ローカルサーバーを起動中... http://localhost:8000/")
|
65 |
-
Thread(target=start_flask).start()
|
66 |
-
|
67 |
-
input("Enterで終了します。")
|
|
|
1 |
+
from huggingface_hub import HfApi
|
2 |
+
|
3 |
+
# スペースのリポジトリ情報
|
4 |
+
repo_id = "soiz1/s4s-editor"
|
5 |
+
repo_type = "space" # "model" や "dataset" ではなく "space" を指定
|
6 |
+
|
7 |
+
# 除外したい最初のコミットSHA
|
8 |
+
exclude = {
|
9 |
+
"d597f12958d455343f3e615926b940275157dd6a",
|
10 |
+
"6bcb42f9f3a292e3ee572372ca4dd19054e51b3f"
|
11 |
+
}
|
12 |
+
|
13 |
+
api = HfApi()
|
14 |
+
|
15 |
+
# コミット履歴の取得
|
16 |
+
commits = api.list_repo_commits(repo_id=repo_id, repo_type=repo_type)
|
17 |
+
|
18 |
+
# 除外コミット以外の変更されたファイルを格納
|
19 |
+
files = set()
|
20 |
+
for commit in commits:
|
21 |
+
sha = commit.sha
|
22 |
+
if sha in exclude:
|
23 |
+
continue
|
24 |
+
diff = api.get_commit_diff(
|
25 |
+
repo_id=repo_id,
|
26 |
+
repo_type=repo_type,
|
27 |
+
revision=sha
|
28 |
+
)
|
29 |
+
# diff は "diff --git a/path/to/file b/path/to/file" のような形式
|
30 |
+
for line in diff.splitlines():
|
31 |
+
if line.startswith("diff --git"):
|
32 |
+
parts = line.split()
|
33 |
+
# a/… と b/… からファイルパスを抽出
|
34 |
+
a = parts[2][2:]
|
35 |
+
b = parts[3][2:]
|
36 |
+
# 同じなら片方だけ使う
|
37 |
+
files.add(a if a == b else a)
|
38 |
+
|
39 |
+
# 結果の表示
|
40 |
+
print("修正されたファイル一覧(重複除外、指定コミットは除く):")
|
41 |
+
for f in sorted(files):
|
42 |
+
print(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|