gitlab-org/gitlab
Snippets
Reusable code blobs. Each snippet is its own Git repository with one or more files; users can share them as gists.
Source
| Concern | Location |
|---|---|
| Models | app/models/snippet.rb, personal_snippet.rb, project_snippet.rb |
| Services | app/services/snippets/, app/services/spam/spam_action_service.rb (spam check) |
| Controllers | app/controllers/snippets_controller.rb, app/controllers/projects/snippets_controller.rb |
| API | lib/api/snippets.rb, lib/api/project_snippets.rb |
| GraphQL | app/graphql/types/snippet_type.rb, app/graphql/mutations/snippets/ |
| Gitaly access | lib/gitlab/git_access_snippet.rb, lib/gitlab/user_access_snippet.rb |
| Frontend | app/assets/javascripts/snippets/ |
Storage
Like wikis, snippets are real Git repositories. The repo has one or more files; users can git clone and push.
Visibility
A snippet has the visibility levels:
private— only the author.internal— any logged-in user.public— everyone.
Project snippets inherit the project's visibility constraints.
Spam protection
SpamActionService (app/services/spam/) integrates with Akismet and the gitlab-spamcheck service to flag suspicious snippets.
API
REST endpoints support full CRUD plus GET /raw for the snippet content.
Related
- Source code management — snippets share the Git infrastructure.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.