Advertising (This ad goes away for registered users. You can Login or Register)

Qcma - Crossplatform content manager for the PSVita

Open discussions on programming specifically for the PS Vita.
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Locked
TheDevilItSelf!
Posts: 60
Joined: Fri Jul 19, 2013 10:42 am

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by TheDevilItSelf! »

Just passing by to mention the new windows version is working great, thanks.

OS: Windows 8.1 update 1
Advertising
codestation
Big Beholder
Posts: 1660
Joined: Wed Jan 19, 2011 3:45 pm
Location: /dev/negi

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by codestation »

@Xian: checked yor script, the idea is good, sadly i cannot use that changelog format because debian uses a very strict format: https://www.debian.org/doc/debian-polic ... gchangelog

The script is simple enough to only require a main body but if you make it bigger then consider using some functions and make use of the "if __name__ == '__main__':" stuff.
Advertising
Plugin list
Working on: QPSNProxy, QCMA - Open source content manager for the PS Vita
Playing: Error: ENOTIME
Repositories: github, google code
Just feel the code..
Xian Nox
Retired Mod
Posts: 2744
Joined: Fri Nov 05, 2010 5:27 pm
Location: Over the hills and far away

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by Xian Nox »

codestation wrote:@Xian: checked yor script, the idea is good, sadly i cannot use that changelog format because debian uses a very strict format: https://www.debian.org/doc/debian-polic ... gchangelog
Should be feasible to make a converter, I think. I'll look into it.
codestation
Big Beholder
Posts: 1660
Joined: Wed Jan 19, 2011 3:45 pm
Location: /dev/negi

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by codestation »

