Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions gitgud/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def postMessage(message):


def continue_commit_prompt():
print "Your commit message is bad. Do you want to continue your commit? [Y/n]"
valid = {"": True, "yes": True, "y": True, "no": False, "n": False}
sys.stdin = open("/dev/tty", "r")
choice = raw_input().lower()
Expand All @@ -36,12 +35,22 @@ def main():
txt_file.close()

# check thie return score
if postMessage(commit_message):
if postMessage(commit_message > 0.8):
# commit if score is good
print "Your commit message is good."
print "Your commit message is quite good."
sys.exit(0)
else if postMessage(commit_message >= 0.5):
# commit if score is good
print "Your commit message could be improved. Do you want to continue your commit? [Y/n]"
if continue_commit_prompt():
sys.exit(0)
else:
# abort if user says no
print("Commit abort.")
sys.exit(1)
else:
# otherwise, ask user if they want to continue the commit
print "Your commit message is bad. Do you want to continue your commit? [Y/n]"
if continue_commit_prompt():
sys.exit(0)
else:
Expand Down
11 changes: 6 additions & 5 deletions server/model/git_good_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import numpy as np
import http.client, urllib.request, urllib.parse, urllib.error, base64
from scipy.sparse import hstack
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
from sklearn.model_selection import train_test_split
from sklearn.metrics import precision_recall_fscore_support as score
from sklearn.neural_network import MLPClassifier
import random
import nltk
from nltk import word_tokenize, pos_tag
Expand All @@ -18,7 +18,7 @@
class GitGudModel():

def __init__(self, dataframe=None):
self.model = MultinomialNB()
self.model = MLPClassifier(100, logistic)
self.dataframe = dataframe
pass

Expand All @@ -35,7 +35,8 @@ def parse_and_split_data(self, df, *, star_thresh=200, fork_thresh=50, watchers_

y = df["label"]

X_train, X_test, y_train, y_test = train_test_split(mcl_transformed, y, test_size=0.1, random_state=random.randint(1, 100))
X_train, X_test, y_train, y_test = train_test_split(mcl_transformed, y,
test_size=0.1, random_state=random.randint(1, 100))

return (X_train, X_test, y_train, y_test)

Expand Down Expand Up @@ -220,7 +221,7 @@ def commit_body_has_present_tense(self, msg, weight):
return self.expon((weight * present / total), 5)


def label_data(self, df, good_thresh=.5):
def label_data(self, df):
label = []

negfunctions = [(self.commit_body_has_swear, 1)]
Expand All @@ -239,7 +240,7 @@ def label_data(self, df, good_thresh=.5):
score += funct(row['msg'], weight)
for funct, weight in negfunctions:
score *= funct(row['msg'], weight)
label.append(GOOD if score > good_thresh else BAD)
label.append(score)

df['label'] = pd.Series(label)
return df
Expand Down