本文整理汇总了Python中git.Actor方法的典型用法代码示例。如果您正苦于以下问题:Python git.Actor方法的具体用法?Python git.Actor怎么用?Python git.Actor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git
的用法示例。
在下文中一共展示了git.Actor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rank_directory_default_unindexed_revision
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def test_rank_directory_default_unindexed_revision(builddir):
""" Test the rank feature with an unindexed revision. """
repo = Repo(builddir)
with open(builddir / "test.py", "w") as test_txt:
test_txt.write("import abc")
index = repo.index
index.add([str(builddir / "test.py")])
author = Actor("An author", "author@example.com")
committer = Actor("A committer", "committer@example.com")
commit = index.commit(
"unindexed commit",
author=author,
committer=committer,
author_date="Thu, 28 Apr 2019 22:13:13 +0200",
commit_date="Thu, 28 Apr 2019 22:13:13 +0200",
)
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", builddir, "rank", "-r", commit.hexsha])
assert result.exit_code == 1, result.stdout
示例2: data_repository
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def data_repository(directory_tree):
"""Create a test repo."""
from git import Repo, Actor
# initialize
repo = Repo.init(directory_tree.strpath)
# add a file
repo.index.add([directory_tree.join('file').strpath])
repo.index.commit('test commit', author=Actor('me', 'me@example.com'))
# commit changes to the same file with a different user
directory_tree.join('file').write('5678')
repo.index.add([directory_tree.join('file').strpath])
repo.index.commit('test commit', author=Actor('me2', 'me2@example.com'))
# commit a second file
repo.index.add([directory_tree.join('dir2/file2').strpath])
repo.index.commit('test commit', author=Actor('me', 'me@example.com'))
# return the repo
return repo
示例3: test_generate_new_message
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def test_generate_new_message(monkeypatch, repo, commits, expected):
monkeypatch.setenv("CI_ENVIRONMENT_URL", "example.com")
old_version = repo.head.commit.hexsha
for commit in commits:
repo.index.commit(commit, author=Actor("test_author", "test@test.com"))
fake_deployment = Deployment(
repo=repo,
new_version="HEAD",
old_version=old_version,
stack=rancher.Stack("0st0", "foo"),
)
monkeypatch.setattr(uut, "deployment", fake_deployment)
slack_hook = uut.Hook()
slack_hook.get_changelog = lambda: ""
slack_hook.users_by_email = {"picky@kiwi.com": "@picky"}
msg = slack_hook.generate_new_message()
expected["text"] = slack_hook.deployment_text
assert msg == expected
示例4: setUp
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def setUp(self):
super().setUp()
git.Repo.clone_from(os.path.join(self.current_directory, 'data', 'repository'),
os.path.join(self.working_directory.name, 'worktree'))
repository = git.Repo(os.path.join(self.working_directory.name, 'worktree'))
git.Submodule.add(repository, 'subrepo', 'subrepo',
os.path.join(self.current_directory, 'data', 'subrepository'))
author = git.Actor('Author A', 'a@example.com')
repository.index.commit('Add subrepo', author=author)
示例5: test_submodule_in_initial_commit_is_understood
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def test_submodule_in_initial_commit_is_understood(self):
submodule_repository = git.Repo.init(os.path.join(self.working_directory.name, 'initial_submodule'))
git.Submodule.add(submodule_repository, 'subrepo', 'subrepo',
os.path.join(self.current_directory, 'data', 'subrepository'))
author = git.Actor('Author B', 'b@example.com')
submodule_repository.index.commit('Initial commit', author=author)
self.hammer.add_repository(os.path.join(self.working_directory.name, 'initial_submodule'))
commit = next(self.hammer.iter_individual_commits())
self.assertEqual(commit.line_counts, {commit.author: 3})
示例6: __init__
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def __init__(self, repo: git.Repo,
dry_run: bool,
home='bioconda/bioconda-recipes',
fork=None,
allow_dirty=False) -> None:
#: GitPython Repo object representing our repository
self.repo: git.Repo = repo
if not allow_dirty and self.repo.is_dirty():
raise RuntimeError("Repository is in dirty state. Bailing out")
#: Dry-Run mode - don't push or commit anything
self.dry_run = dry_run
#: Remote pointing to primary project repo
self.home_remote = self.get_remote(home)
if fork is not None:
#: Remote to pull from
self.fork_remote = self.get_remote(fork)
else:
self.fork_remote = self.home_remote
#: Semaphore for things that mess with working directory
self.lock_working_dir = asyncio.Semaphore(1)
#: GPG key ID or bool, indicating whether/how to sign commits
self._sign: Union[bool, str] = False
#: Committer and Author
self.actor: git.Actor = None
示例7: set_user
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def set_user(self, user: str, email: str = None) -> None:
"""Set the user and email to use for committing"""
self.actor = git.Actor(user, email)
示例8: test_build_crash
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def test_build_crash(tmpdir):
"""
Simulate a runtime error in the build.
"""
repo = Repo.init(path=tmpdir)
tmppath = pathlib.Path(tmpdir)
# Write a test file to the repo
with open(tmppath / "test.py", "w") as test_txt:
test_txt.write("import abc")
index = repo.index
index.add(["test.py"])
author = Actor("An author", "author@example.com")
committer = Actor("A committer", "committer@example.com")
index.commit("basic test", author=author, committer=committer)
repo.close()
import wily.commands.build
with patch.object(
wily.commands.build.Bar, "finish", side_effect=RuntimeError("arggh")
) as bar_finish:
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", tmpdir, "build", "test.py"])
assert bar_finish.called_once
assert result.exit_code == 1, result.stdout
示例9: test_build
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def test_build(tmpdir, cache_path):
"""
Test that build works in a basic repository.
"""
repo = Repo.init(path=tmpdir)
tmppath = pathlib.Path(tmpdir)
# Write a test file to the repo
with open(tmppath / "test.py", "w") as test_txt:
test_txt.write("import abc")
index = repo.index
index.add(["test.py"])
author = Actor("An author", "author@example.com")
committer = Actor("A committer", "committer@example.com")
commit = index.commit("basic test", author=author, committer=committer)
repo.close()
runner = CliRunner()
result = runner.invoke(
main.cli,
["--debug", "--path", tmpdir, "--cache", cache_path, "build", "test.py"],
)
assert result.exit_code == 0, result.stdout
cache_path = pathlib.Path(cache_path)
assert cache_path.exists()
index_path = cache_path / "git" / "index.json"
assert index_path.exists()
rev_path = cache_path / "git" / (commit.name_rev.split(" ")[0] + ".json")
assert rev_path.exists()
示例10: test_dirty_git
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def test_dirty_git(tmpdir):
""" Check that repository fails to initialise if unchecked files are in the repo """
repo = Repo.init(path=tmpdir)
tmppath = pathlib.Path(tmpdir)
index = repo.index
author = Actor("An author", "author@example.com")
committer = Actor("A committer", "committer@example.com")
# First commit
with open(tmppath / ".gitignore", "w") as ignore:
ignore.write(".wily/")
index.add([".gitignore"])
commit1 = index.commit("commit1", author=author, committer=committer)
# Write a test file to the repo
with open(tmppath / "blah.py", "w") as ignore:
ignore.write("*.py[co]\n")
index.add(["blah.py"])
repo.close()
config = DEFAULT_CONFIG
config.path = tmpdir
with pytest.raises(DirtyGitRepositoryError):
archiver = GitArchiver(config)
archiver.revisions(tmpdir, 2)
示例11: test_detached_head
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def test_detached_head(tmpdir):
""" Check that repo can initialize in detached head state"""
repo = Repo.init(path=tmpdir)
tmppath = pathlib.Path(tmpdir)
index = repo.index
author = Actor("An author", "author@example.com")
committer = Actor("A committer", "committer@example.com")
# First commit
with open(tmppath / "test.py", "w") as ignore:
ignore.write("print('hello world')")
index.add(["test.py"])
commit1 = index.commit("commit1", author=author, committer=committer)
# Second commit
with open(tmppath / "test.py", "w") as ignore:
ignore.write("print('hello world')\nprint(1)")
index.add(["test.py"])
commit2 = index.commit("commit2", author=author, committer=committer)
repo.git.checkout(commit2.hexsha)
repo.close()
config = DEFAULT_CONFIG
config.path = tmpdir
archiver = GitArchiver(config)
assert archiver.revisions(tmpdir, 1) is not None
示例12: _migrate_old_workflows
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def _migrate_old_workflows(client):
"""Migrates old cwl workflows to new jsonld format."""
wf_path = '{}/*.cwl'.format(client.workflow_path)
cwl_paths = glob.glob(wf_path)
cwl_paths = [(p, _find_only_cwl_commit(client, p)) for p in cwl_paths]
cwl_paths = sorted(cwl_paths, key=lambda p: p[1].committed_date)
for cwl_file, commit in cwl_paths:
path = _migrate_cwl(client, cwl_file, commit)
os.remove(cwl_file)
client.repo.git.add(cwl_file, path)
if client.repo.is_dirty():
commit_msg = ('renku migrate: ' 'committing migrated workflow')
committer = Actor('renku {0}'.format(__version__), version_url)
client.repo.index.commit(
commit_msg,
committer=committer,
skip_hooks=True,
)
示例13: commit_changes
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def commit_changes(self, commit_message, committer_name, committer_email):
"""
Commit all changes made to the repository.
Args:
commit_message (str): message describing the commit
committer_name (str): committer name
committer_email (str): committer email
"""
LOG.info("Adding files to repository index")
self.index.add(["*"])
LOG.info("Committing changes to local repository")
actor = git.Actor(committer_name, committer_email)
self.index.commit(commit_message, author=actor, committer=actor)
示例14: patch_and_push
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def patch_and_push(dfp, repository, target_branch, release_version):
"""patch the Dockerfile and push the created branch to origin"""
# lets create a new branch
new_branch = repository.create_head(target_branch)
new_branch.checkout()
# set dockerfile version to release version
dfp.envs['MATTERMOST_VERSION'] = release_version
dfp.envs['MATTERMOST_VERSION_SHORT'] = release_version.replace('.', '')
# and write back the Dockerfile
with open('./mattermost-openshift-workdir/Dockerfile', 'w') as f:
f.write(dfp.content)
f.close()
# commit our work
repository.index.add(['Dockerfile'])
author = Actor('Mattermost Server Updater Bot', 'goern+bot@b4mad.net')
committer = Actor('Mattermost Server Updater Bot', 'goern+bot@b4mad.net')
repository.index.commit("Update to Mattermost " + release_version,
author=author, committer=committer)
# and push to origin
with repository.git.custom_environment(GIT_SSH_COMMAND=SSH_CMD):
repository.remotes.origin.push(refspec='{}:{}'.format(
target_branch, target_branch))
示例15: convert
# 需要导入模块: import git [as 别名]
# 或者: from git import Actor [as 别名]
def convert(self, redmine_page):
title = (self.textile_converter.normalize(redmine_page["title"])
if 'parent' in redmine_page
else 'home')
print("Converting {} ({} version {})".format(title, redmine_page["title"], redmine_page["version"]))
text = redmine_page.get('text', "")
# create a copy of the original page (for comparison, will not be committed)
file_name = title + ".textile"
with open(self.repo_path + "/" + file_name, mode='wt', encoding='utf-8') as fd:
print(text, file=fd)
# replace some contents
text = text.replace("{{lastupdated_at}}", redmine_page["updated_on"])
text = text.replace("{{lastupdated_by}}", redmine_page["author"]["name"])
text = text.replace("[[PageOutline]]", "")
text = text.replace("{{>toc}}", "")
text = self.textile_converter.convert(text)
# save file with author/date
file_name = title + ".md"
with open(self.repo_path + "/" + file_name, mode='wt', encoding='utf-8') as fd:
print(text.replace('\n', "\n"), file=fd)
# todo: check for attachments
# todo: upload attachments
if redmine_page["comments"]:
commit_msg = redmine_page["comments"] + " (" + title + " v" + str(redmine_page["version"]) + ")";
else:
commit_msg = title + ", version " + str(redmine_page["version"]);
author = Actor(redmine_page["author"]["name"], "")
time = redmine_page["updated_on"].replace("T", " ").replace("Z", " +0000")
self.repo.index.add([file_name])
self.repo.index.commit(commit_msg, author=author, committer=author, author_date=time, commit_date=time)