Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit 3283f1c

Browse files
Jinlin Zhangbuck-bot
andauthored
Fixed git push access denied issue (#2487)
Co-authored-by: buck-bot <[email protected]>
1 parent da5384f commit 3283f1c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

tools/release/platforms/homebrew.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from platforms.common import ReleaseException, run
2626
from releases import get_version_and_timestamp_from_release
27+
from releases import get_current_user
2728

2829

2930
def brew(homebrew_dir, command, *run_args, **run_kwargs):
@@ -230,7 +231,7 @@ def update_formula_after_bottle(formula_path, sha, target_macos_version_spec):
230231
logging.info("Updated formula with new bottle sha")
231232

232233

233-
def push_tap(git_repository, tap_path, version):
234+
def push_tap(git_repository, tap_path, version, github_token):
234235
"""
235236
Grab any working directory changes for the tap, clone a new tap repository,
236237
and push those changes upstream. The original tap path is in a clean state
@@ -243,7 +244,8 @@ def push_tap(git_repository, tap_path, version):
243244
"""
244245
logging.info("Gathering git diff from {}".format(tap_path))
245246
git_diff = run(["git", "diff"], tap_path, True).stdout
246-
git_url = "[email protected]:{}.git".format(git_repository)
247+
user = get_current_user(github_token)
248+
git_url = "https://{}:{}@github.com/{}.git".format(user["login"], github_token, git_repository)
247249

248250
with tempfile.TemporaryDirectory() as temp_dir:
249251
logging.info("Cloning {} into {}".format(git_url, temp_dir))
@@ -297,13 +299,13 @@ def audit_tap(homebrew_dir, tap_repository):
297299
brew(homebrew_dir, ["audit", brew_target])
298300

299301

300-
def publish_tap_changes(homebrew_dir, tap_repository, version):
302+
def publish_tap_changes(homebrew_dir, tap_repository, version, github_token):
301303
git_user, git_repo = tap_repository.split("/")
302304
full_git_repo = "{}/homebrew-{}".format(git_user, git_repo)
303305
formula_path = get_formula_path(homebrew_dir, tap_repository)
304306
tap_path = os.path.dirname(formula_path)
305307

306-
push_tap(full_git_repo, tap_path, version)
308+
push_tap(full_git_repo, tap_path, version, github_token)
307309

308310

309311
def log_about_manual_tap_push(homebrew_dir, tap_repository):

tools/release/publish_release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def publish(
398398
add_assets(release, github_token, homebrew_file)
399399
validate_tap(homebrew_dir, args.tap_repository, args.version)
400400
if args.homebrew_push_tap:
401-
publish_tap_changes(homebrew_dir, args.tap_repository, args.version)
401+
publish_tap_changes(homebrew_dir, args.tap_repository, args.version, github_token)
402402
else:
403403
log_about_manual_tap_push(args.tap_repository)
404404

0 commit comments

Comments
 (0)