Skip to content

Commit

Permalink
fix(jans-linux-setup): modification date of MANIFEST.MF in war file i…
Browse files Browse the repository at this point in the history
…s build date (#7453)

Signed-off-by: Mustafa Baser <mbaser@mail.com>
Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
  • Loading branch information
devrimyatar and moabu committed Jan 22, 2024
1 parent e8fa4cf commit 3639863
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions jans-linux-setup/jans_setup/setup_app/utils/printVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import json
import argparse
import datetime

try:
from urllib.request import urlopen
Expand All @@ -28,8 +29,9 @@ def get_latest_commit(service):

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 @@ -43,16 +45,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.jans') 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 3639863

Please sign in to comment.