blob: 1bfe48302087fea700b3e377b3cc3604f882bfad [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(
[f" {'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(f"{revision}\t{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(f"{f}\x00" 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))