Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/gitee provider #1403

Closed

Conversation

Sourabh7iwari
Copy link
Contributor

@Sourabh7iwari Sourabh7iwari commented Nov 30, 2024

Add Gitee Git Provider Support

This PR adds comprehensive Gitee integration to Daytona's git provider system, enabling users to work with Gitee repositories seamlessly.

Features Added

URL Support

  • HTTPS URLs (https://gitee.com/owner/repo)
  • SSH URLs ([email protected]:owner/repo.git)
  • Branch-specific URLs (/tree/branch)
  • Commit-specific URLs (/commit/sha)
  • Pull request URLs (/pulls/number)
  • File/blob URLs (/blob/branch/path)

Core Functionality

  • Repository context parsing
  • Personal and organization repository listing
  • Proper authentication handling
  • Pagination support for repository lists

Implementation Details

New Files

  • pkg/gitprovider/gitee.go: Main Gitee provider implementation
  • pkg/gitprovider/gitee_test.go: Comprehensive test suite

Key Components

  1. CanHandle: Smart URL detection for Gitee repositories
  2. ParseStaticGitContext: Robust URL parsing with support for all Gitee URL formats
  3. GetRepositories: Repository listing with personal/org namespace support
  4. GetUser: User information retrieval
  5. GetNamespaces: Namespace management

Testing

  • Comprehensive test coverage for all components
  • Mock HTTP server for API testing
  • Edge case handling
  • Error scenarios covered
  • Testing result
cd pkg/gitprovider && go test -v -run "Gitee"
=== RUN   TestGiteeCanHandle
=== RUN   TestGiteeCanHandle/valid_Gitee_HTTPS_URL
=== RUN   TestGiteeCanHandle/valid_Gitee_SSH_URL
=== RUN   TestGiteeCanHandle/invalid_GitHub_URL
--- PASS: TestGiteeCanHandle (0.00s)
    --- PASS: TestGiteeCanHandle/valid_Gitee_HTTPS_URL (0.00s)
    --- PASS: TestGiteeCanHandle/valid_Gitee_SSH_URL (0.00s)
    --- PASS: TestGiteeCanHandle/invalid_GitHub_URL (0.00s)
=== RUN   TestGiteeGetUser
--- PASS: TestGiteeGetUser (0.00s)
=== RUN   TestGiteeGetNamespaces
--- PASS: TestGiteeGetNamespaces (0.00s)
=== RUN   TestGiteeGetRepositories
=== RUN   TestGiteeGetRepositories/personal_repositories
=== NAME  TestGiteeGetRepositories
    gitee_test.go:215: Request path: /api/v5/user/repos
=== RUN   TestGiteeGetRepositories/organization_repositories
=== NAME  TestGiteeGetRepositories
    gitee_test.go:215: Request path: /api/v5/orgs/testorg/repos
--- PASS: TestGiteeGetRepositories (0.00s)
    --- PASS: TestGiteeGetRepositories/personal_repositories (0.00s)
    --- PASS: TestGiteeGetRepositories/organization_repositories (0.00s)
=== RUN   TestGiteeParseStaticGitContext
=== RUN   TestGiteeParseStaticGitContext/Basic_repository_URL
=== RUN   TestGiteeParseStaticGitContext/SSH_repository_URL
=== RUN   TestGiteeParseStaticGitContext/Repository_URL_with_branch
=== RUN   TestGiteeParseStaticGitContext/Repository_URL_with_commit
=== RUN   TestGiteeParseStaticGitContext/Repository_URL_with_pull_request
--- PASS: TestGiteeParseStaticGitContext (0.00s)
    --- PASS: TestGiteeParseStaticGitContext/Basic_repository_URL (0.00s)
    --- PASS: TestGiteeParseStaticGitContext/SSH_repository_URL (0.00s)
    --- PASS: TestGiteeParseStaticGitContext/Repository_URL_with_branch (0.00s)
    --- PASS: TestGiteeParseStaticGitContext/Repository_URL_with_commit (0.00s)
    --- PASS: TestGiteeParseStaticGitContext/Repository_URL_with_pull_request (0.00s)
=== RUN   TestGiteeGetUrlFromRepo
=== RUN   TestGiteeGetUrlFromRepo/URL_without_branch
=== RUN   TestGiteeGetUrlFromRepo/URL_with_branch
--- PASS: TestGiteeGetUrlFromRepo (0.00s)
    --- PASS: TestGiteeGetUrlFromRepo/URL_without_branch (0.00s)
    --- PASS: TestGiteeGetUrlFromRepo/URL_with_branch (0.00s)
PASS
ok      github.com/daytonaio/daytona/pkg/gitprovider    0.022s

Security Considerations

  • Secure token handling
  • Input validation
  • Proper error handling

Breaking Changes

None. This is an additive change that extends Daytona's git provider support.

Documentation

The implementation follows existing patterns in Daytona's git provider system, making it familiar to maintainers and users.

Reviewer Notes

  • The implementation aligns with existing git provider patterns
  • Test coverage includes all major use cases
  • Error handling follows established patterns
  • API endpoint handling matches Gitee's API structure

Related Issues

Closes #1341 - Add Gitee support to Daytona

Future Considerations

  • Potential webhook support
  • Advanced API integrations
  • Performance optimizations

Testing Instructions

cd pkg/gitprovider && go test -v -run "Gitee"

@quest-bot loot #1341

Copy link

quest-bot bot commented Nov 30, 2024

Quest PR submitted! image Quest PR submitted!

@Sourabh7iwari, you are attempting to solve the issue and loot this Quest. Will you be successful?


Questions? Check out the docs.

@Sourabh7iwari Sourabh7iwari force-pushed the feature/gitee-provider branch 2 times, most recently from 9e10975 to 87e3090 Compare November 30, 2024 18:00
@mojafa
Copy link
Collaborator

mojafa commented Dec 2, 2024

@Sourabh7iwari could you please share screenshots of how your solution works?

Screenshot 2024-12-02 at 15 44 40

@mojafa
Copy link
Collaborator

mojafa commented Dec 2, 2024

Also I'm getting this error, yet I created a Gitee account and pasted my personal access token.

Screenshot 2024-12-02 at 15 49 26

@Sourabh7iwari
Copy link
Contributor Author

Sourabh7iwari commented Dec 2, 2024

@mojafa Pardon me Sir i hadn't committed the gitee registration in service.go, newGitProvider method, and now after rectifying. it. it working fine I guess.
Thanks for pointing out. i hope it doesn't cause any problem now.
Screenshot from 2024-12-02 19-07-56

- Add Gitee provider with URL parsing support
- Implement repository listing and user management
- Add comprehensive test coverage
- Support both HTTPS and SSH URLs

Signed-off-by: Sourabh Tiwari <[email protected]>
@Sourabh7iwari Sourabh7iwari force-pushed the feature/gitee-provider branch from e303289 to 17bd784 Compare December 2, 2024 14:16
@mojafa
Copy link
Collaborator

mojafa commented Dec 3, 2024

@Sourabh7iwari having a look

@Sourabh7iwari
Copy link
Contributor Author

@mojafa thanks sir but i think @tarunrajput sir has done better job then me
Its my first time doing oss collaboration thats I didn't do it properly.

@mojafa
Copy link
Collaborator

mojafa commented Dec 3, 2024

@Sourabh7iwari good stuff so far, i was able to add the GItee git-provider, see below. However creating a workspace from the daytona create url in this case my url was https://gitee.com/mojafa/sample-julia.git i got an error. I also got an error on the text-based ui (TUI) when i entered the command daytona create.
Screenshot 2024-12-03 at 13 24 22
Screenshot 2024-12-03 at 13 25 47

@mojafa
Copy link
Collaborator

mojafa commented Dec 3, 2024

Hey @Sourabh7iwari
Just wanted to let you know that Tarun's PR (#1409) is now complete, and we’ll be moving forward with that one.

As a starting point, I’d like you to focus on tackling the following instead:

Additionally, you can refer to PR #1284 for inspiration.

Let me know if you have any questions or need further clarification.

@Tpuljak
Copy link
Member

Tpuljak commented Dec 3, 2024

Closing per #1403 (comment)

@Tpuljak Tpuljak closed this Dec 3, 2024
@Sourabh7iwari Sourabh7iwari deleted the feature/gitee-provider branch December 3, 2024 15:46
@Sourabh7iwari
Copy link
Contributor Author

@mojafa ohh this PR #1284 guidance is very much helpfull.
I'll try to tackle any next issue in more compliant way and free from error.
Thanks

Copy link

quest-bot bot commented Dec 5, 2024

🧚 Another solver has looted Quest #1341, but your efforts have not gone unnoticed.

Go to https://quira.sh/quests/solver to find a new adventure 🗡

Questions? Check out the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚔️ Quest Tracks quest-bot quests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggestion to Add Support for Gitee in Git Provider or More Customization Options
3 participants