@@ -33,6 +33,7 @@ const expectCreateDefaults = (command: CreateCommand) => {
3333 expect ( command . config . repoRef ) . toBe ( defaultTemplateConfig . repoRef )
3434 expect ( command . outDir ) . toBe ( ".docker-git/org/repo" )
3535 expect ( command . runUp ) . toBe ( true )
36+ expect ( command . forceEnv ) . toBe ( false )
3637}
3738
3839describe ( "parseArgs" , ( ) => {
@@ -45,6 +46,16 @@ describe("parseArgs", () => {
4546 expect ( command . config . sshPort ) . toBe ( defaultTemplateConfig . sshPort )
4647 } ) )
4748
49+ it . effect ( "parses create command with issue url into isolated defaults" , ( ) =>
50+ expectCreateCommand ( [ "create" , "--repo-url" , "https://github.com/org/repo/issues/9" ] , ( command ) => {
51+ expect ( command . config . repoUrl ) . toBe ( "https://github.com/org/repo.git" )
52+ expect ( command . config . repoRef ) . toBe ( "issue-9" )
53+ expect ( command . outDir ) . toBe ( ".docker-git/org/repo/issue-9" )
54+ expect ( command . config . containerName ) . toBe ( "dg-repo-issue-9" )
55+ expect ( command . config . serviceName ) . toBe ( "dg-repo-issue-9" )
56+ expect ( command . config . volumeName ) . toBe ( "dg-repo-issue-9-home" )
57+ } ) )
58+
4859 it . effect ( "fails on missing repo url" , ( ) =>
4960 Effect . sync ( ( ) => {
5061 Either . match ( parseArgs ( [ "create" ] ) , {
@@ -68,6 +79,18 @@ describe("parseArgs", () => {
6879 expect ( command . config . repoRef ) . toBe ( "feature-x" )
6980 } ) )
7081
82+ it . effect ( "parses force-env flag for clone" , ( ) =>
83+ expectCreateCommand ( [ "clone" , "https://github.com/org/repo.git" , "--force-env" ] , ( command ) => {
84+ expect ( command . force ) . toBe ( false )
85+ expect ( command . forceEnv ) . toBe ( true )
86+ } ) )
87+
88+ it . effect ( "supports force + force-env together" , ( ) =>
89+ expectCreateCommand ( [ "clone" , "https://github.com/org/repo.git" , "--force" , "--force-env" ] , ( command ) => {
90+ expect ( command . force ) . toBe ( true )
91+ expect ( command . forceEnv ) . toBe ( true )
92+ } ) )
93+
7194 it . effect ( "parses GitHub tree url as repo + ref" , ( ) =>
7295 expectCreateCommand ( [ "clone" , "https://github.com/agiens/crm/tree/vova-fork" ] , ( command ) => {
7396 expect ( command . config . repoUrl ) . toBe ( "https://github.com/agiens/crm.git" )
@@ -76,6 +99,37 @@ describe("parseArgs", () => {
7699 expect ( command . config . targetDir ) . toBe ( "/home/dev/agiens/crm" )
77100 } ) )
78101
102+ it . effect ( "parses GitHub issue url as isolated project + issue branch" , ( ) =>
103+ expectCreateCommand ( [ "clone" , "https://github.com/org/repo/issues/5" ] , ( command ) => {
104+ expect ( command . config . repoUrl ) . toBe ( "https://github.com/org/repo.git" )
105+ expect ( command . config . repoRef ) . toBe ( "issue-5" )
106+ expect ( command . outDir ) . toBe ( ".docker-git/org/repo/issue-5" )
107+ expect ( command . config . targetDir ) . toBe ( "/home/dev/org/repo/issue-5" )
108+ expect ( command . config . containerName ) . toBe ( "dg-repo-issue-5" )
109+ expect ( command . config . serviceName ) . toBe ( "dg-repo-issue-5" )
110+ expect ( command . config . volumeName ) . toBe ( "dg-repo-issue-5-home" )
111+ } ) )
112+
113+ it . effect ( "parses GitHub PR url as isolated project" , ( ) =>
114+ expectCreateCommand ( [ "clone" , "https://github.com/org/repo/pull/42" ] , ( command ) => {
115+ expect ( command . config . repoUrl ) . toBe ( "https://github.com/org/repo.git" )
116+ expect ( command . config . repoRef ) . toBe ( "refs/pull/42/head" )
117+ expect ( command . outDir ) . toBe ( ".docker-git/org/repo/pr-42" )
118+ expect ( command . config . targetDir ) . toBe ( "/home/dev/org/repo/pr-42" )
119+ expect ( command . config . containerName ) . toBe ( "dg-repo-pr-42" )
120+ expect ( command . config . serviceName ) . toBe ( "dg-repo-pr-42" )
121+ expect ( command . config . volumeName ) . toBe ( "dg-repo-pr-42-home" )
122+ } ) )
123+
124+ it . effect ( "parses attach with GitHub issue url into issue workspace" , ( ) =>
125+ Effect . sync ( ( ) => {
126+ const command = parseOrThrow ( [ "attach" , "https://github.com/org/repo/issues/7" ] )
127+ if ( command . _tag !== "Attach" ) {
128+ throw new Error ( "expected Attach command" )
129+ }
130+ expect ( command . projectDir ) . toBe ( ".docker-git/org/repo/issue-7" )
131+ } ) )
132+
79133 it . effect ( "parses down-all command" , ( ) =>
80134 Effect . sync ( ( ) => {
81135 const command = parseOrThrow ( [ "down-all" ] )
0 commit comments