Skip to content

Commit 62bf913

Browse files
Update documentation and file names to reflect PR feedback.
Signed-off-by: Leander Stephen D'Souza <leanderdsouza1234@gmail.com>
1 parent b186be5 commit 62bf913

File tree

6 files changed

+113
-30
lines changed

6 files changed

+113
-30
lines changed

README.md

Lines changed: 97 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,108 @@ Only for this command vcs2l supports the pseudo clients `tar` and `zip` which fe
9292

9393
### Import with extends functionality
9494

95-
The `vcs import` command supports an `extends` key at the top level of the YAML file.
96-
The value of that key is a path or URL to another YAML file which is imported first.
97-
This parent file can itself also contain the key to chain multiple files.
98-
The child is given precedence over the parent in case of duplicate repository entries.
95+
The `vcs import` command supports an `extends` key at the top level of the YAML file. The value of that key is a path or URL to another YAML file which is imported first.
96+
This base file can itself also contain the key to chain multiple files. The extension to this base file is given precedence over the parent in case of duplicate repository entries.
97+
98+
#### Normal Extension
99+
100+
For instance, consider the following two files:
101+
102+
- **`base.repos`**: contains three repositories `vcs2l`, `immutable/hash` and `immutable/tag`, checked out at specific versions.
103+
104+
```yaml
105+
---
106+
repositories:
107+
vcs2l:
108+
type: git
109+
url: https://github.com/ros-infrastructure/vcs2l.git
110+
version: main
111+
immutable/hash:
112+
type: git
113+
url: https://github.com/ros-infrastructure/vcs2l.git
114+
version: 377d5b3d03c212f015cc832fdb368f4534d0d583
115+
immutable/tag:
116+
type: git
117+
url: https://github.com/ros-infrastructure/vcs2l.git
118+
version: 1.1.3
119+
```
120+
121+
- **`base_extension.repos`**: extends the base file and overrides the version of `immutable/hash` and `immutable/tag` repositories.
122+
123+
```yaml
124+
---
125+
extends: base.repos
126+
repositories:
127+
immutable/hash:
128+
type: git
129+
url: https://github.com/ros-infrastructure/vcs2l.git
130+
version: 25e4ae2f1dd28b0efcd656f4b1c9679d8a7d6c22
131+
immutable/tag:
132+
type: git
133+
url: https://github.com/ros-infrastructure/vcs2l.git
134+
version: 1.1.5
135+
```
136+
The resulting extension import would import vcs2l at version `main`, `immutable/hash` at version `25e4ae2` and `immutable/tag` at version `1.1.5`.
137+
138+
#### Circular Loop Protection
139+
99140
In order to avoid infinite loops in case of circular imports the tool detects already imported files and raises an error if such a file is encountered again.
100141

101-
```yaml
102-
# parent.repos
103-
repositories:
104-
vcs2l:
105-
type: git
106-
url: git@github.com:ros-infrastructure/vcs2l.git
107-
version: main
142+
For instance, consider the following two files:
143+
144+
- **`loop_base.repos`**: extends the `loop_extension.repos` file, and contains two repositories `vcs2l` and `immutable/tag`.
145+
146+
```yaml
147+
---
148+
extends: loop_extension.repos
149+
repositories:
150+
vcs2l:
151+
type: git
152+
url: https://github.com/ros-infrastructure/vcs2l.git
153+
version: main
154+
immutable/tag:
155+
type: git
156+
url: https://github.com/ros-infrastructure/vcs2l.git
157+
version: 1.1.3
158+
```
159+
160+
- **`loop_extension.repos`**: extends the `loop_base.repos` file, and modifies the version of `immutable/tag` with `1.1.5`.
161+
162+
```yaml
163+
---
164+
extends: loop_base.repos
165+
repositories:
166+
immutable/tag:
167+
type: git
168+
url: https://github.com/ros-infrastructure/vcs2l.git
169+
version: 1.1.5
170+
```
171+
The resulting extension import would prevent the download and raise the following error:
108172

109-
# child.repos
110-
extends: parent.repos
111-
repositories:
112-
vcs2l:
113-
type: git
114-
url: https://github.com/ros-infrastructure/vcs2l.git
115-
version: 1.1.5
173+
```bash
174+
Circular import detected: <relative-path>/loop_extension.repos
116175
```
117176

177+
#### File path behaviour
178+
179+
Currently there are two ways to specify the path to the repository file passed to `vcs import`:
180+
181+
1. **Recommended**: Using `--input`.
182+
183+
* For instance: `vcs import --input my.repos <destination-path>`
184+
185+
* The extended files are searched relative to the location of `my.repos`.
186+
187+
* You do not require to be in the same directory as `my.repos` to run the command.
188+
189+
2. Using the input redirection operator `<` to pass a local file path via `stdin`.
190+
191+
* For instance: `vcs import < my.repos <destination-path>`
192+
193+
* The extended files are searched relative to the current working directory.
194+
195+
* Therefore, you have to be in the **same** directory as `my.repos` to run the command. In addition, all the extended files must also be relative to the current working directory.
196+
118197
### Delete set of repositories
119198

120199
The `vcs delete` command removes all directories of repositories which are passed in via `stdin` in YAML format.

test/list_extends_loop_parent.repos

Lines changed: 0 additions & 8 deletions
This file was deleted.
File renamed without changes.

test/loop_base.repos

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Base repositories file that creates an extends a circular import on its extension implementation.
2+
---
3+
extends: loop_extension.repos
4+
repositories:
5+
vcs2l:
6+
type: git
7+
url: https://github.com/ros-infrastructure/vcs2l.git
8+
version: main
9+
immutable/tag:
10+
type: git
11+
url: https://github.com/ros-infrastructure/vcs2l.git
12+
version: tags/1.1.3

test/list_extends_loop_child.repos renamed to test/loop_extension.repos

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Child file that creates an extends a circular import on its parent.
1+
# Repositories extension file that creates an extends a circular import on its base.
22
---
3-
extends: list_extends_loop_parent.repos
3+
extends: loop_base.repos
44
repositories:
55
vcs2l:
66
type: git

test/test_commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
REPOS_FILE = os.path.join(os.path.dirname(__file__), 'list.repos')
1515
REPOS_FILE_URL = file_uri_scheme + REPOS_FILE
1616
REPOS2_FILE = os.path.join(os.path.dirname(__file__), 'list2.repos')
17-
REPOS_EXTENDS_FILE = os.path.join(os.path.dirname(__file__), 'list_extends.repos')
17+
REPOS_EXTENDS_FILE = os.path.join(os.path.dirname(__file__), 'list_extension.repos')
1818
REPOS_EXTENDS_LOOP_FILE = os.path.join(
19-
os.path.dirname(__file__), 'list_extends_loop_child.repos'
19+
os.path.dirname(__file__), 'loop_extension.repos'
2020
)
2121
BAD_REPOS_FILE = os.path.join(os.path.dirname(__file__), 'bad.repos')
2222
TEST_WORKSPACE = os.path.join(

0 commit comments

Comments
 (0)