blob: cf75ecc68d9cfe1106636aa644aa22db90eab112 [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine import recipe_test_api
class GitTestApi(recipe_test_api.RecipeTestApi):
def branch(self, step_name, branches, remotes=False):
test_data = "\n".join(
[" %s%s" % ("origin/" if remotes else "", b) for b in branches]
)
return self.step_data(step_name, stdout=self.m.raw_io.output_text(test_data))
def get_all_remote_branch_heads(self, step_name, heads):
stdout = "\n".join(
"{}\t{}".format(revision, name) for name, revision in heads.items()
)
return self.step_data(step_name, stdout=self.m.raw_io.output_text(stdout))
def get_remote_branch_head(self, step_name, revision):
return self.get_all_remote_branch_heads(step_name, {"arbitrary": revision})
def get_changed_files(self, step_name, files):
return self.step_data(
step_name,
stdout=self.m.raw_io.output_text("".join("{}\0".format(f) for f in files)),
)
def rev_parse(self, step_name, revision):
return self.step_data(step_name, stdout=self.m.raw_io.output_text(revision))