Merge lp:~asbalderson/jenkins-launchpad-plugin/private-repo into lp:jenkins-launchpad-plugin

Proposed by Alexander Balderson
Status: Merged
Merged at revision: 145
Proposed branch: lp:~asbalderson/jenkins-launchpad-plugin/private-repo
Merge into: lp:jenkins-launchpad-plugin
Diff against target: 45 lines (+14/-6)
1 file modified
jlp/commands/autoland.py (+14/-6)
To merge this branch: bzr merge lp:~asbalderson/jenkins-launchpad-plugin/private-repo
Reviewer Review Type Date Requested Status
Joshua Powers (community) Approve
Review via email: mp+364540@code.launchpad.net

Commit message

Use git+ssh url's for all autoland operations.

When trying to autoland against repo's which are private on launchpad,
the https_url doesnt exist. Use the git+ssh url instead for those
operations. Because the user performing autoland operations has
access to push to the repo, it should also have access to clone as well.

Description of the change

I suspect the reason the https url was used originally was to ensure that the wrong repo couldnt be pushed to, but that's what automation is for. which should ensure we dont accidentally push incorrectly.

To post a comment you must log in.
Revision history for this message
Joshua Powers (powersj) :
review: Approve
145. By Joshua Powers

Use git+ssh url's for all autoland operations.

When trying to autoland against repo's which are private on launchpad,
the https_url doesnt exist. Use the git+ssh url instead for those
operations. Because the user performing autoland operations has
access to push to the repo, it should also have access to clone as well.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'jlp/commands/autoland.py'
--- jlp/commands/autoland.py 2018-07-31 15:57:38 +0000
+++ jlp/commands/autoland.py 2019-03-15 16:41:46 +0000
@@ -107,6 +107,17 @@
107 return _merge_and_commit_bzr(mp, args)107 return _merge_and_commit_bzr(mp, args)
108108
109109
110def _get_user_and_git_ssh_url(url):
111 """Create a git+ssh://user@git.launchpad.net/repo like url.
112
113 @param url: a git+ssh url without a user
114 @return: a git+ssh with user url
115 """
116 return url.replace(
117 'ssh://', 'ssh://%s@' % get_config_option('launchpad_login')
118 )
119
120
110def _git_source_info(mp):121def _git_source_info(mp):
111 """Get the current sha, author, and email of the source branch.122 """Get the current sha, author, and email of the source branch.
112123
@@ -116,7 +127,7 @@
116 tmp_dir = tempfile.mkdtemp()127 tmp_dir = tempfile.mkdtemp()
117 try:128 try:
118 proposal = git.Repo.clone_from(129 proposal = git.Repo.clone_from(
119 mp.source_git_repository.git_https_url,130 _get_user_and_git_ssh_url(mp.source_git_repository.git_ssh_url),
120 tmp_dir, branch=get_source_branch(mp))131 tmp_dir, branch=get_source_branch(mp))
121 revid = proposal.head.object.hexsha132 revid = proposal.head.object.hexsha
122 author = proposal.head.commit.author.name133 author = proposal.head.commit.author.name
@@ -189,13 +200,10 @@
189 args, LaunchpadVote.NEEDS_FIXING)200 args, LaunchpadVote.NEEDS_FIXING)
190 return 1201 return 1
191202
192 # create a git+ssh://user@git.launchpad.net/repo like url203 url = _get_user_and_git_ssh_url(mp.target_git_repository.git_ssh_url)
193 url = mp.target_git_repository.git_ssh_url.replace(
194 'ssh://', 'ssh://%s@' % get_config_option('launchpad_login')
195 )
196 target = git.Repo.clone_from(url, git_dir, branch=get_target_branch(mp))204 target = git.Repo.clone_from(url, git_dir, branch=get_target_branch(mp))
197 source = target.create_remote(205 source = target.create_remote(
198 'source', mp.source_git_repository.git_https_url206 'source', _get_user_and_git_ssh_url(mp.source_git_repository.git_ssh_url)
199 )207 )
200 source.fetch()208 source.fetch()
201209

Subscribers

People subscribed via source and target branches