{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "19bb933c",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pydriller import Repository\n",
    "import pandas as pd\n",
    "import csv\n",
    "import sys\n",
    "import requests\n",
    "\n",
    "def commit_tmp():\n",
    "    df = pd.read_csv('template_commit.csv')\n",
    "\n",
    "    for index, row in df.iterrows():\n",
    "        print(index)\n",
    "        repo_url = str(row['url'])\n",
    "        repo_file = str(row['file_name'])\n",
    "        try:\n",
    "            with open(\"commit_message_0213.csv\", 'a', encoding='utf-8', newline=\"\") as file:\n",
    "                writer = csv.writer(file)\n",
    "                for commit in Repository(repo_url, filepath=repo_file).traverse_commits():\n",
    "                    writer.writerow((repo_url, repo_file, commit.hash, commit.msg, commit.author.name, commit.author.email, \n",
    "                                     commit.committer.name, commit.committer.email, commit.committer_date, \n",
    "                                     commit.deletions, commit.insertions))\n",
    "        except Exception as e:\n",
    "            print(index, e)\n",
    "            pass\n",
    "    print('finished!')\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    commit_tmp()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
