Skip to content

Commit b20d5aa

Browse files
authored
doc(librarian): document current behavior when using local repo with push flag (#2885)
Documents current behavior that when using local repo, Librarian will branch-off the checked-out branch for commits, but will attempt to create PR against main branch if `push` flag is set. Add clarification to `branch` flag description that it is ignored with local repo. Fixes #2877
1 parent 23ab992 commit b20d5aa

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

cmd/librarian/doc.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ Flags:
9898
The location of an API specification repository.
9999
Can be a remote URL or a local file path. (default "https://github.com/googleapis/googleapis")
100100
-branch string
101-
The branch to use with remote code repositories. This is used to specify
102-
which branch to clone and which branch to use as the base for a pull
103-
request. (default "main")
101+
The branch to use with remote code repositories. It is ignored if
102+
you are using a local repository. This is used to specify which branch to clone
103+
and which branch to use as the base for a pull request. (default "main")
104104
-build
105105
If true, Librarian will build each generated library by invoking the
106106
language-specific container.
@@ -131,6 +131,10 @@ Flags:
131131
local file path like /path/to/repo. Both absolute and relative paths are
132132
supported. If not specified, will try to detect if the current working directory
133133
is configured as a language repository.
134+
Note: When using a local repository (either by providing a path or by defaulting
135+
to the current directory), Librarian creates a new branch from the currently checked-out
136+
branch and commits changes. If the --push flag is also specified, a pull request is
137+
created against the main branch. The --branch flag is ignored for local repositories.
134138
-v enables verbose logging
135139
136140
# release
@@ -193,9 +197,9 @@ Usage:
193197
Flags:
194198
195199
-branch string
196-
The branch to use with remote code repositories. This is used to specify
197-
which branch to clone and which branch to use as the base for a pull
198-
request. (default "main")
200+
The branch to use with remote code repositories. It is ignored if
201+
you are using a local repository. This is used to specify which branch to clone
202+
and which branch to use as the base for a pull request. (default "main")
199203
-commit
200204
If true, librarian will create a commit for the change but not create
201205
a pull request. This flag is ignored if push is set to true.
@@ -222,6 +226,10 @@ Flags:
222226
local file path like /path/to/repo. Both absolute and relative paths are
223227
supported. If not specified, will try to detect if the current working directory
224228
is configured as a language repository.
229+
Note: When using a local repository (either by providing a path or by defaulting
230+
to the current directory), Librarian creates a new branch from the currently checked-out
231+
branch and commits changes. If the --push flag is also specified, a pull request is
232+
created against the main branch. The --branch flag is ignored for local repositories.
225233
-v enables verbose logging
226234
227235
# release tag
@@ -270,6 +278,10 @@ Flags:
270278
local file path like /path/to/repo. Both absolute and relative paths are
271279
supported. If not specified, will try to detect if the current working directory
272280
is configured as a language repository.
281+
Note: When using a local repository (either by providing a path or by defaulting
282+
to the current directory), Librarian creates a new branch from the currently checked-out
283+
branch and commits changes. If the --push flag is also specified, a pull request is
284+
created against the main branch. The --branch flag is ignored for local repositories.
273285
-v enables verbose logging
274286
275287
# update-image
@@ -301,9 +313,9 @@ Flags:
301313
The location of an API specification repository.
302314
Can be a remote URL or a local file path. (default "https://github.com/googleapis/googleapis")
303315
-branch string
304-
The branch to use with remote code repositories. This is used to specify
305-
which branch to clone and which branch to use as the base for a pull
306-
request. (default "main")
316+
The branch to use with remote code repositories. It is ignored if
317+
you are using a local repository. This is used to specify which branch to clone
318+
and which branch to use as the base for a pull request. (default "main")
307319
-build
308320
If true, Librarian will build each generated library by invoking the
309321
language-specific container.
@@ -339,6 +351,10 @@ Flags:
339351
local file path like /path/to/repo. Both absolute and relative paths are
340352
supported. If not specified, will try to detect if the current working directory
341353
is configured as a language repository.
354+
Note: When using a local repository (either by providing a path or by defaulting
355+
to the current directory), Librarian creates a new branch from the currently checked-out
356+
branch and commits changes. If the --push flag is also specified, a pull request is
357+
created against the main branch. The --branch flag is ignored for local repositories.
342358
-test
343359
If true, run container tests after generation but before committing and pushing.
344360
These tests verify the interaction between language containers and the Librarian CLI's

internal/librarian/flags.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ language-specific container.`)
4141

4242
func addFlagBranch(fs *flag.FlagSet, cfg *config.Config) {
4343
fs.StringVar(&cfg.Branch, "branch", "main",
44-
`The branch to use with remote code repositories. This is used to specify
45-
which branch to clone and which branch to use as the base for a pull
46-
request.`)
44+
`The branch to use with remote code repositories. It is ignored if
45+
you are using a local repository. This is used to specify which branch to clone
46+
and which branch to use as the base for a pull request.`)
4747
}
4848

4949
func addFlagCheckUnexpectedChanges(fs *flag.FlagSet, cfg *config.Config) {
@@ -126,7 +126,11 @@ func addFlagRepo(fs *flag.FlagSet, cfg *config.Config) {
126126
in the format of a remote URL such as https://github.com/{owner}/{repo} or a
127127
local file path like /path/to/repo. Both absolute and relative paths are
128128
supported. If not specified, will try to detect if the current working directory
129-
is configured as a language repository.`)
129+
is configured as a language repository.
130+
Note: When using a local repository (either by providing a path or by defaulting
131+
to the current directory), Librarian creates a new branch from the currently checked-out
132+
branch and commits changes. If the --push flag is also specified, a pull request is
133+
created against the main branch. The --branch flag is ignored for local repositories.`)
130134
}
131135

132136
func addFlagTest(fs *flag.FlagSet, cfg *config.Config) {

0 commit comments

Comments
 (0)