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 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 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)