Exemple #1
0
 def setUp(self):
     # Set up small network
     sub.call(["cp", "-R", "small_network_repo.git", ".git"])
     path = os.getcwd()
     self.my_log = gitnet.get_log(path)
     self.ignore_all = self.my_log.ignore(".*.md")
     self.ignore_one = self.my_log.ignore("file1.md")
Exemple #2
0
    def setUp(self):
        # Set up small network
        sub.call(["cp", "-R", "small_network_repo.git", ".git"])
        self.good_path = os.getcwd()
        self.my_log = gitnet.get_log(self.good_path)

        self.simp_net = self.my_log.network(type="author/file/simple")
Exemple #3
0
    def test_changes(self):
        """Are changes to files such as merge and delete displayed?"""
        # Setting up a more complicated repository
        sub.call(["rm", "-rf", ".git"])
        sub.call(["cp", "-R", "repo_nx.git", ".git"])
        path = os.getcwd()
        nx_log = gitnet.get_log(path)

        with patch('sys.stdout', new=StringIO()) as fake_out:
            nx_log.describe()
            output = fake_out.getvalue()
            self.assertIsInstance(output, str)
            self.assertIn("Log containing 4881 records from local git created at ", output)
            self.assertIn("\nOrigin:", output)
            self.assertNotIn("Filters:", output)
            self.assertIn("\nNumber of authors: 181\n", output)
            self.assertIn("\nNumber of files: 1559\n", output)
            self.assertIn("\nMost common email address domains:", output)
            self.assertIn("\n\t @gmail.com [89 users]\n", output)
            self.assertIn("\n\t @users.noreply.github.com [8 users]\n", output)
            self.assertIn("\n\t @ucl.ac.uk [2 users]\n", output)
            self.assertIn("\n\t @hotmail.com [2 users]\n", output)
            self.assertIn("\nDate range: 2005-07-12 23:35:35+00:00 to 2016-05-18 21:46:13-04:00\n", output)
            self.assertIn("\nChange distribution summary:\n", output)
            self.assertIn("\n\t Files changed: Mean = 2.621, SD = 8.727", output)
            self.assertIn("\n\t Line insertions: Mean = 103.837, SD = 1082.744\n", output)
            self.assertIn("\n\t Line deletions: Mean = 77.315, SD = 870.92\n", output)
            self.assertIn("\nNumber of merges: 798\n", output)
            self.assertIn("\nNumber of parsing errors: 0\n", output)
Exemple #4
0
 def setUp(self):
     # Set up Repo One
     sub.call(["cp", "-R", "repo_one.git", ".git"])
     good_path = os.getcwd()
     my_log = gitnet.get_log(good_path)
     self.r1 = my_log.collection['fc3527c']
     self.r2 = my_log.collection['44b4c72']
     self.r3 = my_log.collection['51ba020']
Exemple #5
0
 def setUp(self):
     # Set up Repo One
     sub.call(["cp", "-R", "repo_one.git", ".git"])
     good_path = os.getcwd()
     my_log = gitnet.get_log(good_path)
     self.r1 = my_log.collection['fc3527c']
     self.r2 = my_log.collection['44b4c72']
     self.r3 = my_log.collection['51ba020']
Exemple #6
0
    def test_basic(self):
        # Set up small network
        sub.call(["cp", "-R", "small_network_repo.git", ".git"])
        path = os.getcwd()
        my_log = gitnet.get_log(path)

        tags = my_log.get_tags()

        self.assertListEqual(tags, ["hash", "author", "email", "domain", "date", "utc_date", "utc_datetime", "mode", "merge",
                                    "summary", "fedits", "inserts", "deletes", "message", "files", "changes"])

        # Delete temporary .git file
        sub.call(["rm", "-rf", ".git"])
Exemple #7
0
    def test_change_edge(self):
        # Check return type
        self.assertIsInstance(
            helpers.net_edges_changes('Alice', 'file78', self.r3, ['date']),
            tuple)

        # Check return values
        self.assertTupleEqual(
            helpers.net_edges_changes('Alice', 'file78', self.r3, ['date']),
            ("Alice", 'file78', {
                'date': 'Fri May 6 14:50:22 2016 -0400'
            }))

        # Checking Bin execution
        sub.call(["rm", "-rf", ".git"])
        sub.call(["cp", "-R", "repo_nx.git", ".git"])
        good_path = os.getcwd()
        nx_log = gitnet.get_log(good_path)
        nxr1 = nx_log.collection['1dc1602']
        self.assertTupleEqual(
            helpers.net_edges_changes('Dan Schult',
                                      'examples/drawing/knuth_miles.txt.gz',
                                      nxr1, ['date']),
            ('Dan Schult', 'examples/drawing/knuth_miles.txt.gz', {
                'date': 'Fri Aug 7 11:02:04 2015 -0400',
                'weight': 1
            }))

        self.assertTupleEqual(
            helpers.net_edges_changes('Dan Schult',
                                      'networkx/algorithms/threshold.py', nxr1,
                                      ['date']),
            ('Dan Schult', 'networkx/algorithms/threshold.py', {
                'date': 'Fri Aug 7 11:02:04 2015 -0400',
                'weight': 910
            }))
