MCPcopy Create free account
hub / github.com/pytorch/pytorch / handle_commit

Method handle_commit

scripts/release_notes/categorize.py:101–181  ·  view source on GitHub ↗
(self, commit, i, total, commits)

Source from the content-addressed store, hash-verified

99 return reasons
100
101 def handle_commit(self, commit, i, total, commits):
102 potential_reverts = self.potential_reverts_of(commit, commits)
103 if potential_reverts:
104 potential_reverts = f"!!!POTENTIAL REVERTS!!!: {potential_reverts}"
105 else:
106 potential_reverts = ""
107
108 features = self.features(commit)
109 if self.classifier is not None:
110 # Some commits don't have authors:
111 author = features.author if features.author else "Unknown"
112 files = " ".join(features.files_changed)
113 classifier_input = CommitClassifierInputs(
114 title=[features.title], files=[files], author=[author]
115 )
116 classifier_category = self.classifier.get_most_likely_category_name(
117 classifier_input
118 )[0]
119
120 else:
121 classifier_category = commit.category
122
123 breaking_alarm = ""
124 if "module: bc-breaking" in features.labels:
125 breaking_alarm += "\n!!!!!! BC BREAKING !!!!!!"
126
127 if "module: deprecation" in features.labels:
128 breaking_alarm += "\n!!!!!! DEPRECATION !!!!!!"
129
130 os.system("clear")
131 view = textwrap.dedent(
132 f"""\
133[{i}/{total}]
134================================================================================
135{features.title}
136
137{potential_reverts} {breaking_alarm}
138
139{features.body}
140
141Files changed: {features.files_changed}
142
143Labels: {features.labels}
144
145Current category: {commit.category}
146
147Select from: {', '.join(common.categories)}
148
149 """
150 )
151 print(view)
152 cat_choice = None
153 while cat_choice is None:
154 print("Enter category: ")
155 value = input(f"{classifier_category} ").strip()
156 if len(value) == 0:
157 # The user just pressed enter and likes the default value
158 cat_choice = classifier_category

Callers 1

categorizeMethod · 0.95

Calls 7

potential_reverts_ofMethod · 0.95
featuresMethod · 0.95
update_commitMethod · 0.95
stripMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected