def test_plugin_commit_message(git_project): git_plugin = FSPlugin(git_project) NEW_COMMIT_MSG = "New commit message" git_plugin.pull() assert not git_plugin.config.get("pootle_fs.commit_message") # make some updates git_plugin.push_translations() # check that commit message uses default when not set in config with tmp_git(git_plugin.fs_url) as (tmp_repo_path, tmp_repo): last_commit = tmp_repo.git.log('-1', '--pretty=%s') assert last_commit == DEFAULT_COMMIT_MSG # update the config git_plugin.config["pootle_fs.commit_message"] = NEW_COMMIT_MSG # make further updates git_plugin.add_translations() git_plugin.sync_translations() # test that sync_translations committed with new commit message with tmp_git(git_plugin.fs_url) as (tmp_repo_path, tmp_repo): last_commit = tmp_repo.git.log('-1', '--pretty=%s') assert last_commit == NEW_COMMIT_MSG
def test_plugin_commit_committer(git_project): plugin = FSPlugin(git_project) NEW_COMMITTER_NAME = "New Committer" NEW_COMMITTER_EMAIL = "*****@*****.**" plugin.pull() assert not plugin.config.get("pootle_fs.committer_name") assert not plugin.config.get("pootle_fs.committer_email") # make some updates plugin.push_translations() # check that commit message uses system default when not set in config with tmp_git(plugin.fs_url) as (tmp_repo_path, tmp_repo): last_committer_name = tmp_repo.git.log('-1', '--pretty=%an') last_committer_email = tmp_repo.git.log('-1', '--pretty=%ae') git_config = tmp_repo.config_reader() default_user = os.environ["USER"] default_email = ( "%s@%s" % (default_user, os.environ.get("HOSTNAME", ""))) assert ( last_committer_name == git_config.get_value("user", "name", default_user)) assert ( last_committer_email == git_config.get_value("user", "email", default_email)) # update the committer name/email in config plugin.config["pootle_fs.committer_name"] = NEW_COMMITTER_NAME plugin.config["pootle_fs.committer_email"] = NEW_COMMITTER_EMAIL # make further updates plugin.add_translations() plugin.sync_translations() # test that sync_translations committed with new commit committer with tmp_git(plugin.fs_url) as (tmp_repo_path, tmp_repo): last_committer_name = tmp_repo.git.log('-1', '--pretty=%cn') last_committer_email = tmp_repo.git.log('-1', '--pretty=%ce') assert last_committer_name == NEW_COMMITTER_NAME assert last_committer_email == NEW_COMMITTER_EMAIL