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

do-release-tags: Add remote pull option #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
41 changes: 40 additions & 1 deletion do-release-tags
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,31 @@ def fatal(msg):
print >>sys.stderr, msg
sys.exit(1)

def pullcommit(commit,remote,repo,sourceref):
pulloptionsdict = GLib.VariantDict.new()
variant_type_string = GLib.VariantType.new('s')

pulloptionscommit = GLib.Variant.new_array(variant_type_string, [GLib.Variant.new_string(commit)])
pulloptionsdict.insert_value('override-commit-ids', pulloptionscommit)
pulloptionsref = GLib.Variant.new_array(variant_type_string, [GLib.Variant.new_string(sourceref)])
pulloptionsdict.insert_value('refs', pulloptionsref)
pulloptions = pulloptionsdict.end()

try:
repo.pull_with_options (remote, pulloptions, None, None)
except GLib.Error:
fatal("Unable to pull commit {} from {}".format(commit,remote))


parser = argparse.ArgumentParser(prog=sys.argv[0])
parser.add_argument("--ignore-no-previous-promotion", help="Releases file",
action='store_true')
parser.add_argument("--repo", help="Repo path",
action='store', required=True)
parser.add_argument("--releases", help="Releases file",
action='store', required=True)
parser.add_argument("--remote", help="Remote name",
action='store')

args = parser.parse_args()

Expand All @@ -43,6 +61,14 @@ r.open(None)
releasedata = yaml.load(open(args.releases))
baseref = releasedata['baseref']
changed = False

if args.remote:
remote = args.remote
elif 'remote' in releasedata:
remote = releasedata['remote']
else:
remote = False

for (name,newcommit) in releasedata['releases'].iteritems():
ref = baseref + name
[_, current] = r.resolve_rev(ref, True)
Expand All @@ -67,7 +93,20 @@ for (name,newcommit) in releasedata['releases'].iteritems():
print("No changes in {} = {}, promoted from {}".format(ref, current, currentpromoted))
continue
print("Previously: {} = {}, promoted from {}".format(ref, current, currentpromoted))
_,newcommitdata,_ = r.load_commit(newcommit)
_,havecommit = r.has_object(OSTree.ObjectType.COMMIT,newcommit)
if not havecommit:
msg = "Commit {} not found locally".format(newcommit)
if remote:
print(msg)
print("Attempting to pull from remote " + remote)
if 'sourceref' in releasedata:
sourceref = releasedata['sourceref']
else:
sourceref = baseref + name
pullcommit(newcommit,remote,r,sourceref)
else:
fatal(msg)
_,newcommitdata,_ = r.read_commit(newcommit)
_,newcommitroot,_ = r.read_commit(newcommit, None)
newcommitmeta = newcommitdata.get_child_value(0)
versionv = newcommitmeta.lookup_value("version", GLib.VariantType.new("s"))
Expand Down