Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion llvm/utils/git-llvm-push
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,23 @@ def get_token_from_cli(runner: CommandRunner) -> str:
return result.stdout.strip().decode("utf-8")


def get_git_config_options() -> argparse.Namespace:
# We do not use a runner here as we need to run this before we know what
# flags we want to pass to the runner.
try:
process = subprocess.run(
["git", "config", "--list"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
args = argparse.Namespace()
for line in process.stdout.decode("utf-8").split("\n"):
if line.startswith("git-llvm-push."):
line_parts = line.split("=")
setattr(args, line_parts[0][14:].replace("-", "_"), line_parts[1])
Comment thread
boomanaiden154 marked this conversation as resolved.
Outdated
return args
except:
return argparse.Namespace()


def main() -> None:
parser = argparse.ArgumentParser(
description="Create and land a stack of Pull Requests."
Expand Down Expand Up @@ -671,7 +688,8 @@ def main() -> None:
help="Print only essential output and errors.",
)

args = parser.parse_args()
git_config_args = get_git_config_options()
args = parser.parse_args(None, git_config_args)

command_runner = CommandRunner(
dry_run=args.dry_run, verbose=args.verbose, quiet=args.quiet
Expand Down
16 changes: 16 additions & 0 deletions llvm/utils/git-llvm-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ Regardless of success or failure, the script performs the following cleanup step
1. **Checkout Original Branch:** The script will check out the branch you were on when you started the script.
2. **Delete Temporary Remote Branches:** Any temporary branches created on your fork (e.g., `users/johndoe/my-feature-1`) will be deleted from the remote. This prevents clutter in your fork.

## Configuration

In addition to accepting command line flags, `git-llvm-push` can also be configured
through the git config. To do this, edit your git config (using a command like
`git config --edit` to edit your repo specific configuration) and add the following
section header:

```
[git-llvm-push]
<flag> = <flag value>
```

The flags are spelled the exact same as they are on the command line. All flags
are supported, although `--verbose` and `--dry-run` will not have an impact on
the git invocation to read the configuration.

## Examples

### Dry Run (Safe Mode)
Expand Down
Loading