Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --upstream-branch option #180

Merged
merged 3 commits into from
Apr 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ optional arguments:
location of the Git repo
--only ONLY [ONLY ...]
generate only the specified packages
--pr-comment PR_COMMENT
comment to add to the PR
--upstream-repo UPSTREAM_REPO
location of the upstream repository as in
https://github.com/<owner>/<repository>
--upstream-branch UPSTREAM_BRANCH
branch of the upstream repository
--skip-keys SKIP_KEYS
packages to skip during regeneration
```

### Testing Gentoo Ebuilds
Expand Down
7 changes: 5 additions & 2 deletions superflore/generators/bitbake/ros_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@


class RosMeta(object):
def __init__(self, repo_dir, do_clone, org='allenh1', repo='meta-ros'):
self.repo = RepoInstance(org, repo, repo_dir, do_clone)
def __init__(
self, repo_dir, do_clone, org='allenh1', repo='meta-ros', from_branch=''
):
self.repo = RepoInstance(
org, repo, repo_dir, do_clone, from_branch=from_branch)
self.branch_name = 'yocto-bot-%s' % rand_ascii_str()
info('Creating new branch {0}...'.format(self.branch_name))
self.repo.create_branch(self.branch_name)
Expand Down
3 changes: 2 additions & 1 deletion superflore/generators/bitbake/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def main():
_repo,
not args.output_repository_path,
org=repo_org,
repo=repo_name
repo=repo_name,
from_branch=args.upstream_branch,
)
if not args.only:
pr_comment = pr_comment or (
Expand Down
8 changes: 5 additions & 3 deletions superflore/generators/ebuild/overlay_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@


class RosOverlay(object):
def __init__(self, repo_dir, do_clone, org='ros', repo='ros-overlay'):
def __init__(
self, repo_dir, do_clone, org='ros', repo='ros-overlay', from_branch=''
):
self.repo = RepoInstance(
org, repo, repo_dir=repo_dir, do_clone=do_clone
)
org, repo, repo_dir=repo_dir, do_clone=do_clone,
from_branch=from_branch)
self.branch_name = 'gentoo-bot-%s' % rand_ascii_str()
info('Creating new branch {0}...'.format(self.branch_name))
self.repo.create_branch(self.branch_name)
Expand Down
3 changes: 2 additions & 1 deletion superflore/generators/ebuild/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def main():
_repo,
not args.output_repository_path,
org=repo_org,
repo=repo_name
repo=repo_name,
from_branch=args.upstream_branch,
)
if not preserve_existing and not args.only:
pr_comment = pr_comment or (
Expand Down
8 changes: 7 additions & 1 deletion superflore/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ def get_parser(tool_tip, is_generator=True):
)
parser.add_argument(
'--upstream-repo',
help='location of the upstream repository',
help='location of the upstream repository as in '
+ 'https://github.com/<owner>/<repository>',
type=str
)
parser.add_argument(
'--upstream-branch',
help='branch of the upstream repository',
type=str
)
parser.add_argument(
Expand Down
9 changes: 6 additions & 3 deletions superflore/repo_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@


class RepoInstance(object):
def __init__(self, repo_owner, repo_name, repo_dir=None, do_clone=True):
def __init__(
self, repo_owner, repo_name, repo_dir=None, do_clone=True,
from_branch=''):
self.repo_owner = repo_owner
self.repo_name = repo_name
repo_url = 'https://github.com/{0}/{1}'
self.repo_url = repo_url.format(self.repo_owner, self.repo_name)
self.repo_dir = repo_dir or self.repo_name
# by default, start on master.
self.branch = 'master'
self.branch = from_branch or 'master'
if do_clone:
self.repo = Repo.clone_from(self.repo_url, self.repo_dir)
self.repo = Repo.clone_from(
self.repo_url, self.repo_dir, branch=self.branch)
else:
self.repo = Repo(repo_dir)
self.git = self.repo.git
Expand Down
2 changes: 2 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ def test_get_parser(self):
self.assertIn('pr_only', ret)
self.assertIn('ros_distro', ret)
self.assertIn('upstream_repo', ret)
self.assertIn('upstream_branch', ret)
self.assertIn('skip_keys', ret)