Hello community,

here is the log from the commit of package obs-service-tar_scm for 
openSUSE:Factory checked in at 2016-08-29 15:39:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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  
2016-08-05 18:17:35.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.obs-service-tar_scm.new/obs-service-tar_scm.changes 
    2016-08-29 15:42:18.000000000 +0200
@@ -1,0 +2,11 @@
+Fri Aug 19 08:11:24 UTC 2016 - [email protected]
+
+- Update to version 0.6.1.1471594222.d257927:
+  * prefer local cache directory
+  * jailed mode for docker integration
+  * added setup of remote branches in jailed mode
+  * new handling for remote/local branches when caching
+- cache handling will be refactored to have only one implementation
+  in future.
+
+-------------------------------------------------------------------

Old:
----
  obs-service-tar_scm-0.6.0.1469628830.67456b7.tar.gz

New:
----
  obs-service-tar_scm-0.6.1.1471594222.d257927.tar.gz

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

Other differences:
------------------
++++++ obs-service-tar_scm.spec ++++++
--- /var/tmp/diff_new_pack.YsFhkq/_old  2016-08-29 15:42:23.000000000 +0200
+++ /var/tmp/diff_new_pack.YsFhkq/_new  2016-08-29 15:42:23.000000000 +0200
@@ -20,18 +20,18 @@
 %define seperate_build 0
 
 %if "%seperate_build" == "1"
-%define version_unconverted 0.6.0.1469628830.67456b7
+%define version_unconverted 0.6.1.1471594222.d257927
 
 Name:           obs-service-obs_scm
 %else
-%define version_unconverted 0.6.0.1469628830.67456b7
+%define version_unconverted 0.6.1.1471594222.d257927
 
 Name:           obs-service-%{service}
 #Obsoletes:      obs-service-obs_scm
 Provides:       obs-service-obs_scm = %version-%release
 %endif
 Provides:       obs-service-tar = %version-%release
-Version:        0.6.0.1469628830.67456b7
+Version:        0.6.1.1471594222.d257927
 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.YsFhkq/_old  2016-08-29 15:42:23.000000000 +0200
+++ /var/tmp/diff_new_pack.YsFhkq/_new  2016-08-29 15:42:23.000000000 +0200
@@ -4,7 +4,7 @@
     <param name="scm">git</param>
     <param name="exclude">.git</param>
     <param name="version">git-master</param>
-    <param name="versionformat">0.6.0.%ct.%h</param>
+    <param name="versionformat">0.6.1.%ct.%h</param>
     <param name="revision">master</param>
     <param name="changesgenerate">enable</param>
   </service>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.YsFhkq/_old  2016-08-29 15:42:23.000000000 +0200
+++ /var/tmp/diff_new_pack.YsFhkq/_new  2016-08-29 15:42:23.000000000 +0200
@@ -1,6 +1,6 @@
 <servicedata>
 <service name="tar_scm">
             <param 
name="url">git://github.com/adrianschroeter/obs-service-tar_scm.git</param>
-          <param 
name="changesrevision">67456b7400afa5c2c03d7701682470296497751a</param></service><service
 name="tar_scm">
+          <param 
name="changesrevision">309b68f96203645af093c0c2285655f2cf8f1aee</param></service><service
 name="tar_scm">
             <param 
name="url">git://github.com/openSUSE/obs-service-tar_scm.git</param>
           <param 
name="changesrevision">49c9462599650ab6a6d122b9156c732187cf99ea</param></service></servicedata>
\ No newline at end of file

++++++ obs-service-tar_scm-0.6.0.1469628830.67456b7.tar.gz -> 
obs-service-tar_scm-0.6.1.1471594222.d257927.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.6.0.1469628830.67456b7/tar_scm.py 
new/obs-service-tar_scm-0.6.1.1471594222.d257927/tar_scm.py
--- old/obs-service-tar_scm-0.6.0.1469628830.67456b7/tar_scm.py 2016-07-27 
16:13:50.000000000 +0200
+++ new/obs-service-tar_scm-0.6.1.1471594222.d257927/tar_scm.py 2016-08-19 
10:10:22.000000000 +0200
@@ -40,6 +40,38 @@
 
 DEFAULT_AUTHOR = '[email protected]'
 
