Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

  • Understand the repository structure and existing commands
  • Implement upload subcommand with the core git operations
  • Update documentation with upload command usage
  • Remove unnecessary validation and directory restoration
  • Add optional targetFolder parameter for non-force push workflow
  • Refactor code based on review feedback (better scoping, concise commands)
  • Add optional localPath parameter to download command with smart defaults
  • Run code review and security checks (no issues found)

Summary

Upload Command (New)

Implemented upload subcommand with clean, maintainable code:

Basic Usage (Force Push)

xgit upload path/to/source-folder https://github.com/your-org/your-repo target-branch
  • Initializes git in source folder
  • Creates and force pushes new branch

Advanced Usage (Non-Force Push to Subdirectory)

xgit upload path/to/source-folder https://github.com/your-org/your-repo target-branch target/directory
  • Clones existing branch with git clone -b
  • Overwrites specific directory
  • Pushes without force

Download Command (Enhanced)

Added optional localPath parameter with intelligent defaults:

Usage Examples

# Download entire repo to current directory
xgit download https://github.com/your-org/your-repo main

# Download specific folder - automatically uses folder name as local destination
xgit download https://github.com/your-org/your-repo main src/components

# Override local destination path
xgit download https://github.com/your-org/your-repo main src/components ./my-components

Smart Default Behavior:

  • When downloading a specific folderOrFilePath, it uses that as the local destination by default
  • When downloading entire repo or when localPath is explicitly provided, uses that value
  • Falls back to current directory only when no specific path is given
  • Target path is determined after checking whether downloaded content is a file or directory

Code Quality

  • Proper variable scoping (tempFolder declared inside if)
  • Concise git commands (git clone -b instead of init/remote/pull/checkout)
  • No unnecessary options (removed overwrite flag)
  • Smart defaults: localPath = folderOrFilePath
  • Target path determined after file/directory check
  • Uses nullish coalescing for robust default handling
  • Follows consistent pattern across commands
  • All security checks passed
Original prompt

新增 upload 子命令,设计如下:

CLI 参数

git-utility upload https://some.git.server/path/to/repository target-branch source-folder

核心操作

cd source-folder
git init
git remote add origin https://some.git.server/path/to/repository
git checkout -b target-branch

Human changes

  1. [fix] some Folder bugs
  2. [optimize] update Upstream packages

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@TechQuery
Copy link
Member

@copilot #### 核心操作

cd source-folder
git init
git remote add origin https://some.git.server/path/to/repository
git checkout -b target-branch
git add .
git commit -m "upload by Git-utility CLI"
git push --set-upstream origin target-branch -f

Copilot AI and others added 2 commits November 22, 2025 18:49
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 22, 2025

@copilot #### 核心操作

Implemented the upload subcommand with all the core operations you specified. The implementation includes validation and error handling. See commit 9422972.

Copilot AI changed the title [WIP] Add upload subcommand for git utility Add upload subcommand for git utility Nov 22, 2025
Copilot finished work on behalf of TechQuery November 22, 2025 18:52
Copy link
Member

@TechQuery TechQuery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 最后加一个可选目标目录的参数,如果有特定目录,就先拉取、再覆盖,然后非强制推送。

Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 22, 2025

@copilot 最后加一个可选目标目录的参数,如果有特定目录,就先拉取、再覆盖,然后非强制推送。

Added optional targetFolder parameter. When specified, it pulls the branch first, overwrites the target directory, and pushes without force. See commit b8b4a98.

Copilot AI requested a review from TechQuery November 22, 2025 19:16
Copilot finished work on behalf of TechQuery November 22, 2025 19:16
Copy link
Member

@TechQuery TechQuery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copilot AI requested a review from TechQuery November 22, 2025 20:40
Copilot finished work on behalf of TechQuery November 22, 2025 20:40
Copy link
Member

@TechQuery TechQuery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 给下载子命令加一个末尾可选参数,用于指定下载的本地目标路径,这个参数的默认值就是源路径。

Copilot AI and others added 2 commits November 22, 2025 20:49
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 22, 2025

@copilot 给下载子命令加一个末尾可选参数,用于指定下载的本地目标路径,这个参数的默认值就是源路径。

Added optional localPath parameter to the download command. When not specified, downloads to current directory. See commits 01983de and 43f4c2c.

Copilot AI changed the title Add upload subcommand for git utility Add upload subcommand and enhance download command for git utility Nov 22, 2025
Copilot AI requested a review from TechQuery November 22, 2025 20:52
Copilot finished work on behalf of TechQuery November 22, 2025 20:52
Copy link
Member

@TechQuery TechQuery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…after download

Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copilot AI requested a review from TechQuery November 22, 2025 22:09
Copilot finished work on behalf of TechQuery November 22, 2025 22:09
[optimize] update Upstream packages
@TechQuery TechQuery changed the title Add upload subcommand and enhance download command for git utility [add] upload subcommand and support optional Target Folder for download subcommand Nov 22, 2025
@TechQuery TechQuery marked this pull request as ready for review November 22, 2025 23:31
@TechQuery TechQuery merged commit cbe58d3 into master Nov 22, 2025
@github-project-automation github-project-automation bot moved this from In progress to Done in 开源项目 Nov 22, 2025
@TechQuery TechQuery deleted the copilot/add-upload-subcommand branch November 24, 2025 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants