add option for recursive cloning
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ from huggingface_hub.utils import HfHubHTTPError
|
|
7 |
api = HfApi()
|
8 |
|
9 |
|
10 |
-
def process(git_repo_url, space_destination, user_token, space_sdk):
|
11 |
|
12 |
your_username = api.whoami(token=user_token)["name"]
|
13 |
|
@@ -21,8 +21,8 @@ def process(git_repo_url, space_destination, user_token, space_sdk):
|
|
21 |
# Create a temporary directory to clone the repository
|
22 |
tmp_dir = tempfile.mkdtemp()
|
23 |
|
24 |
-
# Clone the
|
25 |
-
repo = Repo.clone_from(git_repo_url, tmp_dir)
|
26 |
|
27 |
# Check if README.md already exists in tmp_dir
|
28 |
readme_path = os.path.join(tmp_dir, "README.md")
|
@@ -96,10 +96,20 @@ with gr.Blocks(css=css) as demo:
|
|
96 |
with gr.Column(elem_id="col-container"):
|
97 |
gr.Markdown("# Clone GitHub repo to Space")
|
98 |
with gr.Group():
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
with gr.Row():
|
104 |
space_destination = gr.Textbox(
|
105 |
label="Space ID",
|
@@ -122,7 +132,7 @@ with gr.Blocks(css=css) as demo:
|
|
122 |
|
123 |
submit_btn.click(
|
124 |
fn=process,
|
125 |
-
inputs=[git_repo_url, space_destination, user_token, space_sdk],
|
126 |
outputs=[status]
|
127 |
)
|
128 |
|
|
|
7 |
api = HfApi()
|
8 |
|
9 |
|
10 |
+
def process(git_repo_url, recursive_bool, space_destination, user_token, space_sdk):
|
11 |
|
12 |
your_username = api.whoami(token=user_token)["name"]
|
13 |
|
|
|
21 |
# Create a temporary directory to clone the repository
|
22 |
tmp_dir = tempfile.mkdtemp()
|
23 |
|
24 |
+
# Clone the Git repository
|
25 |
+
repo = Repo.clone_from(git_repo_url, tmp_dir, recursive=recursive_bool)
|
26 |
|
27 |
# Check if README.md already exists in tmp_dir
|
28 |
readme_path = os.path.join(tmp_dir, "README.md")
|
|
|
96 |
with gr.Column(elem_id="col-container"):
|
97 |
gr.Markdown("# Clone GitHub repo to Space")
|
98 |
with gr.Group():
|
99 |
+
with gr.Row():
|
100 |
+
|
101 |
+
git_repo_url = gr.Textbox(
|
102 |
+
label="Git repo URL to clone",
|
103 |
+
placeholder="https://github.com/username/my-repo.git",
|
104 |
+
scale=3
|
105 |
+
)
|
106 |
+
|
107 |
+
recursive_mode = gr.Checkbox(
|
108 |
+
label="Recursive mode",
|
109 |
+
value=False,
|
110 |
+
scale=1
|
111 |
+
)
|
112 |
+
|
113 |
with gr.Row():
|
114 |
space_destination = gr.Textbox(
|
115 |
label="Space ID",
|
|
|
132 |
|
133 |
submit_btn.click(
|
134 |
fn=process,
|
135 |
+
inputs=[git_repo_url, recursive_mode, space_destination, user_token, space_sdk],
|
136 |
outputs=[status]
|
137 |
)
|
138 |
|