Hello community,

here is the log from the commit of package obs-service-tar_scm for 
openSUSE:Factory checked in at 2013-11-26 19:21:43
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/obs-service-tar_scm (Old)
 and      /work/SRC/openSUSE:Factory/.obs-service-tar_scm.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "obs-service-tar_scm"

Changes:
--------
--- /work/SRC/openSUSE:Factory/obs-service-tar_scm/obs-service-tar_scm.changes  
2013-11-01 14:38:37.000000000 +0100
+++ 
/work/SRC/openSUSE:Factory/.obs-service-tar_scm.new/obs-service-tar_scm.changes 
    2013-11-26 19:21:44.000000000 +0100
@@ -1,0 +2,6 @@
+Tue Nov 19 10:15:53 UTC 2013 - [email protected]
+
+- Bump version to 0.3.2
+  * changes file generation support written by Sascha
+
+-------------------------------------------------------------------

Old:
----
  obs-service-tar_scm-0.3.1.1383144507.58d1af8.tar.gz

New:
----
  obs-service-tar_scm-0.3.2.1384855776.cc62c54.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ obs-service-tar_scm.spec ++++++
--- /var/tmp/diff_new_pack.Asx8X1/_old  2013-11-26 19:21:44.000000000 +0100
+++ /var/tmp/diff_new_pack.Asx8X1/_new  2013-11-26 19:21:44.000000000 +0100
@@ -19,7 +19,7 @@
 %define service tar_scm
 
 Name:           obs-service-%{service}
-Version:        0.3.1.1383144507.58d1af8
+Version:        0.3.2.1384855776.cc62c54
 Release:        0
 Summary:        An OBS source service: checkout or update a tar ball from 
svn/git/hg
 License:        GPL-2.0+

++++++ _service ++++++
--- /var/tmp/diff_new_pack.Asx8X1/_old  2013-11-26 19:21:44.000000000 +0100
+++ /var/tmp/diff_new_pack.Asx8X1/_new  2013-11-26 19:21:44.000000000 +0100
@@ -1,10 +1,10 @@
 <services>
   <service name="tar_scm" mode="disabled">
-    <param name="url">[email protected]:openSUSE/obs-service-tar_scm.git</param>
+    <param name="url">git://github.com/openSUSE/obs-service-tar_scm.git</param>
     <param name="scm">git</param>
     <param name="exclude">.git</param>
     <param name="version">git-master</param>
-    <param name="versionformat">0.3.1.%ct.%h</param>
+    <param name="versionformat">0.3.2.%ct.%h</param>
     <param name="revision">master</param>
   </service>
 

++++++ obs-service-tar_scm-0.3.1.1383144507.58d1af8.tar.gz -> 
obs-service-tar_scm-0.3.2.1384855776.cc62c54.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/obs-service-tar_scm-0.3.1.1383144507.58d1af8/tar_scm 
new/obs-service-tar_scm-0.3.2.1384855776.cc62c54/tar_scm
--- old/obs-service-tar_scm-0.3.1.1383144507.58d1af8/tar_scm    2013-10-30 
15:58:20.000000000 +0100
+++ new/obs-service-tar_scm-0.3.2.1384855776.cc62c54/tar_scm    2013-11-19 
11:16:32.000000000 +0100
@@ -23,6 +23,9 @@
   MYPACKAGEMETA=""
   USE_SUBMODULES=enable
 #  MYHISTORYDEPTH=""
+  CHANGES_GENERATE=disable
+  CHANGES_REVISION=""
+  CHANGES_AUTHOR=""
   INCLUDES=""
 }
 
@@ -96,6 +99,14 @@
         USE_SUBMODULES="$2"
         shift
       ;;
+      *-changesgenerate)
+        CHANGES_GENERATE="$2"
+        shift
+      ;;
+      *-changesauthor)
+        CHANGES_AUTHOR="$2"
+        shift
+      ;;
       *)
         echo "Unknown parameter: $1"
         echo 'Usage: $SERVICE --scm $SCM --url $URL [--subdir $SUBDIR] 
[--revision $REVISION] [--version $VERSION] [--include $INCLUDE]* [--exclude 
$EXCLUDE]* [--versionformat $FORMAT] [--versionprefix $PREFIX] [--filename 
$FILENAME] [--package-meta $META] [--submodules disable] --outdir $OUT'
@@ -165,6 +176,156 @@
   esac
 }
 
