Skip to content

Conversation

@yashin-luo
Copy link

Gitee (https://gitee.com/) is a major code hosting platform in China, often compared to GitHub.
Supporting Gitee as a provider will benefit many Chinese developers.

resolves #241

@aguegu
Copy link

aguegu commented Nov 10, 2025

Good to have this.

Enable efficient partial downloads from Gitee repositories by leveraging their
directory-specific tarball generation API. This significantly reduces download
times and bandwidth usage when targeting subdirectories within large repos.
@aguegu
Copy link

aguegu commented Nov 24, 2025

I would provide a script for anyone need this feature before this PR being merged.

import { downloadTemplate } from "giget";

const gitee = (input, { auth }) => {
  const { repo, ref, subdir = '/' } = input.match(/^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w./@-]+)?/).groups;
  const version = ref ? ref.slice(1) : 'main';
  return {
    name: repo.replace('/', '-'),
    version,
    subdir,
    headers: {
      Authorization: auth ? `token ${auth}` : undefined,
    },
    url: `https://gitee.com/${repo}/tree/${version}${subdir}`,
    tar: `https://gitee.com/api/v5/repos/${repo}/tarball?ref=${version}`,
  };
};

const { source, dir } = await downloadTemplate('gitee:<owner>/<repo>', {
  providers: { gitee },
  auth: '<token>',
});

auth is always required for gitee due to traffic control.
For public repos, auth token with only user_info scope would be sufficient.
For private repos, user_info and projects scopes in token would be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support for gitee.com

2 participants