What about one that can read the commit entries between the last tag and HEAD and generate a new set of entries in the changelog? I have looked for that everywhere and always end making the changelog by hand ( found some perl scripts but they are too old and don't work anymore).
Plugin list
Working on: QPSNProxy, QCMA - Open source content manager for the PS Vita
Playing: Error: ENOTIME
Repositories: github, google code
Just feel the code..
Xian Nox
Retired Mod
Posts: 2744
Joined: Fri Nov 05, 2010 5:27 pm
Location: Over the hills and far away

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by Xian Nox »

Something along the lines of this?
- Get output from git log v0.3.1..v0.3.2 --pretty=oneline --abbrev-commit (if v0.3.2 is not specified, it will just go to HEAD)
- Add header/footer based on format (rpm/deb)
- Save to temp file and open it in nano
- Once nano exits, continue

The only thing is, is that the correct git command to use for the occasion?
codestation
Big Beholder
Posts: 1660
Joined: Wed Jan 19, 2011 3:45 pm
Location: /dev/negi

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by codestation »

I like the idea to open a temp file with nano to review the entries and remove/edit them. I added some sed magic to remove the commit id and add the " * " (for deb):

Code: Select all

git log v0.3.1..v0.3.2 --pretty=oneline --abbrev-commit | sed 's/^.\{,7\}/  */'
To obtain the last tag:

Code: Select all

git describe --abbrev=0 --tags
Maybe this could work:

Code: Select all

git log $(git describe --abbrev=0 --tags)..HEAD --pretty=oneline --abbrev-commit | sed 's/^.\{,7\}/  */'
Plugin list
Working on: QPSNProxy, QCMA - Open source content manager for the PS Vita
Playing: Error: ENOTIME
Repositories: github, google code
Just feel the code..
Xian Nox
Retired Mod
Posts: 2744
Joined: Fri Nov 05, 2010 5:27 pm
Location: Over the hills and far away

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by Xian Nox »

Should only give the commit messages

Code: Select all

latest_tag = subprocess.check_output(["git", "describe", "--tags"]).decode("utf-8").rstrip()
# or latest_tag = 'v0.3.1' for testing purposes
commit_logs = subprocess.check_output(["git", "log", latest_tag + "..", "--pretty=oneline"]).decode("utf-8")
print(re.sub('[0-9a-f]{40} ', '', commit_logs))
Edit: something along these lines?

Code: Select all

#!/usr/bin/python3
import argparse
import subprocess
import re
import tempfile
from time import strftime

parser = argparse.ArgumentParser(
  prog='genlog', 
  description='Command-line utility to generate changelog files based on version control commit logs', 
  epilog='Well, on second thought, let\'s not go to Camelot. It is a silly place.')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.1')
parser.add_argument('-g', '--git', action='store_true', help='use git to retrieve commit logs')
parser.add_argument('-m', '--hg', action='store_true', help='use hg to retrieve commit logs')
parser.add_argument('-d', '--debian', action='store_true', help='create debian-style changelog')
parser.add_argument('-r', '--rpm', action='store_true', help='create rpm-style changelog')
parser.add_argument('-c', '--changelog', default='ChangeLog', help='path to the changelog file to be used')

args = parser.parse_args()

# Check if vcs and style are set
if((args.git is not True and args.hg is not True) or (args.debian is not True and args.rpm is not True)):
  print('Invalid parameters. See genspec -h or genspec --help for more information on usage')
  quit()

# Retrieve the commit logs
if(args.git):
  latest_tag = subprocess.check_output(["git", "describe", "--tags"]).decode("utf-8").rstrip()
  commit_logs = subprocess.check_output(["git", "log", latest_tag + "..", "--pretty=oneline"]).decode("utf-8")
  commit_logs = re.sub('[0-9a-f]{40} ', '', commit_logs)
elif(args.hg):
  latest_tag = subprocess.check_output(["hg", "parents", "--template", "'{latesttag}'"]).decode("utf-8").rstrip()
  commit_logs = subprocess.check_output(["hg", "log", "--rev", "tip:" + latest_tag, "--template", "{desc}\n"]).decode("utf-8")

# Prepare commit logs based on format (rpm/deb)
if(args.debian):
  # prettify commits
  split = commit_logs.splitlines()
  commit_logs = ''
  for s in split:
    commit_logs += '  * ' + s + '\n'
  
  # assemble into entry
  commit_logs  = 'qcma (0.3.2) unstable; urgency=low\n\n' + commit_logs + '\n'
  commit_logs += '-- ' + input('Changelog author: ') + ' <' + input('Changelog author email: ') + '> ' + strftime("%a, %d %b %Y %H:%M:%S %z") + '\n'
  
elif(args.rpm):
  # prettify commits
  split = commit_logs.splitlines()
  commit_logs = ''
  for s in split:
    commit_logs += ' - ' + s + '\n'
  
  # assemble into entry
  commit_logs = '* ' + strftime("%a %b %d %Y") + ' <' + input('Changelog author: ') + '> ' + input('Version: ') + '\n' + commit_logs

# Open a temporary file and present the commit logs for editing
with tempfile.NamedTemporaryFile(mode='w+') as temp:
  temp.write(commit_logs)
  temp.flush()	# there's a good chance the random text will remain in cache and not get shown otherwise
  subprocess.call(["nano", temp.name])
  with open(temp.name, 'r') as temp_reader:
    commit_logs = temp_reader.read()

# Save new changelog entry at the start of the changelog file
if(input('Save specfile? (y/N) ') == 'y'):
  with open(args.changelog, 'r') as output_file:
    old_logs = output_file.read()
    
    with open(args.changelog, 'w') as wfile:
      wfile.write(commit_logs + '\n' + old_logs)
      print('Changelog saved.')

Kotyan
Posts: 5
Joined: Sat May 03, 2014 7:24 am
Location: Tokyo, Japan
Contact:

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by Kotyan »

good job!
TheDevilItSelf!
Posts: 60
Joined: Fri Jul 19, 2013 10:42 am

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by TheDevilItSelf! »

i was wondering if we can get and automatically start
program when windows starts option for the next release.
codestation
Big Beholder
Posts: 1660
Joined: Wed Jan 19, 2011 3:45 pm
Location: /dev/negi

Re: QCMA - Cross-platform content manager for the PSVita (0.

Post by codestation »

TheDevilItSelf! wrote:i was wondering if we can get and automatically start
program when windows starts option for the next release.
OK, i will add a checkbox to the end of the installer so you can set qcma to run at windows startup.
Plugin list
Working on: QPSNProxy, QCMA - Open source content manager for the PS Vita
Playing: Error: ENOTIME
Repositories: github, google code
Just feel the code..
Locked

Return to “Programming and Security”