NovitàCoding dal vivo: un link per chi si candida, una sandbox condivisa per tutti.Guardala ↓
KendorDocs

How to import one folder or branch of a repository

For owners and editors ·

Questo articolo non è ancora tradotto, quindi è mostrato in inglese.

Paste the link to a folder or branch page from your Git host. Kendor imports only that part and makes the folder the root of the candidate's project.

To import part of a repository, open the folder or branch on your Git host, copy the link from the browser's address bar, and paste it into the repository field instead of the plain repository link. Kendor reads the branch and folder from the link, imports only that folder, and makes it the root of the candidate's project.

This suits monorepos, repositories that keep several exercises side by side, and challenges that live on their own branch.

The branch can also be a tag or a full commit hash. The folder part is optional: leave it off to import the whole repository at that branch.

Host Branch or folder link
GitHub and GitHub Enterprise Server https://github.com/<owner>/<repo>/tree/<branch>/<folder>
GitLab and GitLab self-managed https://gitlab.com/<group>/<repo>/-/tree/<branch>/<folder>
Bitbucket https://bitbucket.org/<workspace>/<repo>/src/<branch>/<folder>
Gitea and Forgejo https://git.example.com/<owner>/<repo>/src/branch/<branch>/<folder>

For Gitea and Forgejo, use src/tag/<tag> for a tag and src/commit/<hash> for a commit. GitLab links can include subgroups, such as gitlab.com/acme/backend/platform/-/tree/main/services/api.

Links to a single file, such as GitHub /blob/ pages, aren't accepted.

Examples

A Node.js service in a monorepo on GitHub:

https://github.com/acme/platform/tree/main/services/api

Kendor imports services/api from the main branch. A file that was at services/api/package.json in the repository is at package.json in the challenge.

A tagged release of a GitLab project, whole repository:

https://gitlab.com/acme/rate-limiter/-/tree/v2.1.0

One exercise folder on Bitbucket:

https://bitbucket.org/acme/exercises/src/main/booking-api

A pinned commit on a Gitea server:

https://git.example.com/acme/platform/src/commit/4f9c2e1d8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d/services/api

What re-rooting changes

The folder you link to becomes the top of the candidate's project. That affects a few things:

  • Run setup. Kendor looks for kendor.yaml at the root of the folder, not at the root of the repository. If the folder has none, Kendor detects the setup from the folder's own files, such as its package.json or go.mod.
  • Files outside the folder aren't included. If the folder depends on something elsewhere in the repository, such as a shared package or a lockfile at the repository root, the candidate won't have it. Import the parent folder instead, or copy what's needed into the folder.
  • Limits apply to the folder. The 5,000-file and 50 MB limits count only the folder's files, after dependency folders are left out. If a whole repository is too big, importing the folder you need is usually the fix.
  • The suggested title comes from the folder name, so services/booking-api suggests Booking Api. You can change it before adding.

The Check result shows the folder and the branch or commit after the repository name, so you can confirm what you're about to import before choosing Add challenge.

Branch names that contain a slash

In a link, Kendor treats the first segment after tree/ (or src/) as the branch and everything after it as the folder. A branch called feature/new-api would be read as the branch feature and the folder new-api.

For a branch like that:

  • On github.com, use the shorthand owner/repo@feature/new-api. This imports the whole repository at that branch, without picking a folder.
  • On any host, use a link with the commit hash instead of the branch name. Copy the hash of the latest commit on the branch and put it where the branch goes.

Common errors

  • No files found under "services/api" means the folder doesn't exist on that branch, or holds only dependency or build folders that Kendor leaves out. Check the spelling, including upper and lower case.
  • Repository or ref not found means the branch, tag or commit doesn't exist, or the repository is private. See Import a private repository.
  • Use a repository or /tree/<branch>/<folder> URL (or the GitLab, Bitbucket or Gitea equivalent) means the link points at something other than a repository, branch or folder, such as a file, a pull request or an issue.
Questo articolo ti è stato utile?