import datetime as dt from perceval.backends.core.git import Git #globals repo_dir = '/tmp/perceval.git' #main function for all subsequent tasks using perceval def main(vcs_path, begin_date): perceval_info = {} perceval_info['list_of_commits'] = get_perceval_log(vcs_path, begin_date) perceval_info['age_of_project'] = get_repo_age(perceval_info['list_of_commits'] ) return perceval_info # this is the primary function for getting the list of commits from perceval def get_perceval_log(vcs_path, begin_date): repo = Git(uri=vcs_path[0], gitpath=repo_dir) # this is a temporary date_from, will need to be more inclusive in the future fetched_commits = repo.fetch(from_date=begin_date) return list(fetched_commits) #this function is just to evaluate the repository age, as defined by Tamburri and used by van Meijel def get_repo_age(all_commits): first_commit = all_commits[0] last_commit = all_commits[-1] first_date = dt.datetime.strptime(first_commit['data']["CommitDate"], '%c %z') last_date = dt.datetime.strptime(last_commit['data']["CommitDate"], '%c %z') print(first_date) print("---------------------") print(last_date) #project life, as defined in YOSHI, unit is days project_life = last_date - first_date print(project_life) return project_life if __name__ == "__main__": manifest = '../kaylea_dissertation/lifecycle/package_metadata/woof_manifest.yaml' main(manifest)