Skip to content

Commit d419a50

Browse files
committed
Update readme for branching and git support
1 parent dcee589 commit d419a50

1 file changed

Lines changed: 59 additions & 5 deletions

File tree

readme.md

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,17 @@ analyze [OPTIONS] <PROJECT ID> <FILE(S)...>
131131
```
132132

133133
- `-n, --name <NAME>` Optionally specify a name for the analysis.
134-
- `<PROJECT ID>` Specify which Code Dx project you want to upload files to, by its ID.
135-
(Note: you can find a project's ID using the [`projects`](#command-projects) command,
136-
or finding the number in the URL when you visit that project in a browser)
134+
- `-g, --include-git-source` Flag for including configured git source in the analysis.
135+
- `--git-branch-name <GIT BRANCH NAME>` Git target branch name.
136+
- `--branch-name <BRANCH NAME>` Code Dx target branch name. If a branch of that name does not exist off of the given project context, a new one will
137+
be created.
138+
- `<PROJECT CONTEXT>` Specify which Code Dx project or project context you want to upload files to. Project context should be in the form of `<project-id>`, `<project-
139+
id>;branchId=<branch-id>`, or `<project-id>;branch=<branch-name>` (Note: you can find a project's ID using the [`projects`](#command-projects) command,
140+
or finding the number in the URL when you visit that project in a browser and branch names/IDs can be found using the [`branches`](#command-projects) command).
137141
- `<FILE(S)>` Specify the path to one or more files that you wish to upload.
138142
Each file is a separate argument, separated by a space.
139143

140-
## Example
144+
## Examples
141145

142146
Suppose I want analyze my "WebGoat" project, which happens to have an ID of `5`:
143147

@@ -152,6 +156,28 @@ codedx> analyze -n "Hello Analysis" 5 "/path/to/workspace/webgoat-source.zip" "/
152156
Completed
153157
```
154158

159+
Now, suppose I want to run an analysis on this same project but not on its default branch.
160+
I use the `branches` command to view a list of branches and identify the name or ID of the desired branch.
161+
Let's say the desired branch has an ID of 7 and is named "feature". I then use this to construct the following project context: `5;branchId=7`
162+
if building the context by branch ID, or `5;branch=feature` if building the context by name.
163+
164+
```text
165+
codedx> analyze -n "Hello Analysis" 5;branchId=7 "/path/to/workspace/webgoat-source.zip" "/path/to/workspace/webgoat-classes.zip"
166+
# Started analysis 78 with job id 414a68aa-3b86-4ec2-9118-677f34471a8f
167+
...
168+
```
169+
170+
The `-g` (or `--include-git-source`) flag can be used to include a git-source associated with the project.
171+
The `--git-branch-name <GIT BRANCH NAME>` option can be used to specify a target Git branch for the analysis.
172+
In this example, the `include-git-source` flag is set (via `-g`) and the target git branch is "bugfix".
173+
```text
174+
codedx> analyze -n "Hello Analysis" 5;branchId=7 -g --git-branch-name "bugfix" "/path/to/workspace/webgoat-source.zip" "/path/to/workspace/webgoat-classes.zip"
175+
# Requesting new analysis with job id 2fcc373d-f63f-46c5-8d9a-13eaccf0c70b with included git source
176+
...
177+
# Started analysis 79 with job id fa0bbad5-ec13-4213-a437-41520f1d6b9c
178+
...
179+
```
180+
155181
# Command: `projects`
156182

157183
The `projects` command helps you get a list of all Code Dx projects, or search for specific projects.
@@ -165,7 +191,7 @@ projects [OPTIONS]
165191
- *if no options* - Prints a list of all Code Dx projects that you have at least read access to.
166192
- `-n, --name <PART OF NAME>` - If this flag is given, it adds search criteria such that matching
167193
projects include `<PART OF NAME>` in their name (case insensitive).
168-
- `-m, --metadata <FIELD> <VALUE>` - If this flag is given, it should be followed a key-value
194+
- `-m, --metadata <FIELD> <VALUE>` - If this flag is given, it should be followed by a key-value
169195
pair related to the project's metadata. If given, it adds search criteria such that
170196
matching projects must have entries for the given metadata fields matching the respective
171197
given metadata values. To specify another key-value pair, use the `-m` flag again.
@@ -200,6 +226,34 @@ codedx> projects -m Owner jo -m Visibility high
200226
{"id":4,"name":"Yet another","parentId":3}
201227
```
202228

229+
# Commands: `branches`
230+
The `branches` command helps you get a list of all Code Dx branches for a specified project.
231+
232+
## Arguments and Options
233+
234+
```text
235+
branches [OPTIONS]
236+
```
237+
238+
- `-p, --project-id <PROJECT_ID>` - Specifies the project, by ID, to display a list of branches for.
239+
- `-n, --name <PART_OF_NAME>` - Displays only branches with names containing the given name value.
240+
241+
## Examples
242+
243+
```text
244+
codedx> branches -p 1
245+
{"id":1,"name":"main","projectId":1,"isDefault":true}
246+
{"id":2,"name":"another branch","projectId":1,"isDefault":false}
247+
{"id":7,"name":"yet another branch","projectId":1,"isDefault":false}
248+
...
249+
```
250+
251+
```text
252+
codedx> branches -p 1 -n another
253+
{"id":2,"name":"another branch","projectId":1,"isDefault":false}
254+
{"id":7,"name":"yet another branch","projectId":1,"isDefault":false}
255+
```
256+
203257
# Troubleshooting
204258

205259
## Certificate verification errors

0 commit comments

Comments
 (0)