-
Notifications
You must be signed in to change notification settings - Fork 67
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
clone: Fetch the upstream remote specified in debian/upstream/metadata
#70
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,7 @@ def build_parser(name): | |
|
||
branch_group.add_option("--all", action="store_true", dest="all", default=False, | ||
help="track all branches, not only debian and upstream") | ||
branch_group.add_config_file_option(option_name="upstream-remote", dest="upstream_remote") | ||
branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") | ||
branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch") | ||
branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar") | ||
|
@@ -208,6 +209,31 @@ def main(argv): | |
|
||
repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo) | ||
|
||
if options.upstream_remote: | ||
try: | ||
with open(os.path.join(clone_to, 'debian', 'upstream', 'metadata')) as f: | ||
import yaml | ||
|
||
y = yaml.load(f, Loader=yaml.CSafeLoader) | ||
try: | ||
upstream_repo = y['Repository'] | ||
|
||
try: | ||
# check if it exists as a git repo | ||
repo.fetch(repo=upstream_repo) | ||
|
||
repo.add_remote_repo(options.upstream_remote, | ||
upstream_repo, | ||
tags=True) | ||
except GitRepositoryError: | ||
gbp.log.warn( | ||
'Unable to fetch upstream repository %s, ' | ||
'ignoring.' % upstream_repo) | ||
except KeyError: | ||
pass | ||
except FileNotFoundError: | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could that go into a function? Also we don't have a way to fail cloning if no upstream remote exists or when cloning fails. I'd expect things to fail if that feature is enabled otherwise things become hard to use in scripts. Maybe we need a separate option to enable adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thing is we can't know from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do heuristics then: So for --clone-upstream=auto :
if cloning fails we give an error. If it does not match the pattern ignore the error (and print a warning). We could go further and make this configurable (similar to what we have for And plesse add a code comment that points to the bug that says we need to be clearer on metadata (i think i saw this flying by) |
||
|
||
if postclone: | ||
Hook('Postclone', options.postclone, | ||
extra_env={'GBP_GIT_DIR': repo.git_dir}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of
Set to an empty string to disable cloning "upstream"
it'd rather do adefault is ...
as with most of the other options.