chiark / gitweb /
Dgit.pm: Move upstream_commitish_search from git-debrebase
[dgit.git] / Debian / Dgit.pm
index 455cb10189ebdd57588cd20071bc1909cc771341..892ebf9b1cb021e9ffcdbe52afc1e6c0315dece9 100644 (file)
@@ -45,7 +45,7 @@ BEGIN {
                      dep14_version_mangle
                       debiantags debiantag_new
                      debiantag_maintview
-                     upstreamversion
+                     upstreamversion upstream_commitish_search
                      stripepoch source_file_leafname is_orig_file_of_p_v
                      server_branch server_ref
                       stat_exists link_ltarget rename_link_xf
@@ -617,6 +617,17 @@ sub git_check_unmodified () {
     }
 }
 
+sub upstream_commitish_search ($$) {
+    my ($upstream_version, $tried) = @_;
+    # todo: at some point maybe use git-deborig to do this
+    foreach my $tagpfx ('', 'v', 'upstream/') {
+       my $tag = $tagpfx.(dep14_version_mangle $upstream_version);
+       my $new_upstream = git_get_ref "refs/tags/$tag";
+       push @$tried, $tag;
+       return $new_upstream if length $new_upstream;
+    }
+}
+
 sub is_fast_fwd ($$) {
     my ($ancestor,$child) = @_;
     my @cmd = (qw(git merge-base), $ancestor, $child);