Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ go run . user info

### Test Git operations
```bash
go run . clone john/my-project
go run . clone john/my-project # Clone from another user
go run . clone my-project # Clone from logged-in user
go run . push
go run . fetch
go run . pull
Expand Down Expand Up @@ -177,7 +178,8 @@ The application uses OAuth2 device flow:
The CLI provides seamless Git integration with JuliaHub authentication through two approaches:

### Method 1: JuliaHub CLI Wrapper Commands
- **Clone**: `jh clone username/project` - resolves project names to UUIDs and clones with authentication
- **Clone**: `jh clone [username/]project` - resolves project names to UUIDs and clones with authentication
- Format: `jh clone username/project` or `jh clone project` (defaults to logged-in user)
- **Push/Fetch/Pull**: `jh push/fetch/pull [args...]` - wraps Git commands with authentication headers
- **Authentication**: Uses `http.extraHeader="Authorization: Bearer <id_token>"` for Git operations
- **Argument passthrough**: All Git arguments are passed through to underlying commands
Expand Down Expand Up @@ -271,6 +273,7 @@ jh run setup
- Multi-server authentication handled automatically via credential helper
- Project filtering supports `--user` parameter for showing specific user's projects or own projects
- Clone command automatically resolves `username/project` format to project UUIDs
- Clone command supports `project` (without username) and defaults to the logged-in user's username
- Folder naming conflicts are resolved with automatic numbering (project-1, project-2, etc.)
- Credential helper follows Git protocol: responds only to JuliaHub URLs, ignores others

Expand Down
9 changes: 8 additions & 1 deletion git.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,14 @@ func cloneProject(server, projectIdentifier, localPath string) error {
username = parts[0]
projectName = parts[1]
} else {
return fmt.Errorf("project identifier must be in format 'username/project'")
// No username provided, use the logged-in user's username
userInfo, err := getUserInfo(server)
if err != nil {
return fmt.Errorf("failed to get user info for default username: %w", err)
}
username = userInfo.Username
projectName = projectIdentifier
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

projectName = projectIdentifier
Is this intended ? Looks unrelated to PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

its an argument to the function, if you expand above

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but looks like its just assigned and not used anywhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the projectName is used right? in line 236

fmt.Printf("Using logged-in user '%s' as project owner\n", username)
}

// Find the project by username and project name
Expand Down