handle uncommitted changes
authorAnas Nashif <anas.nashif@intel.com>
Mon, 23 Jul 2012 07:54:58 +0000 (08:54 +0100)
committerAnas Nashif <anas.nashif@intel.com>
Mon, 23 Jul 2012 07:54:58 +0000 (08:54 +0100)
Change-Id: Ib5ef09f53cd027331b43c8cf048cc89335fa87e9

depanneur

index 4dd2d94..ee7e2a1 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -251,10 +251,19 @@ sub fill_packs_from_git() {
     my $pkg_release = $pack->{release};
     my $spec_file = basename($spec);
     my $skip = 0;
+    my $old_base = "";
     if ( -e "$base/.git" ) {
         open(GIT,"git --git-dir $base/.git rev-parse  HEAD |") || die "Failed: $!\n";
         while (my $current_rev = <GIT>) {
             chomp($current_rev);
+            if ( system("grep -rq $current_rev $cache_path") == 0 ) {
+               open(GREP,"grep -rl $current_rev $cache_path |") || die "Failed: $!\n";
+               while ( <GREP> ) {
+                    chomp;
+                   $old_base = $_;
+               }
+               $skip = 1;
+            }
             my @lines = ();
             if ( -e "$cache_path/$pkg_name-$pkg_version-$pkg_release" ) {
                 open (REV, "< $cache_path/$pkg_name-$pkg_version-$pkg_release");
@@ -263,7 +272,6 @@ sub fill_packs_from_git() {
                 open (REV, "> $cache_path/$pkg_name-$pkg_version-$pkg_release");
             }
             foreach my $old_rev(@lines) {
-                chomp($old_rev);
                 if ( $current_rev eq $old_rev ) {
                     $skip = 1;
                 }
@@ -278,7 +286,14 @@ sub fill_packs_from_git() {
         debug("not a git repo: $base/.git!!");
     }
     if ($skip == 1) {
-        push(@packs, "$pkg_path/$pkg_name-$pkg_version-$pkg_release/$spec_file");
+        if ( $old_base ne "" ) {
+            $old_base = basename($old_base);
+            #print "yyy $old_base\n";
+            print "xxx $pkg_path/$old_base/$spec_file\n";
+            push(@packs, "$pkg_path/$old_base/$spec_file");
+        } else {
+            push(@packs, "$pkg_path/$pkg_name-$pkg_version-$pkg_release/$spec_file");
+        }
     } else {
         if ( system("gbs export  $base -o $pkg_path") == 0 ) {
             push(@packs, "$pkg_path/$pkg_name-$pkg_version-$pkg_release/$spec_file");