File size: 2,563 Bytes
c7dc4b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os
import subprocess

def main():
    files_to_delete = [
        "stitch_merchflow_ai_dashboard.zip",
        "screen.jpg",
        "test_image.jpg"
    ]
    
    # Delete Local Binaries
    print("Deleting local binaries...")
    for filename in files_to_delete:
        try:
            os.remove(filename)
            print(f"Deleted: {filename}")
        except FileNotFoundError:
            print(f"File not found (already deleted): {filename}")
        except Exception as e:
            print(f"Error deleting {filename}: {e}")
            
    # Update .gitignore
    print("Updating .gitignore...")
    gitignore_path = ".gitignore"
    
    # Read existing content to avoid duplicate entries
    existing_ignores = []
    try:
        if os.path.exists(gitignore_path):
            with open(gitignore_path, "r", encoding="utf-8") as f:
                existing_ignores = f.read().splitlines()
    except Exception as e:
        print(f"Warning: Could not read .gitignore: {e}")
        
    ignores_to_add = ["*.zip", "*.jpg"]
    
    try:
        with open(gitignore_path, "a", encoding="utf-8") as f:
            for ignore in ignores_to_add:
                if ignore not in existing_ignores:
                    # add a newline if files doesn't end with one, but simplier to just write
                    f.write(f"\n{ignore}\n")
                    print(f"Added '{ignore}' to .gitignore")
                else:
                    print(f"'{ignore}' already in .gitignore")
    except Exception as e:
        print(f"Error updating .gitignore: {e}")

    # The Orphan Branch Strategy
    print("\nExecuting Git Orphan Branch Strategy...")
    
    commands = [
        "git checkout --orphan hf_clean_deploy_v2",
        "git add .",
        'git commit -m "UI Update: Glassmorphism Design & Binary Cleanup"'
    ]
    
    for cmd in commands:
        print(f"Running: {cmd}")
        subprocess.run(cmd, shell=True, check=False)
        
    push_cmd = "git push --force space hf_clean_deploy_v2:main"
    print(f"\nRunning final push command: {push_cmd}")
    
    result = subprocess.run(push_cmd, shell=True, capture_output=True, text=True)
    
    # Expected Output
    print("\n--- Push Command STDOUT ---")
    print(result.stdout)
    print("--- Push Command STDERR ---")
    print(result.stderr)
    print("---------------------------\n")

    if result.returncode == 0:
        print("✅ Force push successful!")
    else:
        print("❌ Force push failed (see STDERR above).")

if __name__ == "__main__":
    main()