soiz1 commited on
Commit
ba9093b
·
verified ·
1 Parent(s): ececdd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -16,17 +16,25 @@ authed_url = repo_url.replace("https://", f"https://{token}@")
16
  # カレントディレクトリのパス
17
  current_dir = os.getcwd()
18
 
 
19
  subprocess.run(["git", "config", "--global", "user.name", "izum00"], check=True)
20
- subprocess.run(["git", "config", "--global", "user.email", os.getenv("mail")], check=True)
 
 
 
21
 
 
22
  subprocess.run(["git", "config", "--global", "--add", "safe.directory", "/app"], check=True)
23
 
24
- # .gitディレクトリがなければ初期化
25
- if not os.path.exists(os.path.join(current_dir, ".git")):
26
- subprocess.run(["git", "init"], check=True)
27
- subprocess.run(["git", "remote", "add", "origin", authed_url], check=True)
28
- else:
29
- subprocess.run(["git", "remote", "set-url", "origin", authed_url], check=True)
 
 
 
30
 
31
  # Gitの操作
32
  subprocess.run(["git", "add", "."], check=True)
 
16
  # カレントディレクトリのパス
17
  current_dir = os.getcwd()
18
 
19
+ # Gitユーザー情報の設定
20
  subprocess.run(["git", "config", "--global", "user.name", "izum00"], check=True)
21
+ subprocess.run([
22
+ "git", "config", "--global", "user.email",
23
+ os.getenv("mail") or "[email protected]"
24
+ ], check=True)
25
 
26
+ # Gitの安全設定
27
  subprocess.run(["git", "config", "--global", "--add", "safe.directory", "/app"], check=True)
28
 
29
+ # .gitが存在していれば削除(Gitオブジェクト壊れ防止)
30
+ git_dir = os.path.join(current_dir, ".git")
31
+ if os.path.exists(git_dir):
32
+ shutil.rmtree(git_dir)
33
+
34
+ # Gitの初期化とLFSの初期化(LFSが導入されていることが前提)
35
+ subprocess.run(["git", "init"], check=True)
36
+ subprocess.run(["git", "lfs", "install"], check=True) # LFSが使われているなら必要
37
+ subprocess.run(["git", "remote", "add", "origin", authed_url], check=True)
38
 
39
  # Gitの操作
40
  subprocess.run(["git", "add", "."], check=True)