From 9408e404ab45d518eb1a88b35e65d0ec63ea3264 Mon Sep 17 00:00:00 2001 From: Steve McColl Date: Wed, 31 Aug 2016 10:13:06 -0400 Subject: [PATCH 1/2] Added the tag calendar feature for get log. --- gitnet/get_log.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gitnet/get_log.py b/gitnet/get_log.py index 26736ae..592c824 100644 --- a/gitnet/get_log.py +++ b/gitnet/get_log.py @@ -21,7 +21,7 @@ from gitnet.exceptions import RepositoryError, ParseError, InputError from gitnet.commit_log import CommitLog -def get_log(path, mode="stat", commit_source="local git"): +def get_log(path, mode="stat", commit_source="local git", tag_calendar=True): """ A function for gathering data from a local Git repository. @@ -42,10 +42,18 @@ def get_log(path, mode="stat", commit_source="local git"): **Returns** : `Commitlog` """ + if commit_source == "local git": detect_key = "hash" else: detect_key = "unknown" + if tag_calendar == True: + os.chdir(path) + # Bash should be changed to subprocess. + tag_calendar = sh.bash('git log --tags --simplify-by-decoration --pretty="format:%ai %d"').stdout.decode("utf-8") + if len(tag_calendar) == 0: + print("This repository has no tags.") + print(tag_calendar) return CommitLog(dofd=parse_commits(retrieve_commits(path, mode)), source=commit_source, path=path, @@ -226,7 +234,7 @@ def retrieve_commits(path, mode="stat"): # Save the current directory. Navigate to new directory. Retrieve logs. Return to original directory. work_dir = os.getcwd() os.chdir(path) - raw_logs = sh.bash(log_commands[mode]).stdout.decode("utf-8") + raw_logs = sh.bash(log_commands[mode]).stdout.decode("utf-8", "ignore") os.chdir(work_dir) # If the retrieval was unsuccessful, raise an error. if len(raw_logs) == 0: From 814170bb0649b7be6ff0330eb74e39fbe6f1a363 Mon Sep 17 00:00:00 2001 From: Steve McColl Date: Tue, 6 Sep 2016 10:44:38 -0400 Subject: [PATCH 2/2] Edits to documentation. --- gitnet/log.py | 7 +++++-- gitnet/multigraph.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gitnet/log.py b/gitnet/log.py index 12ce470..d0e3972 100644 --- a/gitnet/log.py +++ b/gitnet/log.py @@ -658,17 +658,20 @@ def generate_network(self, mode1, mode2, colours=None, edge_helper=net_edges_sim >> The tag names of attributes to be saved for each edge. + **NOTE**: Need to refine the below section, since there seems to be some confusing statements. + *Adding atomic attributes to the graph will also add them to any graphml file generated*. + > *mode1_atom_attrs* : `list` >> The tag names of attributes to be saved once for each node of mode1. > *mode2_atom_attrs* : `list` - >> The tag names of attributes to be saved repeatedly for each node of mode1. + >> The tag names of attributes to be saved once for each node of mode2. > *mode1_vector_attrs* : `list` - >> The tag names of attributes to be saved once for each node of mode2. + >> The tag names of attributes to be saved repeatedly for each node of mode1. > *mode2_vector_attrs* : `list` diff --git a/gitnet/multigraph.py b/gitnet/multigraph.py index c0bbfd7..1781bac 100644 --- a/gitnet/multigraph.py +++ b/gitnet/multigraph.py @@ -405,8 +405,8 @@ def write_graphml(self, fname): if warning: warnings.warn("The provided graph contained the vector attributes: {}. All values of vector attributes have" - " been converted to semicolon-delimited strings. To prevent this, remove vector attributes or" - " convert them to atomic attributes prior to calling .write_graphml" + "\nbeen converted to semicolon-delimited strings. To prevent this, remove vector attributes or" + "\nconvert them to atomic attributes prior to calling .write_graphml" .format(warning_set)) nx.write_graphml(graph, fname) print("Success. Wrote GraphML file {} to {}".format(fname, os.getcwd()))