Exemple #8
0
    def test_change_edge(self):
        # Check return type
        self.assertIsInstance(helpers.net_edges_changes('Alice', 'file78', self.r3, ['date']), tuple)

        # Check return values
        self.assertTupleEqual(helpers.net_edges_changes('Alice', 'file78', self.r3, ['date']),
                              ("Alice", 'file78', {'date': 'Fri May 6 14:50:22 2016 -0400'}))


        # Checking Bin execution
        sub.call(["rm","-rf",".git"])
        sub.call(["cp", "-R", "repo_nx.git", ".git"])
        good_path = os.getcwd()
        nx_log = gitnet.get_log(good_path)
        nxr1 = nx_log.collection['1dc1602']
        self.assertTupleEqual(helpers.net_edges_changes('Dan Schult', 'examples/drawing/knuth_miles.txt.gz', nxr1, ['date']),
                              ('Dan Schult', 'examples/drawing/knuth_miles.txt.gz',
                               {'date': 'Fri Aug 7 11:02:04 2015 -0400',
                                'weight': 1}))

        self.assertTupleEqual(helpers.net_edges_changes('Dan Schult', 'networkx/algorithms/threshold.py', nxr1, ['date']),
                              ('Dan Schult', 'networkx/algorithms/threshold.py',
                               {'date': 'Fri Aug 7 11:02:04 2015 -0400',
                                'weight': 910}))
Exemple #9
0
 def setUp(self):
     sub.call(["cp", "-R", "small_network_repo.git", ".git"])
     self.good_path = os.getcwd()
     self.my_log = gitnet.get_log(self.good_path)
Exemple #10
0
 def test_no_commits(self):
     with self.assertRaises(gitnet.RepositoryError):
         print(self.bad_path)
         gitnet.get_log(self.bad_path)
Exemple #11
0
 def setUp(self):
     # Set up Repo One
     sub.call(["cp", "-R", "repo_one.git", ".git"])
     self.good_path = os.getcwd()
     self.my_log = gitnet.get_log(self.good_path)
Exemple #12
0
 def setUp(self):
     # Set up Repo One
     sub.call(["cp","-R","repo_one.git",".git"])
     self.good_path = os.getcwd()
     self.my_log = gitnet.get_log(self.good_path)
Exemple #13
0
 def setUp(self):
     sub.call(["cp", "-R", "small_network_repo.git", ".git"])
     self.good_path = os.getcwd()
     self.my_log = gitnet.get_log(self.good_path)
Exemple #14
0
 def setUp(self):
     # Prepare small network repo for testing.
     sub.call(["cp","-R","small_network_repo.git",".git"])
     self.path = os.getcwd()
     self.mylogs = gitnet.get_log(self.path)
     self.mgraph = self.mylogs.generate_network('author', 'files')
Exemple #15
0
 def setUp(self):
     # Set up small network
     sub.call(["cp", "-R", "small_network_repo.git", ".git"])
     path = os.getcwd()
     self.my_log = gitnet.get_log(path)
Exemple #16
0
 def test_no_repo(self):
     with self.assertRaises(gitnet.RepositoryError):
         gitnet.get_log("/")
Exemple #17
0
 def test_invalid_mode(self):
     with self.assertRaises(gitnet.InputError):
         gitnet.get_log(self.bad_path, mode="hoolagin")
Exemple #18
0
# In a new terminal window, type:
#
# `git clone https://github.com/btford/write-good.git`
#
# OR open the page in a browser and download the zip folder.

# In[ ]:

# Set the current working directory, so that all files created will be stored there.
# The best bet is to create a folder named 'temp' on your desktop.
os.chdir('path')

# In[ ]:

# Insert the path to the write-good folder on your machine.
mylogs = gn.get_log('path')
# You can generate a network using any two tags that exist in the log. For a list of tags, just call .attributes() on your log object.
graph = mylogs.generate_network('author', 'files')
# Quickplot is a preset function that can be used to quickly visualize a network.
graph.quickplot('write_good_net.pdf', layout='spring')

# In[ ]:

# You can get a list of all of the values of any tag in the log object.
# First, lets take a look at all of the possible tags.
print(mylogs.attributes())
# Now, lets print that list of values. Choose one of the tags from above.
print(mylogs.vector('date'))

# ## *2. NetworkX*
# 
# `git clone https://github.com/btford/write-good.git`
# 
# OR open the page in a browser and download the zip folder.

# In[ ]:

# Set the current working directory, so that all files created will be stored there.
# The best bet is to create a folder named 'temp' on your desktop.
os.chdir('path')


# In[ ]:

# Insert the path to the write-good folder on your machine.
mylogs = gn.get_log('path')
# You can generate a network using any two tags that exist in the log. For a list of tags, just call .attributes() on your log object.
graph = mylogs.generate_network('author', 'files')
# Quickplot is a preset function that can be used to quickly visualize a network.
graph.quickplot('write_good_net.pdf', layout = 'spring')


# In[ ]:

# You can get a list of all of the values of any tag in the log object.
# First, lets take a look at all of the possible tags.
print(mylogs.attributes())
# Now, lets print that list of values. Choose one of the tags from above.
print(mylogs.vector('date'))