@@ -55,43 +55,45 @@ def parse_line(line, kind):
5555 title = title .replace ("/" , "|" )
5656 title = title .rstrip ("." )
5757
58- repo_link = ""
58+ pr_repo , issue_repo = "" , ""
5959
6060 for entry in entries :
6161 number = entry [entry .find ("[" )+ 1 :entry .find ("]" )]
6262 number = '' .join (filter (lambda n : n .isdigit (), number ))
63+ entry_data = entry .split ("}" )[0 ]
6364
64- if "pull" in entry :
65- fragment_field , default_repo_token = ["pr" , "pull}" ]
66- if "issue" in entry :
67- fragment_field , default_repo_token = ["issue" , "issue}" ]
65+ try :
66+ fragment_field , repo = entry_data .split ("-" )
67+ repo_link = repo_dict [repo ]
68+ except ValueError :
69+ fragment_field , repo_link = entry_data , default_repolink
70+
71+ fragment_field = fragment_field .replace ("pull" , "pr" )
6872
6973 if fragment_field in fragment_dict .keys ():
7074 print (f"Skipping { line } -> multiple PRs/issues found!\n " )
7175 return
7276
73- fragment_dict [fragment_field ] = number
74-
75- if entry .startswith (default_repo_token ):
76- if repo_link :
77- if repo_link != default_repolink :
78- print (f"Skipping { line } -> multiple repositories found!\n " )
79- return
80- repo_link = default_repolink
81- else :
82- for repo in repo_dict .keys ():
83- if repo in entry :
84- if repo_link and repo_link != repo_dict [repo ]:
85- print (f"Skipping { line } -> multiple repositories found!\n " )
86- return
87- repo_link = repo_dict [repo ]
88-
89- if repo_link :
90- fragment_dict ["repository" ] = repo_link
91-
77+ if fragment_field == "pr" :
78+ fragment_dict [fragment_field ] = number
79+ pr_repo = repo_link
80+ elif fragment_field == "issue" :
81+ fragment_dict [fragment_field ] = number
82+ issue_repo = repo_link
83+
84+ if pr_repo :
85+ fragment_dict ["repository" ] = pr_repo
86+ elif issue_repo :
87+ fragment_dict ["repository" ] = issue_repo
88+
89+ if issue_repo != pr_repo and pr_repo :
90+ try :
91+ del fragment_dict ["issue" ]
92+ except KeyError :
93+ pass
94+
9295 write_fragment (title , fragment_dict )
9396
94-
9597def iterate_lines (f , kind = '' , skip = True ):
9698 line = next (f , None )
9799 if line is None :
0 commit comments