mirror of
https://github.com/tiktok/sparo.git
synced 2025-01-09 05:41:59 -05:00
1 line
9.7 KiB
JavaScript
1 line
9.7 KiB
JavaScript
|
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[739],{4699:(e,s,o)=>{o.r(s),o.d(s,{assets:()=>l,contentTitle:()=>t,default:()=>h,frontMatter:()=>n,metadata:()=>a,toc:()=>c});var i=o(678),r=o(4738);const n={title:"Sparo profiles"},t=void 0,a={id:"pages/guide/sparo_profiles",title:"Sparo profiles",description:"Background",source:"@site/docs/pages/guide/sparo_profiles.md",sourceDirName:"pages/guide",slug:"/pages/guide/sparo_profiles",permalink:"/sparo/_preview/pr-76/pages/guide/sparo_profiles",draft:!1,unlisted:!1,editUrl:"https://github.com/tiktok/sparo/tree/main/apps/website/docs/pages/guide/sparo_profiles.md",tags:[],version:"current",frontMatter:{title:"Sparo profiles"},sidebar:"docsSidebar",previous:{title:"Getting started",permalink:"/sparo/_preview/pr-76/pages/guide/getting_started"},next:{title:"Git optimization",permalink:"/sparo/_preview/pr-76/pages/reference/git_optimization"}},l={},c=[{value:"Background",id:"background",level:2},{value:"Sparo improves sparse checkout",id:"sparo-improves-sparse-checkout",level:2},{value:"Best practices for profiles",id:"best-practices-for-profiles",level:2},{value:"Combining profiles",id:"combining-profiles",level:2},{value:"Querying profiles",id:"querying-profiles",level:2},{value:"See also",id:"see-also",level:2}];function p(e){const s={a:"a",code:"code",em:"em",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.h2,{id:"background",children:"Background"}),"\n",(0,i.jsxs)(s.p,{children:["Git's sparse checkout feature normally relies on a collection of glob patterns that are stored in the ",(0,i.jsx)(s.code,{children:".git/info/sparse-checkout"})," config file. The Git maintainers found that regular glob syntax was too inefficient, so they introduced a ",(0,i.jsx)(s.a,{href:"https://git-scm.com/docs/git-sparse-checkout#_internalsnon_cone_problems",children:'"cone mode"'})," glob interpretation that ignores file-matching patterns and only matches directories."]}),"\n",(0,i.jsx)(s.p,{children:"The syntax looks something like this:"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.strong,{children:".git/info/sparse-checkout example"})}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{children:"/*\n!/*/\n/apps/\n!/apps/*/\n/apps/my-app/\n!/apps/my-app/*/\n/apps/my-app/_/\n"})}),"\n",(0,i.jsxs)(s.p,{children:["To simplify management, Git also provides a ",(0,i.jsx)(s.code,{children:"git sparse-checkout"})," command that simplifies the syntax for adding/removing patterns from this file. However, in a large monorepo with hundreds of projects, managing these globs would nonetheless be confusing and error-prone."]}),"\n",(0,i.jsx)(s.h2,{id:"sparo-improves-sparse-checkout",children:"Sparo improves sparse checkout"}),"\n",(0,i.jsxs)(s.p,{children:["Sparo makes life easier by generating the ",(0,i.jsx)(s.code,{children:".git/info/sparse-checkout"})," configuration automatically from config files called ",(0,i.jsx)(s.strong,{children:"profiles."})," This offers many benefits:"]}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["Sparo profiles are defined using ",(0,i.jsx)(s.a,{href:"https://rushjs.io/pages/developer/selecting_subsets/#--to",children:"project selectors"}),", for example: ",(0,i.jsxs)(s.em,{children:['"Give me ',(0,i.jsx)(s.strong,{children:"app1"}),", ",(0,i.jsx)(s.strong,{children:"app2"}),', and all the projects needed to build them."']})," This is more concise and maintainable than specifying globs."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsx)(s.p,{children:"Profiles are stored in a config file and committed to Git. This makes it easy to share them with your teammates."}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsx)(s.p,{children:"Profiles are automatically updated when switching between branches, which ensures deterministic results. For example, when checking out a very old branch, you want the old profile definition, not today's version of it."}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\
|