soiz1 commited on
Commit
c97eb56
·
verified ·
1 Parent(s): 5af60be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -17
app.py CHANGED
@@ -1,10 +1,10 @@
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"
@@ -12,31 +12,34 @@ exclude = {
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)
 
1
  from huggingface_hub import HfApi
2
 
3
+ # 対象のスペース
4
  repo_id = "soiz1/s4s-editor"
5
+ repo_type = "space"
6
 
7
+ # 除外する最初のコミットID
8
  exclude = {
9
  "d597f12958d455343f3e615926b940275157dd6a",
10
  "6bcb42f9f3a292e3ee572372ca4dd19054e51b3f"
 
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
+
21
  for commit in commits:
22
+ commit_id = commit.commit_id
23
+ if commit_id in exclude:
24
  continue
25
+
26
+ # 差分を取得
27
  diff = api.get_commit_diff(
28
  repo_id=repo_id,
29
  repo_type=repo_type,
30
+ revision=commit_id
31
  )
32
+
33
+ # 差分からファイルを抽出
34
  for line in diff.splitlines():
35
  if line.startswith("diff --git"):
36
  parts = line.split()
37
+ if len(parts) >= 4:
38
+ a = parts[2][2:] # a/xxx
39
+ b = parts[3][2:] # b/xxx
40
+ files.add(a if a == b else a)
41
+
42
+ # 結果を表示
43
+ print("修正されたファイル一覧(除外コミット以外):")
 
44
  for f in sorted(files):
45
  print(f)