Skip to content

Commit

Permalink
fix: modification date of MANIFEST.MF in war file is build date
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Baser <[email protected]>
  • Loading branch information
devrimyatar committed Jan 22, 2024
1 parent 8773dda commit 136c862
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions setup_app/utils/printVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ssl
import json
import argparse
import datetime

try:
from urllib.request import urlopen
Expand Down Expand Up @@ -36,8 +37,9 @@ def get_latest_commit(service, branch):

def get_war_info(war_fn):
retDict = {'title':'', 'version':'', 'build':'', 'buildDate':'', 'branch':''}
war_zip = zipfile.ZipFile(war_fn,"r")
menifest = war_zip.read('META-INF/MANIFEST.MF')
war_zip = zipfile.ZipFile(war_fn, 'r')
menifest_fn = 'META-INF/MANIFEST.MF'
menifest = war_zip.read(menifest_fn)

for l in menifest.splitlines():
ls = l.strip().decode('utf-8')
Expand All @@ -51,16 +53,10 @@ def get_war_info(war_fn):
branch = branch.split('/')[1]

retDict['branch'] = branch


for f in war_zip.filelist:
if f.filename.startswith('META-INF/maven/org.gluu') and f.filename.endswith('pom.properties'):
pom_prop = war_zip.read(f.filename)
for l in pom_prop.splitlines():
build_date = re.findall("\w{3}\s\w{3}\s{1,2}\w{1,2}\s\w{2}:\w{2}:\w{2}\s[+\w]{3}\s\w{4}", l.decode('utf-8'))
if build_date:
retDict['buildDate'] = build_date[0]
break
menifest_info = war_zip.getinfo(menifest_fn)
retDict['buildDate'] = str(datetime.datetime(*menifest_info.date_time))


return retDict

Expand Down

0 comments on commit 136c862

Please sign in to comment.