+detect_changes () {
+  # Try to load from _servicedata. We have to change $PWD, ET.parse() seems to 
be relative...
+  CHANGES_REVISION=$(python <<-EOF
+import os, shutil
+try:
+    # If lxml is available, we can use a parser that doesnt destroy comments
+    import lxml.etree as ET
+    xml_parser = ET.XMLParser(remove_comments=False)
+except ImportError:
+    import xml.etree.ElementTree as ET
+    xml_parser = None
+create_servicedata, tar_scm_service = False, None
+tar_scm_xmlstring = "  <service name=\"tar_scm\">\n    <param 
name=\"url\">${MYURL}</param>\n  </service>\n"
+try:
+    tree = ET.parse(os.path.join("$SRCDIR", "_servicedata"), parser=xml_parser)
+    root = tree.getroot()
+    for service in root.findall("service[@name='tar_scm']"):
+        for param in service.findall("param[@name='url']"):
+            if param.text == "${MYURL}":
+                tar_scm_service = service
+                break
+    if tar_scm_service:
+        changerev_params = 
tar_scm_service.findall("param[@name='changesrevision']")
+        if len(changerev_params) == 1:
+            print(changerev_params[0].text)  # Found what we searched for!
+    else:
+        # File exists, is well-formed but does not contain the service we 
search
+        root.append(ET.fromstring(tar_scm_xmlstring))
+        tree.write(os.path.join("$MYOUTDIR", "_servicedata"))
+except IOError as e:
+    create_servicedata = True  # File doesnt exist
+except ET.ParseError as e:
+    if e.message.startswith("Document is empty"):
+        create_servicedata = True  # File is empty
+    else:
+        print("error: %s" % e) # File is mal-formed, bail out.
+except Exception as e:
+    print("error: %s" % e)  # Catch-all, since we are in a here-document
+if create_servicedata:
+    root = ET.fromstring("<servicedata>\n%s</servicedata>\n" % 
tar_scm_xmlstring)
+    ET.ElementTree(root).write(os.path.join("$MYOUTDIR", "_servicedata"))
+else:
+    shutil.copy(os.path.join("$SRCDIR", "_servicedata"), 
os.path.join("$MYOUTDIR", "_servicedata"))
+EOF
+)
+  if [[ $CHANGES_REVISION == error* ]] ; then
+    echo $CHANGES_REVISION  # All we can do here, really.
+    exit 1
+  fi
+
+  safe_run cd $REPOPATH
+
+  case "$MYSCM" in
+    git)
+      if [ -z "$CHANGES_REVISION" ]; then
+        # Ok, first run. Let's ask git for a range...
+        CHANGES_REVISION=`safe_run git log -n10 --pretty=format:%H | tail -n 1`
+      fi
+      CURRENT_REVISION=`safe_run git log -n1 --pretty=format:%H`
+      CURRENT_REVISION=${CURRENT_REVISION:0:10} # shorten SHA1 hash
+      # Use pattern-matching to check if either revision is a prefix of the 
other. It's pretty common at least
+      # for git users to abbreviate commit hashes but people disagree on the 
exact length, thus:
+      if [[ ${CURRENT_REVISION} == ${CHANGES_REVISION}* || ${CHANGES_REVISION} 
== ${CURRENT_REVISION}* ]]; then
+        debug "No new commits, skipping changes file generation"
+        return
+      fi
+      debug "Generate changes between $CHANGES_REVISION and $CURRENT_REVISION"
+      lines=`safe_run git log --pretty=format:%s --no-merges 
${CHANGES_REVISION}..${CURRENT_REVISION} | tac`
+      ;;
+    svn|hg|bzr)
+      debug "Unable to generate changes for subversion, mercurial or bazaar, 
skipping changes file generation"
+      return
+    ;;
+    *)
+      error "Unknown SCM '$MYSCM'"
+  esac
+  OLD_IFS="$IFS"
+  IFS=$'\n' CHANGES_LINES=( $lines )
+  IFS="$OLD_IFS"
+  CHANGES_REVISION=$CURRENT_REVISION
+}
+
+write_changes () {
+  # Replace or add changesrevision in _servicedata file and do it in Python, 
otherwise sth. like
+  # https://gist.github.com/mralexgray/1209534 would be needed. The stdlib xml 
module's XPath
+  # support is quite basic, thus there are some for-loops in the code:
+  python <<-EOF
+import os
+try:
+    # If lxml is available, we can use a parser that doesn't destroy comments
+    import lxml.etree as ET
+    xml_parser = ET.XMLParser(remove_comments=False)
+except ImportError:
+    import xml.etree.ElementTree as ET
+    xml_parser = None
+tree = ET.parse(os.path.join("$MYOUTDIR", "_servicedata"), parser=xml_parser)
+root = tree.getroot()
+changed, tar_scm_service = False, None
+for service in root.findall("service[@name='tar_scm']"):
+    for param in service.findall("param[@name='url']"):
+        if param.text == "${MYURL}":
+            tar_scm_service = service
+            break
+if tar_scm_service:
+    changerev_params = 
tar_scm_service.findall("param[@name='changesrevision']")
+    if len(changerev_params) == 1:  # already present, just update
+        if changerev_params[0].text != "${CHANGES_REVISION}":
+            changerev_params[0].text = "${CHANGES_REVISION}"
+            changed = True
+    else:  # not present, add changesrevision element
+        tar_scm_service.append(ET.fromstring("    <param 
name=\"changesrevision\">${CHANGES_REVISION}</param>\n"))
+        changed = True
+    if changed:
+        tree.write(os.path.join("$MYOUTDIR", "_servicedata"))
+else:
+    print("File _servicedata is missing tar_scm with URL '${MYURL}'")
+EOF
+
+  if [ ${#CHANGES_LINES[@]} -eq 0 ] ; then
+    echo "No changes since $CHANGES_REVISION, skipping changes file generation"
+    return
+  fi
+
+  if [ -z "$CHANGES_AUTHOR" ] ; then
+    OSCRC="$HOME/.oscrc"
+    if [ -f $OSCRC ] ; then
+      CHANGES_AUTHOR=$(grep -e '^email.*=' $OSCRC | head -n1 | cut -d"=" -f2)
+    else
+      CHANGES_AUTHOR="[email protected]"
+    fi
+  fi
+
+  
change_entry="-------------------------------------------------------------------
+$(LC_ALL=POSIX TZ=UTC date) - ${CHANGES_AUTHOR}
+
+- Update to version ${TAR_VERSION}:"
+  for commit in "${CHANGES_LINES[@]}" ; do
+      change_entry="$change_entry
+  + $commit"
+  done
+  change_entry="$change_entry
+"
+
+  # Prepend change entry to changes files
+  for changes_file in $SRCDIR/*.changes ; do
+      tmpfile=$(mktemp)
+      echo "$change_entry" | cat - $changes_file > $tmpfile && mv $tmpfile 
$MYOUTDIR/$(basename $changes_file)
+  done
+}
+
 fetch_upstream () {
   TOHASH="$MYURL"
   [ "$MYSCM" = 'svn' ] && TOHASH="$TOHASH/$MYSUBDIR"
@@ -225,6 +386,9 @@
   if [ "$TAR_VERSION" == "_auto_" -o -n "$MYFORMAT" ]; then
     detect_version
   fi
+  if [ "$CHANGES_GENERATE" == "enable" ]; then
+    detect_changes
+  fi
 }
 
 calc_dir_to_clone_to () {
@@ -521,6 +685,9 @@
 
   prep_tree_for_tar
   create_tar
+  if [ "$CHANGES_GENERATE" == "enable" ]; then
+    write_changes
+  fi
 
   cleanup
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.3.1.1383144507.58d1af8/tar_scm.service 
new/obs-service-tar_scm-0.3.2.1384855776.cc62c54/tar_scm.service
--- old/obs-service-tar_scm-0.3.1.1383144507.58d1af8/tar_scm.service    
2013-10-30 15:58:20.000000000 +0100
+++ new/obs-service-tar_scm-0.3.2.1384855776.cc62c54/tar_scm.service    
2013-11-19 11:16:32.000000000 +0100
@@ -66,5 +66,13 @@
     <allowedvalue>enable</allowedvalue>
     <allowedvalue>disable</allowedvalue>
   </param>
+  <param name="changesgenerate">
+    <description>Whether or not to generate changes file entries from SCM 
commit log since a given parent revision (see changesrevision).  Default is 
'disable'.</description>
+    <allowedvalue>enable</allowedvalue>
+    <allowedvalue>disable</allowedvalue>
+  </param>
+  <param name="changesauthor">
+    <description>The author of the changes file entry to be written, defaults 
to first email entry in ~/.oscrc or "[email protected]" if there 
is no .oscrc found.</description>
+  </param>
 </service>
 

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to