|
| 1 | +--- |
| 2 | +name: net-http-tools |
| 3 | +description: Tools for interacting with the google/net_http repository. |
| 4 | +--- |
| 5 | + |
| 6 | +# Net HTTP Tools |
| 7 | + |
| 8 | +This skill contains utilities for working with the `google/net_http` repository. |
| 9 | + |
| 10 | +## Capabilities |
| 11 | + |
| 12 | +### 1. Setup |
| 13 | + |
| 14 | +Sets up the repository in your local environment. |
| 15 | + |
| 16 | +**Goal:** |
| 17 | + |
| 18 | +The `google/net_http` repository is successfully set up on the local machine when: |
| 19 | +1. The `gh` CLI is installed and authenticated. |
| 20 | +2. The repository is cloned into `~/github/net_http`. |
| 21 | +3. The `origin` remote points to the user's fork. |
| 22 | +4. The `upstream` remote points to `https://github.com/google/net_http`. |
| 23 | + |
| 24 | +**Instructions:** |
| 25 | + |
| 26 | +(Skip these steps if the Goal is already met) |
| 27 | + |
| 28 | +1. **Check for GitHub CLI (`gh`)** |
| 29 | + Check if `gh` is installed. |
| 30 | + ```bash |
| 31 | + which gh |
| 32 | + ``` |
| 33 | + |
| 34 | +2. **Install GitHub CLI (if missing)** |
| 35 | + If `gh` is **NOT** installed, **STOP** and ask the user to run the following |
| 36 | + commands manually. |
| 37 | + **The agent should not run these commands.** |
| 38 | + ```bash |
| 39 | + sudo glinux-add-repo -c github-cli stable && \ |
| 40 | + sudo apt update && \ |
| 41 | + sudo apt install gh |
| 42 | + ``` |
| 43 | + |
| 44 | +3. **Authenticate GitHub CLI** |
| 45 | + Once `gh` is installed, ensure you are authenticated. |
| 46 | + ```bash |
| 47 | + gh auth login |
| 48 | + ``` |
| 49 | + |
| 50 | +4. **Create Directory** |
| 51 | + Ensure the `~/github` directory exists. |
| 52 | + ```bash |
| 53 | + mkdir -p ~/github |
| 54 | + ``` |
| 55 | + |
| 56 | +5. **Fork Repository** |
| 57 | + Ask the user to fork `https://github.com/google/net_http` if they haven't |
| 58 | + already. |
| 59 | + Then, ask the user for the URL of their personal fork (e.g., |
| 60 | + `https://github.com/USERNAME/net_http`). |
| 61 | +
|
| 62 | +6. **Clone Fork** |
| 63 | + Clone the user's fork into `~/github/net_http`. |
| 64 | + Replace `<USER_FORK_URL>` with the URL provided by the user. |
| 65 | + ```bash |
| 66 | + gh repo clone <USER_FORK_URL> ~/github/net_http |
| 67 | + ``` |
| 68 | + |
| 69 | +7. **Add Upstream Remote** |
| 70 | + Navigate to the repository and add the upstream remote. |
| 71 | + ```bash |
| 72 | + cd ~/github/net_http |
| 73 | + git remote add upstream https://github.com/google/net_http |
| 74 | + git remote -v |
| 75 | + ``` |
| 76 | + |
| 77 | +### 2. Sync Main |
| 78 | + |
| 79 | +Syncs the local `main` branch with the `upstream` repository. |
| 80 | + |
| 81 | +**Goal:** |
| 82 | + |
| 83 | +The local `main` branch is up-to-date with `upstream/main`. |
| 84 | + |
| 85 | +**Instructions:** |
| 86 | + |
| 87 | +1. **Sync Main Branch** |
| 88 | + Run the following command to sync `main`. If the local `main` has diverged |
| 89 | + from `upstream/main`, it will be renamed to `main_backup_<timestamp>` and |
| 90 | + reset to match upstream. |
| 91 | + ```bash |
| 92 | + cd ~/github/net_http |
| 93 | + git remote prune origin && git remote update && git checkout main |
| 94 | +
|
| 95 | + if [ "$(git rev-list --count upstream/main..main)" -gt 0 ]; then |
| 96 | + BACKUP="main_backup_$(date +%Y%m%d_%H%M)" |
| 97 | + echo "Local main has diverged. Renaming to $BACKUP and resetting to upstream/main." |
| 98 | + git branch -m "$BACKUP" |
| 99 | + git checkout -b main upstream/main |
| 100 | + git push -u origin main --force-with-lease |
| 101 | + else |
| 102 | + git pull upstream main |
| 103 | + git push -u origin main |
| 104 | + fi |
| 105 | + ``` |
0 commit comments