+def setup_tracking_branches(git_dir):
+    output = subprocess.Popen(["git", "-C", git_dir, "branch", "-a"], 
stdout=subprocess.PIPE).communicate()[0]
+
+    p = re.compile('.* ->\s+(.*)')
+    p2 = re.compile('.?\s*((remotes/(.*)/)?(.+))')
+
+    remote_branches = {}
+    local_branches  = {}
+    local2remove    = {}
+
+    for line in output.split("\n"):
+        m = p.match(line)
+        if not m:
+            m2 = p2.match(line)
+            if m2:
+                if m2.group(2):
+                    if m2.group(3) == 'origin':
+                        remote_branches[m2.group(4)] = m2.group(1)
+                else:
+                    local_branches[m2.group(4)] = 1
+
+    for branch in local_branches:
+        try:
+            del remote_branches[branch]
+        except KeyError:
+            local2remove[branch] = 1
+
+    for branch in remote_branches:
+        subprocess.Popen(["git", "-C", git_dir, "branch", "--track", branch, 
remote_branches[branch]], stdout=subprocess.PIPE)
+
+    for branch in local2remove:
+        subprocess.Popen(["git", "-C", git_dir, "branch", "-D", branch])
 
 def run_cmd(cmd, cwd, interactive=False, raisesysexit=False):
     """Execute the command cmd in the working directory cwd and check return
@@ -100,15 +132,38 @@
 
 def fetch_upstream_git(url, clone_dir, revision, cwd, kwargs):
     """Fetch sources via git."""
-    command = ['git', 'clone', url, clone_dir]
-    if not is_sslverify_enabled(kwargs):
-        command += ['--config', 'http.sslverify=false']
-    safe_run(command, cwd=cwd, interactive=sys.stdout.isatty())
-    # if the reference does not exist.
-    if revision and not git_ref_exists(clone_dir, revision):
-        # fetch reference from url and create locally
-        safe_run(['git', 'fetch', url, revision + ':' + revision],
-                 cwd=clone_dir, interactive=sys.stdout.isatty())
+    if kwargs['jailed']:
+        reponame = url.split('/')[-1];
+        clone_cache_dir = os.path.join(kwargs['cachedir'],reponame)
+        if not os.path.isdir(os.path.join(clone_cache_dir,'.git')):
+            # clone if no .git dir exists
+            command = ['git', 'clone', '--no-checkout', url, clone_cache_dir]
+            if not is_sslverify_enabled(kwargs):
+                command += ['--config', 'http.sslverify=false']
+        else:
+            # "git fetch" is a blocking command
+            # so no race conditions should occur between multiple service 
processes
+            command = ['git', '-C', clone_cache_dir, 'fetch', '--tags', 
'--prune']
+
+        safe_run(command, cwd=cwd, interactive=sys.stdout.isatty())
+
+       setup_tracking_branches(clone_cache_dir)
+
+        # We use a temporary shared clone to avoid race conditions
+        # between multiple services
+        safe_run(['git','clone','--shared',clone_cache_dir,clone_dir], 
cwd=cwd, interactive=sys.stdout.isatty())
+
+    else:
+        command = ['git', 'clone', url, clone_dir]
+
+        if not is_sslverify_enabled(kwargs):
+            command += ['--config', 'http.sslverify=false']
+        safe_run(command, cwd=cwd, interactive=sys.stdout.isatty())
+        # if the reference does not exist.
+        if revision and not git_ref_exists(clone_dir, revision):
+            # fetch reference from url and create locally
+            safe_run(['git', 'fetch', url, revision + ':' + revision],
+                     cwd=clone_dir, interactive=sys.stdout.isatty())
 
 
 def fetch_upstream_git_submodules(clone_dir, kwargs):
@@ -294,6 +349,8 @@
 
 def fetch_upstream(scm, url, revision, out_dir, **kwargs):
     """Fetch sources from repository and checkout given revision."""
+    logging.debug("CACHEDIR: '%s'" % kwargs['cachedir'])
+    logging.debug("JAILED: '%d'" % kwargs['jailed'])
     clone_prefix = ""
     if 'clone_prefix' in kwargs:
         clone_prefix = kwargs['clone_prefix']
@@ -1148,6 +1205,9 @@
                         help='osc service parameter for internal use only '
                              '(determines where generated files go before '
                              'collection')
+    parser.add_argument('--jailed', required=False, type=int, default=0,
+                        help='service parameter for internal use only '
+                             '(determines whether service runs in docker 
jail)')
     parser.add_argument('--history-depth',
                         help='Obsolete osc service parameter that does '
                              'nothing')
@@ -1189,7 +1249,11 @@
 
 
 def get_repocachedir():
-    # check for enabled caches (1. environment, 2. user config, 3. system wide)
+    # check for enabled caches (1. local .cache, 2. environment, 3. user 
config, 4. system wide)
+    cwd = os.getcwd()
+    if os.path.isdir(os.path.join(cwd, '.cache')):
+        return os.path.join(cwd, '.cache')
+
     repocachedir = os.getenv('CACHEDIRECTORY')
     if repocachedir is None:
         config = get_config_options()
@@ -1258,22 +1322,23 @@
     repocachedir = get_repocachedir()
 
     repodir = None
-    # construct repodir (the parent directory of the checkout)
-    if repocachedir and os.path.isdir(repocachedir):
-        # construct subdirs on very first run
-        if not os.path.isdir(os.path.join(repocachedir, 'repo')):
-            os.mkdir(os.path.join(repocachedir, 'repo'))
-        if not os.path.isdir(os.path.join(repocachedir, 'incoming')):
-            os.mkdir(os.path.join(repocachedir, 'incoming'))
-
-        repohash = get_repocache_hash(args.scm, args.url, args.subdir)
-        logging.debug("HASH: %s", repohash)
-        repodir = os.path.join(repocachedir, 'repo')
-        repodir = os.path.join(repodir, repohash)
-
-    # if caching is enabled but we haven't cached something yet
-    if repodir and not os.path.isdir(repodir):
-        repodir = tempfile.mkdtemp(dir=os.path.join(repocachedir, 'incoming'))
+    if not args.jailed:
+        # construct repodir (the parent directory of the checkout)
+        if repocachedir and os.path.isdir(repocachedir):
+            # construct subdirs on very first run
+            if not os.path.isdir(os.path.join(repocachedir, 'repo')):
+                os.mkdir(os.path.join(repocachedir, 'repo'))
+            if not os.path.isdir(os.path.join(repocachedir, 'incoming')):
+                os.mkdir(os.path.join(repocachedir, 'incoming'))
+
+            repohash = get_repocache_hash(args.scm, args.url, args.subdir)
+            logging.debug("HASH: %s", repohash)
+            repodir = os.path.join(repocachedir, 'repo')
+            repodir = os.path.join(repodir, repohash)
+
+        # if caching is enabled but we haven't cached something yet
+        if repodir and not os.path.isdir(repodir):
+            repodir = tempfile.mkdtemp(dir=os.path.join(repocachedir, 
'incoming'))
 
     if repodir is None:
         repodir = tempfile.mkdtemp(dir=args.outdir)
@@ -1300,7 +1365,7 @@
             # not need in case of local osc build
             os.rename(basename, clone_dir)
     else:
-        clone_dir = fetch_upstream(out_dir=repodir, **args.__dict__)
+        clone_dir = fetch_upstream(out_dir=repodir,cachedir=repocachedir, 
**args.__dict__)
 
     if args.filename:
         dstname = basename = args.filename


Reply via email to