From c03937cd770a01ba5b3fd3e7c8a5819c21900196 Mon Sep 17 00:00:00 2001 From: Andre Rosa Date: Wed, 27 Mar 2019 17:53:42 -0700 Subject: [PATCH 1/3] Add `--upstream-branch` option --- superflore/generators/bitbake/ros_meta.py | 7 +++++-- superflore/generators/bitbake/run.py | 3 ++- superflore/generators/ebuild/overlay_instance.py | 8 +++++--- superflore/generators/ebuild/run.py | 3 ++- superflore/parser.py | 8 +++++++- superflore/repo_instance.py | 9 ++++++--- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/superflore/generators/bitbake/ros_meta.py b/superflore/generators/bitbake/ros_meta.py index 929f85ec..3a22714f 100644 --- a/superflore/generators/bitbake/ros_meta.py +++ b/superflore/generators/bitbake/ros_meta.py @@ -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) diff --git a/superflore/generators/bitbake/run.py b/superflore/generators/bitbake/run.py index 6dcb82c5..682baa95 100644 --- a/superflore/generators/bitbake/run.py +++ b/superflore/generators/bitbake/run.py @@ -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 ( diff --git a/superflore/generators/ebuild/overlay_instance.py b/superflore/generators/ebuild/overlay_instance.py index a4c22a1a..109afbe8 100644 --- a/superflore/generators/ebuild/overlay_instance.py +++ b/superflore/generators/ebuild/overlay_instance.py @@ -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) diff --git a/superflore/generators/ebuild/run.py b/superflore/generators/ebuild/run.py index 4147e5b5..0f0dfedf 100644 --- a/superflore/generators/ebuild/run.py +++ b/superflore/generators/ebuild/run.py @@ -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 ( diff --git a/superflore/parser.py b/superflore/parser.py index 6e5e0ac9..59ec9a39 100644 --- a/superflore/parser.py +++ b/superflore/parser.py @@ -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//', + type=str + ) + parser.add_argument( + '--upstream-branch', + help='branch of the upstream repository', type=str ) parser.add_argument( diff --git a/superflore/repo_instance.py b/superflore/repo_instance.py index fc53ce64..335f10d3 100644 --- a/superflore/repo_instance.py +++ b/superflore/repo_instance.py @@ -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 From feca1f497ee090489183941e52779319eb661553 Mon Sep 17 00:00:00 2001 From: Andre Rosa Date: Thu, 25 Apr 2019 10:56:39 -0700 Subject: [PATCH 2/3] Add parser tests for missing options --- tests/test_parser.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_parser.py b/tests/test_parser.py index d0051f88..c410394e 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -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) From c20d72be4708cfc8cbd765a93239acbecbd6c47d Mon Sep 17 00:00:00 2001 From: Andre Rosa Date: Thu, 25 Apr 2019 12:32:57 -0700 Subject: [PATCH 3/3] Update README.md with newer command line options --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index e2fe888a..1f64501f 100644 --- a/README.md +++ b/README.md @@ -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// + --upstream-branch UPSTREAM_BRANCH + branch of the upstream repository + --skip-keys SKIP_KEYS + packages to skip during regeneration ``` ### Testing Gentoo Ebuilds