完成git的功能
This commit is contained in:
@@ -135,13 +135,27 @@ class RemoteCommandsTab(QWidget):
|
||||
git_layout.addLayout(install_git_layout)
|
||||
|
||||
# 克隆项目
|
||||
clone_layout = QFormLayout()
|
||||
self.repo_url_input = QLineEdit()
|
||||
clone_layout.addRow("仓库URL:", self.repo_url_input)
|
||||
clone_layout = QHBoxLayout()
|
||||
|
||||
# 左侧:仓库URL和目录信息
|
||||
left_layout = QFormLayout()
|
||||
self.repo_url_input = QLineEdit()
|
||||
left_layout.addRow("仓库URL:", self.repo_url_input)
|
||||
|
||||
self.remote_dir_display = QLineEdit()
|
||||
self.remote_dir_display.setReadOnly(True)
|
||||
left_layout.addRow("远程目录:", self.remote_dir_display)
|
||||
|
||||
clone_layout.addLayout(left_layout)
|
||||
|
||||
# 右侧:按钮
|
||||
right_layout = QVBoxLayout()
|
||||
self.clone_button = QPushButton("克隆项目")
|
||||
self.clone_button.clicked.connect(self.clone_repository)
|
||||
clone_layout.addRow(self.clone_button)
|
||||
right_layout.addWidget(self.clone_button)
|
||||
right_layout.addStretch()
|
||||
|
||||
clone_layout.addLayout(right_layout)
|
||||
|
||||
git_layout.addLayout(clone_layout)
|
||||
git_group.setLayout(git_layout)
|
||||
@@ -180,6 +194,11 @@ class RemoteCommandsTab(QWidget):
|
||||
self.status_label.setText("未连接到服务器")
|
||||
self.status_label.setStyleSheet("color: red;")
|
||||
|
||||
def set_server_config(self, git_url, remote_dir):
|
||||
logger.info(f"设置服务器配置: git_url={git_url}, remote_dir={remote_dir}")
|
||||
self.repo_url_input.setText(git_url)
|
||||
self.remote_dir_display.setText(remote_dir)
|
||||
|
||||
def install_git(self):
|
||||
logger.info("安装Git")
|
||||
|
||||
@@ -224,11 +243,20 @@ class RemoteCommandsTab(QWidget):
|
||||
QMessageBox.warning(self, "警告", "请输入仓库URL")
|
||||
return
|
||||
|
||||
remote_dir = self.remote_dir_display.text().strip()
|
||||
|
||||
self.output_text.clear()
|
||||
self.status_label.setText("正在克隆仓库...")
|
||||
|
||||
# 构建克隆命令
|
||||
if remote_dir:
|
||||
# 如果指定了远程目录,先创建目录(如果不存在),然后克隆到指定目录
|
||||
clone_command = f"mkdir -p {remote_dir} && cd {remote_dir} && git clone {repo_url}"
|
||||
else:
|
||||
clone_command = f"git clone {repo_url}"
|
||||
|
||||
# 创建并启动线程执行命令
|
||||
self.command_thread = RemoteCommandThread(self.ssh_client, f"git clone {repo_url}")
|
||||
self.command_thread = RemoteCommandThread(self.ssh_client, clone_command)
|
||||
self.command_thread.output_signal.connect(self.append_output)
|
||||
self.command_thread.finished_signal.connect(self.on_command_finished)
|
||||
self.command_thread.start()
|
||||
|
||||
Reference in New Issue
Block a user