diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/bin/gbp-builder-mock git-buildpackage-0.8.12.2ubuntu0~ppa1/bin/gbp-builder-mock --- git-buildpackage-0.7.5ubuntu0~ppa1/bin/gbp-builder-mock 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/bin/gbp-builder-mock 2017-02-11 19:33:12.000000000 +0000 @@ -38,7 +38,7 @@ while [ $# != 0 ]; do case "$1" in - --help|-h|-?) usage 0;; + --help|-h|-\?) usage 0;; *.spec) SPEC="$1";; esac shift diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/bin/git-pbuilder git-buildpackage-0.8.12.2ubuntu0~ppa1/bin/git-pbuilder --- git-buildpackage-0.7.5ubuntu0~ppa1/bin/git-pbuilder 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/bin/git-pbuilder 2017-02-11 19:33:12.000000000 +0000 @@ -1,12 +1,12 @@ #!/bin/bash -# $Id: git-pbuilder,v 1.40 2016/01/23 23:59:19 eagle Exp $ +# $Id: git-pbuilder,v 1.43 2016/12/10 18:54:05 eagle Exp $ # -# git-pbuilder -- Wrapper around pbuilder for gbp buildpackage +# Wrapper around pbuilder for gbp buildpackage # # Note that this script requires bash, not a POSIX shell, because it uses bash -# arrays to handle GIT_PBUILDER_OPTIONS. It's otherwise quite difficult to -# get the contents of that environment variable to undergo the correct amount -# of shell expansion. +# arrays to handle GIT_PBUILDER_OPTIONS and GIT_PBUILDER_PDEBUILDOPTIONS. +# It's otherwise quite difficult to get the contents of that environment +# variable to undergo the correct amount of shell expansion. # # Written by Russ Allbery # Based on the example in the git-buildpackage documentation @@ -78,7 +78,7 @@ # -backports. Backports was incorporated into the main mirrors as of # wheezy. case $DIST in - squeeze|oldstable) + squeeze) BACKPORTS='http://backports.debian.org/debian-backports' ;; *) @@ -104,8 +104,10 @@ fi # Default options come from the environment. Use eval to parse -# GIT_PBUILDER_OPTIONS into an array since some arguments may have quoting. +# GIT_PBUILDER_OPTIONS and GIT_PBUILDER_PDEBUILDOPTIONS into arrays, since +# some arguments may have quoting. eval "OPTIONS=( $GIT_PBUILDER_OPTIONS )" +eval "PDEBUILDOPTS=( $GIT_PBUILDER_PDEBUILDOPTIONS )" OUTPUT_DIR="${GIT_PBUILDER_OUTPUT_DIR:-../}" # How we handle options depends on what type of builder we're using. Ignore @@ -265,22 +267,27 @@ # Run the builder. if [ no = "$GIT_PBUILDER_AUTOCONF" ] ; then + set -x sudo "$BUILDER" "$action" "${OPTIONS[@]}" "$@" else if [ "$EXT" = '-backports' ] ; then OTHERMIRROR="deb $BACKPORTS $DIST$EXT main" + set -x sudo "$BUILDER" "$action" --distribution "$DIST" \ --othermirror "$OTHERMIRROR" "${OPTIONS[@]}" "$@" elif [ "$EXT" = '-lts' ] ; then OTHERMIRROR="deb $LTS $DIST$EXT main" + set -x sudo "$BUILDER" "$action" --distribution "$DIST" \ --othermirror "$OTHERMIRROR" "${OPTIONS[@]}" "$@" else + set -x sudo "$BUILDER" "$action" --distribution "$DIST" \ "${OPTIONS[@]}" "$@" fi fi - exit $? + { set +x; } 2>/dev/null + exit 0 fi # Build package: not (update | create | login) @@ -313,28 +320,24 @@ # Add all of the additional arguments we got on the command line, but quote # them from the shell since they'll undergo another round of shell expansion # when the pbuilder runs debbuild. -source_only=false for arg in "$@" ; do - if [ x'-S' = x"$arg" ] ; then - source_only=true - fi DEBBUILDOPTS+=" $(shell_quote "$arg")" done # Now we can finally run pdebuild. The quoting here is tricky, but this # seems to pass everything through properly. if [ no = "$GIT_PBUILDER_AUTOCONF" ] ; then + set -e; set -x pdebuild --pbuilder "$BUILDER" --debbuildopts "$DEBBUILDOPTS" \ - -- "${OPTIONS[@]}" + "${PDEBUILDOPTS[@]}" -- "${OPTIONS[@]}" + { set +x; } 2>/dev/null; set +e else + set -e; set -x pdebuild --buildresult "$OUTPUT_DIR" --pbuilder "$BUILDER" \ - --debbuildopts "$DEBBUILDOPTS" -- "${OPTIONS[@]}" -fi -status="$?" -if [ -n "`ls ../*_source.changes`" ] && [ true != "$source_only" ] ; then - rm ../*_source.changes + --debbuildopts "$DEBBUILDOPTS" "${PDEBUILDOPTS[@]}" -- "${OPTIONS[@]}" + { set +x; } 2>/dev/null; set +e fi -exit "$status" +exit 0 # Documentation. Use a hack to hide this from the shell. Because of the # above exit line, this should never be executed. @@ -429,9 +432,8 @@ deb http://backports.debian.org/debian-backports $DIST main The first will be used for most distributions, and the second for -C or C. If the distribution ends in -C<-lts>, the following will be added as an B<--othermirror> parameter to the -builder: +C. If the distribution ends in C<-lts>, the following will +be added as an B<--othermirror> parameter to the builder: deb http://ftp.debian.org/debian $DIST main @@ -499,6 +501,13 @@ directory). This setting is ignored if GIT_PBUILDER_AUTOCONF is set to C. +=item GIT_PBUILDER_PDEBUILDOPTIONS + +Add additional options for B itself (such as +B<--use-pdebuild-internal>). The contents of this variable will undergo +shell expansion, so any arguments containing shell metacharacters or +whitespace need to be quoted in the value of the environment variable. + =item PBUILDER_BASE Set this environment variable to change the default location for the diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/.coverage git-buildpackage-0.8.12.2ubuntu0~ppa1/.coverage --- git-buildpackage-0.7.5ubuntu0~ppa1/.coverage 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/.coverage 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1 @@ +!coverage.py: This is a private format, don't read it directly!{"lines": {"/var/scratch/src/git-buildpackage/git-buildpackage/gbp/rpm/policy.py": [1, 171, 132, 133, 135, 151, 17, 19, 148, 21, 22, 153, 25, 26, 175, 29, 31, 33, 35, 38, 39, 40, 169, 170, 43, 178, 46, 47, 48, 200, 50, 52, 181, 182, 183, 184, 186, 189, 191, 194, 147, 71, 72, 73, 74, 76, 77, 81, 82, 83, 84, 85, 88, 89, 90, 92, 93, 96, 98, 100, 102, 168, 115, 116, 117, 118, 119, 120, 121, 122, 149], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/commit.py": [1, 45, 17, 19, 22, 23, 24, 26], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/common/hook.py": [32, 33, 17, 19, 22, 23, 24, 25, 26, 28, 31], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/errors.py": [17, 20, 21, 22], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/__init__.py": [17], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/__init__.py": [17], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/import_dsc.py": [512, 1, 516, 513, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 43, 44, 47, 70, 72, 73, 74, 76, 77, 78, 80, 81, 82, 88, 91, 94, 96, 97, 100, 104, 105, 106, 109, 112, 116, 117, 120, 122, 125, 130, 131, 133, 134, 138, 139, 140, 141, 143, 146, 148, 149, 151, 154, 157, 158, 159, 161, 162, 163, 165, 166, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 190, 193, 194, 199, 200, 201, 202, 203, 204, 206, 207, 208, 212, 220, 227, 228, 229, 230, 231, 232, 233, 235, 236, 237, 238, 239, 240, 241, 242, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 282, 283, 284, 285, 286, 287, 288, 291, 292, 293, 294, 296, 297, 299, 302, 305, 318, 319, 320, 321, 322, 323, 324, 327, 328, 329, 330, 332, 333, 334, 335, 336, 337, 342, 344, 345, 348, 349, 350, 352, 353, 354, 355, 356, 357, 358, 359, 362, 363, 364, 365, 366, 368, 369, 370, 372, 373, 374, 375, 377, 378, 381, 383, 384, 386, 391, 393, 394, 396, 397, 399, 400, 401, 402, 404, 405, 406, 407, 408, 410, 413, 414, 415, 416, 417, 418, 420, 421, 422, 424, 432, 433, 434, 435, 437, 438, 439, 440, 441, 442, 448, 449, 450, 451, 452, 453, 454, 456, 457, 459, 460, 461, 462, 463, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 483, 485, 486, 487, 488, 489, 490, 493, 495, 498, 499, 500, 501, 505, 507, 508, 509, 511], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/policy.py": [64, 65, 91, 37, 1, 44, 93, 47, 56, 90, 21, 89, 23, 24, 88, 26, 59, 92, 29, 62], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/git.py": [1, 17, 19, 20, 21, 22, 24, 27, 28, 30, 35, 36, 37, 39, 44, 45, 47, 48, 49, 50, 51, 53, 57, 58, 59, 60, 63, 81, 82, 83, 85, 86, 96, 99, 100, 116, 117, 118, 120, 123, 124, 125, 127, 135, 136, 137, 138, 140, 164, 165, 166, 168, 176, 177, 178, 179, 180, 182, 184, 189, 190, 191, 193, 195, 200, 201, 202, 203, 205, 207, 226, 227, 229, 240, 242, 256, 257, 258, 259, 260, 261, 262, 264, 270, 272, 280, 282, 292, 293, 295, 296, 297, 299, 300, 301], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/pq_rpm.py": [19, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 46, 49, 51, 52, 53, 54, 57, 60, 64, 65, 66, 67, 68, 71, 72, 73, 78, 80, 82, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 111, 114, 121, 124, 130, 131, 132, 133, 134, 135, 138, 141, 146, 148, 149, 150, 151, 152, 155, 162, 163, 164, 165, 167, 169, 170, 171, 173, 174, 175, 176, 177, 178, 179, 180, 181, 184, 186, 187, 188, 189, 190, 191, 192, 195, 197, 198, 199, 200, 201, 202, 204, 205, 206, 207, 209, 211, 214, 223, 224, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 240, 241, 243, 244, 245, 246, 248, 249, 251, 254, 256, 257, 258, 259, 260, 261, 264, 272, 274, 275, 276, 277, 278, 280, 281, 283, 284, 285, 286, 287, 288, 291, 292, 293, 294, 295, 296, 298, 304, 305, 306, 307, 308, 309, 310, 311, 313, 314, 315, 317, 319, 320, 321, 322, 323, 324, 325, 326, 327, 329, 330, 333, 335, 336, 337, 338, 340, 341, 342, 344, 345, 348, 360, 363, 365, 366, 367, 369, 370, 371, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 393, 395, 396, 397, 398, 401, 403, 405, 406, 407, 409, 411, 412, 413, 415, 417, 418, 419, 420, 421, 422, 424, 426, 427, 429, 430, 431, 432, 433, 435, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 455, 457, 460, 461, 462, 463, 465, 467, 470], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/rpm_ch.py": [19, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 41, 44, 46, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 60, 62, 63, 66, 67, 68, 70, 72, 73, 74, 76, 77, 79, 82, 85, 88, 91, 92, 93, 94, 95, 96, 97, 101, 102, 105, 109, 110, 111, 112, 113, 116, 117, 118, 119, 124, 126, 127, 130, 131, 132, 133, 137, 139, 140, 141, 143, 144, 145, 146, 149, 151, 152, 155, 156, 157, 158, 159, 160, 161, 163, 165, 167, 170, 173, 175, 178, 179, 180, 181, 184, 185, 186, 187, 188, 189, 190, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 210, 211, 214, 215, 216, 217, 218, 219, 220, 223, 225, 226, 228, 229, 231, 232, 233, 235, 236, 239, 241, 243, 244, 245, 246, 248, 249, 252, 253, 255, 256, 257, 261, 264, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 278, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 295, 296, 297, 300, 301, 302, 305, 306, 309, 311, 312, 313, 314, 315, 316, 318, 319, 320, 321, 322, 323, 324, 325, 326, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 349, 350, 351, 352, 353, 354, 355, 356, 357, 359, 360, 362, 363, 364, 365, 366, 367, 368, 369, 371, 372, 373, 374, 376, 377, 378, 379, 380, 381, 382, 385, 387, 388, 389, 391, 393, 394, 396, 398, 401, 403, 404, 405, 407, 408, 410, 411, 413, 414, 417, 420, 421, 424, 425, 426, 427, 428, 429, 430, 433, 434, 435, 438, 440, 441, 443, 444, 445, 446, 448, 450, 453], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/upstreamsource.py": [18, 20, 21, 22, 24, 25, 26, 29, 30, 31, 32, 33, 34, 37, 42, 43, 44, 45, 46, 47, 49, 50, 52, 54, 55, 56], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/log.py": [18, 20, 21, 22, 23, 24, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 41, 43, 44, 45, 48, 49, 51, 52, 54, 55, 56, 57, 58, 59, 61, 63, 65, 67, 68, 70, 74, 76, 78, 79, 81, 82, 84, 86, 87, 90, 91, 94, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 107, 109, 110, 112, 114, 115, 117, 123, 125, 128, 130, 133, 135, 138, 140, 143, 145, 146, 147, 149, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 165, 167, 168, 169, 170, 172, 176, 178], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/version.py": [1, 2], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/pull.py": [128, 129, 130, 171, 132, 134, 135, 44, 140, 141, 142, 143, 152, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 160, 176, 34, 165, 166, 167, 168, 156, 43, 154, 46, 48, 52, 54, 153, 56, 159, 190, 187, 55, 78, 79, 80, 81, 82, 83, 84, 41, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 106, 107, 108, 109, 110, 111, 114, 117, 118, 119, 120, 122, 123, 124, 126], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/notifications.py": [18, 20, 23, 26, 28, 29, 30, 31, 35, 38, 39, 40, 41, 43, 46, 47, 48, 49, 50, 54, 57, 63, 66, 67, 70], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/common/pq.py": [1, 19, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 35, 38, 47, 50, 58, 59, 62, 70, 71, 74, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 104, 105, 109, 110, 112, 113, 114, 117, 121, 128, 130, 133, 135, 138, 139, 140, 141, 142, 143, 146, 147, 149, 151, 152, 153, 154, 155, 156, 157, 158, 160, 162, 163, 164, 167, 170, 171, 174, 177, 180, 181, 182, 186, 187, 188, 190, 192, 200, 201, 204, 207, 208, 210, 211, 212, 214, 215, 217, 218, 219, 220, 221, 224, 227, 228, 229, 230, 231, 232, 233, 234, 237, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 251, 252, 253, 254, 255, 256, 260, 262, 264, 265, 266, 268, 269, 270, 271, 272, 274, 277, 282, 283, 285, 286, 287, 288, 293, 294, 297, 298, 299, 300, 303, 305, 306, 307, 309, 310, 311, 312, 313, 314, 315, 317, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 334, 335, 336, 337, 339, 341, 342, 343, 348, 350, 351, 352, 353, 355], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/tmpfile.py": [18, 20, 21, 22, 24, 27, 30, 32, 33, 34, 35, 36, 38, 42, 43, 44, 47, 49, 50, 51, 52, 53], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/uscan.py": [128, 1, 130, 132, 161, 17, 19, 20, 21, 24, 25, 28, 29, 31, 32, 33, 34, 163, 36, 165, 38, 167, 40, 169, 42, 171, 44, 173, 62, 63, 66, 68, 69, 70, 71, 72, 84, 86, 87, 88, 164, 90, 91, 92, 94, 166, 105, 106, 107, 108, 110, 170, 127], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/pristinetar.py": [64, 65, 66, 38, 39, 41, 43, 45, 47, 17, 19, 20, 21, 24, 25, 26, 61, 62, 63], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/pkg/pristinetar.py": [17, 19, 20, 21, 24, 25, 26, 27, 29, 30, 31, 33, 40, 42, 49, 50, 52, 53, 54, 55, 56, 57, 58, 60, 67, 68, 70, 80, 81, 82, 84, 87, 88], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/control.py": [17, 19, 20, 23, 24, 25, 28, 29, 30, 33, 34, 36, 47, 48, 50, 51, 56, 57, 59, 60, 62, 63, 65, 68, 71, 73, 76, 78, 81], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/dscfile.py": [17, 19, 20, 22, 23, 24, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 102, 103, 104, 107, 109, 111, 113, 115, 116, 117, 118, 120, 121, 123, 124, 126, 128, 131, 133, 134, 137], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/dch.py": [128, 132, 133, 134, 137, 138, 140, 141, 17, 19, 21, 24, 29, 30, 31, 32, 36, 37, 40, 43, 47, 50, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70, 73, 76, 77, 78, 79, 80, 81, 83, 84, 87, 91, 94, 95, 103, 108, 109, 110, 111, 113, 115, 118, 119, 120, 121, 122, 123, 125], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/repository.py": [2048, 1, 2051, 2052, 2053, 2054, 2056, 2057, 17, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 33, 34, 35, 38, 39, 40, 41, 42, 43, 46, 48, 51, 54, 56, 59, 61, 64, 67, 78, 80, 82, 83, 84, 87, 89, 90, 91, 92, 95, 96, 97, 99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 118, 126, 127, 128, 129, 131, 134, 135, 136, 137, 138, 140, 157, 159, 160, 162, 163, 164, 165, 166, 167, 168, 169, 171, 172, 191, 192, 193, 195, 196, 200, 201, 202, 203, 205, 206, 207, 208, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 221, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 244, 255, 256, 257, 258, 259, 260, 261, 262, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 283, 284, 285, 286, 288, 291, 293, 296, 298, 301, 303, 306, 308, 311, 312, 313, 314, 316, 319, 322, 329, 330, 332, 342, 343, 344, 345, 347, 356, 357, 359, 360, 361, 363, 364, 366, 368, 377, 378, 379, 382, 383, 386, 387, 388, 389, 390, 391, 393, 403, 404, 406, 407, 408, 409, 410, 411, 413, 420, 421, 423, 424, 425, 427, 429, 436, 437, 438, 439, 440, 441, 442, 444, 455, 456, 457, 458, 459, 460, 461, 462, 463, 465, 467, 478, 479, 480, 481, 485, 486, 488, 494, 502, 503, 504, 505, 506, 507, 509, 510, 512, 513, 514, 515, 516, 518, 520, 521, 522, 523, 525, 534, 535, 536, 537, 539, 546, 548, 555, 557, 571, 572, 573, 574, 575, 577, 588, 589, 590, 591, 593, 594, 596, 597, 598, 599, 601, 612, 613, 614, 616, 617, 621, 622, 623, 624, 625, 630, 640, 641, 642, 644, 646, 648, 652, 668, 669, 670, 673, 674, 675, 677, 684, 685, 687, 688, 689, 691, 700, 701, 703, 704, 726, 727, 728, 731, 733, 734, 735, 736, 737, 738, 740, 741, 742, 743, 744, 745, 746, 748, 759, 761, 773, 774, 776, 785, 786, 788, 797, 799, 800, 801, 802, 806, 814, 815, 817, 818, 819, 821, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 840, 842, 844, 857, 858, 860, 861, 862, 863, 865, 866, 867, 868, 870, 872, 883, 884, 885, 886, 888, 889, 890, 893, 902, 903, 904, 905, 907, 908, 909, 912, 913, 915, 916, 917, 918, 920, 921, 922, 924, 926, 935, 937, 948, 949, 950, 951, 952, 953, 954, 956, 957, 977, 978, 980, 982, 983, 984, 985, 988, 995, 997, 1006, 1007, 1008, 1010, 1019, 1020, 1022, 1024, 1025, 1026, 1027, 1028, 1029, 1031, 1038, 1039, 1041, 1042, 1044, 1045, 1046, 1047, 1048, 1050, 1052, 1061, 1062, 1064, 1066, 1078, 1079, 1080, 1081, 1082, 1084, 1085, 1088, 1089, 1090, 1091, 1092, 1096, 1104, 1105, 1106, 1107, 1109, 1115, 1116, 1118, 1124, 1125, 1127, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1149, 1156, 1157, 1158, 1159, 1163, 1164, 1165, 1166, 1167, 1168, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1182, 1184, 1193, 1194, 1196, 1205, 1206, 1208, 1210, 1223, 1224, 1225, 1226, 1227, 1229, 1230, 1231, 1233, 1234, 1249, 1250, 1251, 1252, 1253, 1255, 1256, 1258, 1260, 1271, 1272, 1273, 1274, 1276, 1277, 1279, 1280, 1300, 1301, 1302, 1303, 1304, 1307, 1308, 1309, 1311, 1313, 1315, 1317, 1328, 1329, 1330, 1334, 1345, 1347, 1348, 1350, 1352, 1353, 1355, 1356, 1358, 1360, 1375, 1384, 1385, 1386, 1388, 1389, 1390, 1392, 1393, 1394, 1396, 1397, 1399, 1401, 1412, 1413, 1414, 1416, 1417, 1418, 1419, 1420, 1427, 1428, 1429, 1431, 1442, 1443, 1444, 1446, 1454, 1455, 1456, 1458, 1469, 1470, 1471, 1473, 1474, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1515, 1516, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1528, 1529, 1530, 1532, 1533, 1534, 1536, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1567, 1571, 1572, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1603, 1604, 1608, 1610, 1612, 1613, 1614, 1615, 1616, 1618, 1627, 1628, 1629, 1630, 1631, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1641, 1643, 1653, 1655, 1664, 1665, 1666, 1667, 1668, 1669, 1673, 1675, 1676, 1677, 1678, 1679, 1680, 1682, 1683, 1685, 1686, 1687, 1688, 1689, 1690, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1702, 1703, 1704, 1718, 1719, 1720, 1721, 1722, 1724, 1725, 1727, 1729, 1730, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1741, 1742, 1763, 1764, 1765, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1783, 1785, 1796, 1797, 1799, 1800, 1802, 1803, 1804, 1806, 1808, 1810, 1813, 1828, 1829, 1830, 1831, 1832, 1833, 1836, 1843, 1844, 1845, 1847, 1848, 1849, 1850, 1855, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1873, 1880, 1882, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1904, 1906, 1916, 1917, 1918, 1920, 1921, 1922, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1947, 1948, 1959, 1960, 1962, 1963, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1977, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1990, 1991, 1992, 2016, 2017, 2018, 2020, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2043, 2044, 2046, 2047], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/errors.py": [17, 20, 21, 22], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/config.py": [129, 133, 135, 136, 139, 18, 20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 49, 52, 56, 59, 60, 61, 64, 65, 66, 69, 70, 71, 72, 74, 75, 78, 79, 80, 81, 82, 83, 84, 87, 95, 98, 99, 100, 101, 102, 104, 106, 107, 109, 112, 113, 116, 117, 119, 121, 122, 124, 126], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/common/import_orig.py": [129, 131, 132, 133, 134, 140, 143, 19, 20, 21, 22, 23, 24, 26, 27, 32, 33, 38, 50, 51, 52, 57, 60, 62, 63, 68, 70, 71, 73, 76, 95, 114, 115, 118, 119, 120, 126], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/source.py": [17, 19, 20, 21, 23, 26, 27, 34, 36, 37, 38, 41, 42, 45, 51, 52, 57, 59, 60, 62, 64, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 81, 86, 87, 88, 89, 90, 91, 92, 94, 99], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/import_srpm.py": [18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 34, 35, 36, 38, 39, 40, 41, 42, 47, 50, 51, 52, 55, 57, 58, 59, 60, 61, 62, 63, 64, 67, 70, 72, 73, 77, 78, 79, 84, 85, 86, 89, 91, 92, 93, 94, 95, 98, 100, 101, 102, 103, 106, 108, 113, 115, 117, 119, 122, 124, 125, 126, 127, 129, 130, 131, 133, 134, 135, 136, 137, 138, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 169, 170, 171, 172, 173, 174, 175, 176, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 191, 192, 193, 194, 195, 198, 200, 201, 202, 204, 205, 207, 210, 211, 214, 216, 218, 219, 221, 222, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 239, 240, 241, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 256, 259, 260, 261, 262, 264, 265, 266, 267, 270, 271, 272, 274, 275, 276, 278, 280, 281, 282, 283, 284, 285, 286, 288, 289, 292, 293, 294, 295, 296, 297, 298, 299, 302, 304, 307, 308, 309, 310, 311, 313, 314, 316, 317, 318, 319, 321, 322, 325, 326, 327, 328, 330, 332, 333, 334, 335, 336, 337, 339, 340, 341, 342, 344, 346, 347, 348, 349, 350, 351, 353, 355, 356, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 372, 373, 374, 375, 377, 378, 379, 380, 381, 382, 384, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 401, 402, 403, 404, 405, 406, 407, 409, 410, 412, 416, 417, 418, 419, 420, 421, 423, 426, 428, 429, 431, 432, 433, 434, 435, 436, 437, 440, 441, 442, 443, 444, 445, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 459, 462, 463, 464, 465, 466, 468, 470, 473, 475, 478, 479, 480, 481, 482, 483, 484, 485, 486, 488, 489, 491, 492, 493, 496], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/common/__init__.py": [1, 38, 39, 40, 17, 19, 22, 23, 24, 25, 26, 29], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/import_orig.py": [1, 515, 598, 518, 513, 599, 524, 614, 527, 528, 600, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 551, 40, 553, 43, 556, 557, 46, 47, 560, 561, 52, 565, 121, 56, 570, 571, 60, 61, 62, 63, 64, 577, 66, 67, 580, 69, 582, 583, 584, 585, 74, 241, 76, 589, 590, 591, 592, 593, 594, 84, 86, 87, 88, 601, 71, 91, 92, 605, 606, 607, 608, 97, 99, 100, 101, 102, 615, 104, 617, 106, 619, 108, 109, 622, 111, 624, 625, 114, 627, 629, 120, 532, 122, 635, 124, 618, 638, 639, 641, 642, 643, 132, 534, 646, 620, 535, 140, 385, 144, 536, 146, 147, 148, 150, 537, 152, 153, 155, 156, 157, 158, 159, 161, 162, 539, 602, 540, 172, 626, 541, 543, 189, 190, 193, 194, 586, 197, 199, 200, 201, 202, 203, 204, 546, 206, 207, 210, 547, 212, 215, 216, 548, 219, 222, 549, 604, 225, 226, 227, 228, 229, 519, 205, 235, 236, 93, 125, 552, 242, 126, 247, 250, 127, 255, 256, 621, 555, 260, 263, 130, 131, 559, 284, 285, 286, 163, 96, 304, 305, 306, 307, 309, 312, 564, 314, 317, 318, 319, 320, 123, 324, 325, 327, 328, 329, 330, 331, 332, 334, 335, 336, 339, 609, 313, 574, 145, 572, 364, 573, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 575, 380, 383, 384, 576, 386, 387, 388, 391, 623, 394, 151, 578, 233, 404, 405, 406, 407, 408, 409, 410, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 458, 459, 460, 461, 462, 465, 466, 467, 468, 469, 470, 471, 164, 474, 479, 480, 481, 483, 484, 486, 489, 492, 493, 613, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 508, 509], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/command_wrappers.py": [1, 2, 20, 22, 23, 24, 25, 26, 27, 29, 32, 33, 34, 37, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 66, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 91, 92, 93, 95, 100, 104, 105, 106, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 127, 128, 130, 131, 132, 134, 136, 138, 144, 145, 146, 147, 148, 149, 150, 152, 177, 178, 179, 180, 181, 182, 183, 184, 186, 222, 223, 224, 225, 226, 228, 230, 233, 234, 235, 236, 237, 238, 239, 241, 244, 245, 246, 247, 248, 249, 251, 252, 254, 255, 256, 259, 260, 261, 262, 263, 264, 266, 267, 269, 270, 271, 274, 275, 276, 277, 278, 280, 281, 284, 285, 286, 287, 288, 289, 292, 293, 294, 302, 306, 307, 310, 315, 316, 317, 318, 319, 321, 322, 325, 326, 327, 328, 329, 331, 332, 333, 334, 337, 338, 339, 340, 341], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/__init__.py": [32, 1, 42, 43, 44, 45, 17, 19, 20, 22, 23, 24, 25, 27, 28, 29], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/config.py": [1, 17, 19, 20, 21, 22, 23, 24, 26, 28, 29, 32, 33, 34, 40, 43, 44, 45, 48, 49, 50, 55, 58, 60, 61, 62, 63, 64, 68, 69, 72, 74, 75, 76, 77, 80, 81, 82, 83, 84, 87, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 187, 189, 192, 194, 197, 200, 203, 206, 209, 211, 213, 216, 219, 222, 225, 227, 229, 231, 233, 235, 237, 239, 241, 244, 247, 250, 252, 255, 258, 261, 264, 267, 269, 271, 276, 279, 282, 285, 289, 292, 295, 298, 301, 304, 307, 310, 313, 316, 318, 322, 325, 328, 331, 334, 337, 341, 343, 346, 348, 350, 352, 355, 357, 361, 366, 367, 370, 371, 372, 373, 374, 376, 378, 379, 407, 408, 409, 410, 411, 412, 414, 416, 417, 418, 419, 420, 421, 422, 423, 425, 426, 427, 428, 429, 430, 432, 433, 434, 435, 437, 444, 447, 449, 464, 465, 466, 467, 468, 469, 471, 473, 475, 482, 483, 484, 485, 486, 487, 489, 493, 498, 500, 501, 502, 503, 504, 505, 507, 508, 511, 515, 516, 517, 518, 519, 520, 521, 523, 524, 525, 526, 527, 528, 531, 534, 536, 543, 545, 557, 558, 559, 560, 561, 562, 563, 565, 566, 567, 568, 570, 571, 572, 573, 575, 577, 578, 579, 580, 581, 582, 583, 585, 590, 591, 592, 594, 595, 597, 598, 599, 600, 602, 603, 604, 605, 608, 610, 612, 613, 615, 616, 618, 619, 620, 621, 622, 623, 624, 626, 627, 637, 638, 639, 640, 641, 642, 644, 645, 646, 647, 649, 658, 660, 665, 666, 667, 668, 669, 674, 687, 688, 689, 691, 693, 694, 700, 702, 706, 707, 708, 709, 710, 711, 712, 715, 716, 717, 727, 728, 729, 730, 731, 732, 734, 735, 736, 737, 740, 743, 744, 745, 746, 749, 754, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 783, 784, 785, 787, 790, 792, 796, 799, 802, 805, 808, 812, 815, 818, 821, 824, 827, 830, 832, 834, 838, 840, 844, 847], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/create_remote_repo.py": [1, 19, 21, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 40, 43, 61, 63, 65, 66, 68, 69, 71, 74, 79, 80, 81, 83, 85, 86, 88, 89, 90, 91, 93, 94, 96, 97, 98, 99, 100, 101, 103, 104, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 119, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 154, 163, 164, 165, 166, 167, 168, 169, 170, 173, 194, 201, 207, 212, 215, 216, 217, 218, 219, 220, 221, 222, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 261, 268, 271, 272, 276, 277, 278, 280, 283, 361, 362, 363, 364, 365, 366, 369, 380, 381, 383, 384, 385, 405], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/rpm/linkedlist.py": [129, 213, 214, 1, 141, 142, 144, 17, 146, 19, 21, 24, 25, 27, 28, 29, 30, 159, 32, 33, 162, 35, 165, 38, 39, 40, 41, 43, 157, 176, 177, 178, 180, 181, 182, 184, 57, 163, 59, 60, 62, 58, 64, 65, 66, 67, 68, 71, 72, 210, 74, 75, 77, 78, 79, 80, 209, 82, 83, 212, 85, 86, 89, 90, 92, 93, 94, 96, 97, 99, 100, 101, 102, 104, 161, 107, 208, 109, 211, 158, 123, 124, 126, 127], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/format.py": [1, 2, 17, 20, 21, 24, 44, 45, 47, 48, 50, 51, 52, 53, 55, 56, 58, 59, 60, 61, 63, 66, 68, 71, 73, 76, 97, 98, 100, 101, 111, 112, 113, 114, 117], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/pq.py": [1, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 39, 40, 42, 43, 46, 49, 50, 51, 52, 54, 55, 56, 62, 63, 64, 67, 71, 72, 73, 74, 78, 79, 80, 82, 83, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 108, 111, 120, 121, 122, 125, 132, 134, 135, 136, 137, 142, 143, 144, 145, 146, 147, 150, 154, 155, 156, 158, 159, 160, 162, 164, 165, 168, 169, 171, 172, 173, 174, 177, 181, 182, 183, 184, 187, 190, 193, 196, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 213, 215, 216, 218, 220, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 237, 239, 240, 243, 266, 283, 284, 286, 295, 297, 304, 305, 306, 308, 312, 313, 316, 318, 319, 320, 322, 323, 324, 328, 329, 342, 347, 351, 354, 356, 357, 359, 360, 362, 363, 365, 367, 370, 381, 384, 385, 386, 387, 388, 389, 390, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 413, 414, 415, 416, 417, 420, 421, 423, 424, 425, 427, 429, 433, 435, 436, 447, 448, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 486, 489], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/format.py": [1, 38, 39, 40, 41, 42, 43, 44, 17, 19, 22], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/__init__.py": [1, 17, 19, 20, 22, 23, 24, 27, 28, 31, 32, 34, 35, 37, 39, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 60, 61, 62, 65, 72, 77, 78, 79, 84, 95, 96, 97, 98, 101, 102, 103, 104, 107, 109, 112], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/rpm/changelog.py": [17, 19, 20, 21, 23, 25, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 41, 42, 43, 46, 47, 49, 50, 51, 52, 54, 55, 57, 58, 59, 60, 62, 64, 65, 66, 67, 68, 69, 70, 71, 74, 75, 77, 86, 87, 88, 89, 91, 93, 94, 96, 98, 99, 100, 101, 104, 105, 107, 108, 109, 110, 111, 113, 114, 115, 116, 118, 119, 121, 123, 125, 127, 128, 131, 132, 134, 135, 136, 138, 139, 140, 141, 142, 144, 146, 148, 150, 151, 152, 155, 156, 158, 159, 160, 161, 162, 163, 164, 166, 168, 169, 170, 171, 172, 173, 174, 175, 176, 178, 179, 180, 181, 183, 185, 186, 187, 191, 195, 196, 197, 198, 199, 200, 201, 202, 203, 206, 207, 208, 209, 210, 211, 212, 214, 216, 218, 220, 221, 222, 223, 224, 225, 226, 227, 228, 230, 231, 232, 233, 235, 239, 240, 241, 243, 245, 248, 249, 250, 251, 253, 254, 256, 257, 258, 259, 261], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/common/repo_setup.py": [18, 20, 23, 24, 25, 26, 28, 29, 30], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/buildpackage_rpm.py": [19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 42, 45, 46, 49, 51, 52, 53, 56, 59, 62, 63, 64, 66, 69, 70, 71, 72, 73, 74, 75, 76, 79, 80, 81, 82, 83, 84, 85, 88, 91, 92, 93, 94, 95, 96, 97, 98, 100, 101, 105, 106, 107, 108, 109, 110, 111, 112, 113, 115, 116, 117, 118, 121, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 135, 136, 137, 140, 142, 143, 144, 145, 146, 147, 148, 149, 150, 152, 153, 154, 155, 158, 163, 164, 166, 167, 169, 171, 174, 175, 177, 180, 182, 183, 184, 185, 186, 189, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 225, 227, 228, 229, 231, 232, 233, 234, 235, 236, 237, 239, 242, 244, 245, 247, 248, 249, 250, 253, 255, 258, 259, 261, 262, 263, 264, 267, 282, 284, 286, 287, 288, 289, 290, 293, 295, 296, 297, 298, 301, 303, 304, 305, 306, 307, 308, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 388, 389, 391, 392, 394, 395, 396, 398, 399, 401, 402, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 417, 418, 419, 420, 421, 422, 423, 425, 426, 427, 428, 429, 432, 434, 435, 438, 439, 440, 442, 443, 444, 445, 447, 448, 449, 450, 451, 452, 453, 454, 456, 459, 461, 462, 463, 465, 467, 468, 470, 471, 472, 473, 474, 477, 478, 479, 480, 481, 484, 486, 488, 489, 491, 492, 494, 495, 496, 497, 498, 499, 500, 502, 503, 504, 505, 506, 510, 511, 512, 513, 516, 518, 520, 521, 525, 526, 527, 528, 531, 532, 533, 534, 535, 536, 538, 539, 540, 541, 542, 543, 546, 547, 549, 550, 551, 552, 553, 554, 556, 557, 558, 559, 560, 561, 562, 563, 565, 566, 569, 570, 571, 572, 573, 575, 576, 577, 578, 579, 580, 583, 584, 585, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 629, 630, 632, 633, 634, 635, 636, 637, 638, 639, 640, 642, 645], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/rpm/lib_rpm.py": [34, 35, 36, 37, 40, 17, 19, 21, 22, 24, 26], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/tristate.py": [1, 20, 23, 24, 25, 26, 27, 30, 32, 33, 34, 35, 36, 39, 40, 41, 42, 43, 44, 46, 47, 48, 52, 63, 64, 65, 66, 68, 70, 79, 81, 84, 86, 87, 89, 90, 92, 93, 95, 100, 103, 104, 107], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/dch.py": [1, 516, 517, 518, 513, 520, 522, 524, 528, 18, 531, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 548, 37, 38, 551, 41, 519, 555, 46, 47, 48, 49, 50, 51, 52, 53, 56, 59, 572, 61, 63, 576, 65, 69, 70, 73, 76, 85, 86, 87, 88, 92, 93, 94, 95, 96, 97, 99, 101, 102, 105, 106, 109, 122, 123, 124, 125, 126, 128, 129, 130, 131, 132, 135, 175, 143, 144, 145, 146, 148, 149, 151, 152, 153, 154, 155, 156, 538, 158, 159, 161, 162, 539, 164, 165, 166, 167, 193, 172, 174, 541, 176, 179, 542, 182, 187, 189, 190, 191, 544, 194, 196, 197, 545, 200, 202, 203, 204, 205, 206, 207, 208, 209, 212, 225, 226, 227, 231, 232, 233, 234, 237, 238, 239, 240, 243, 246, 248, 249, 252, 253, 543, 259, 260, 261, 263, 558, 266, 267, 270, 557, 272, 273, 277, 278, 280, 281, 559, 284, 286, 288, 289, 290, 291, 293, 294, 299, 300, 303, 304, 305, 306, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 327, 328, 329, 330, 331, 332, 333, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 354, 355, 356, 357, 358, 360, 361, 362, 363, 365, 366, 573, 368, 369, 371, 372, 373, 374, 375, 376, 377, 379, 380, 381, 383, 384, 385, 386, 387, 388, 389, 391, 64, 394, 395, 396, 397, 400, 401, 402, 403, 405, 406, 407, 408, 409, 412, 413, 414, 415, 416, 417, 418, 420, 422, 423, 425, 426, 427, 428, 429, 433, 434, 440, 163, 444, 445, 447, 450, 451, 452, 453, 454, 457, 458, 460, 461, 464, 466, 467, 468, 470, 472, 473, 546, 488, 489, 491, 492, 494, 496, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/pkg/__init__.py": [1, 18, 20, 21, 22, 24, 26, 27, 30, 31, 32, 33, 36, 37, 40, 43, 44, 45, 46, 49, 77, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 97, 100, 103, 104, 105, 106, 107, 109, 119, 120, 123, 133, 134, 135, 137, 138, 179, 180, 182, 183, 190, 191, 194, 195, 196, 197, 198, 200, 203, 204, 205, 206, 208, 210, 212, 213, 219, 220, 221, 223, 226, 227, 228, 229, 230, 231, 232, 233, 235, 238, 240, 241, 242, 245, 257, 258, 259, 260, 261, 262, 264, 265, 266, 268, 277, 278, 279, 281, 282, 283, 285, 286, 287, 288, 289, 290, 292, 298, 300, 306, 308, 310, 312, 318, 321, 322, 324, 327, 328, 330, 335, 336, 337, 339, 341, 343, 344, 345, 349, 351, 352, 354, 355, 357, 359, 364, 365, 366, 371, 382, 385, 386, 388, 391, 392, 393, 394, 395, 396, 397, 401, 403, 405, 407, 408, 409], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/rpm/git.py": [1, 19, 20, 21, 22, 23, 26, 27, 29, 30, 31, 33, 45, 46, 49, 51, 52, 54, 70, 71, 72, 73, 75, 88, 90, 96, 98, 106], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/supercommand.py": [128, 1, 131, 22, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145, 18, 20, 150, 23, 24, 25, 29, 32, 37, 40, 41, 53, 56, 64, 68, 69, 70, 71, 73, 76, 81, 84, 85, 86, 87, 88, 89, 90, 93, 94, 95, 96, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 123], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/buildpackage.py": [1, 18, 20, 21, 22, 23, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 45, 46, 47, 51, 53, 54, 58, 59, 61, 62, 63, 64, 65, 68, 69, 81, 84, 89, 90, 91, 92, 94, 95, 96, 99, 107, 110, 111, 112, 113, 115, 118, 132, 141, 142, 144, 147, 148, 151, 152, 155, 168, 176, 177, 181, 183, 184, 190, 218, 221, 222, 223, 225, 226, 229, 232, 234, 236, 237, 238, 239, 241, 244, 253, 254, 255, 256, 262, 267, 268, 269, 270, 271, 277, 283, 284, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 308, 311, 317, 318, 320, 321, 322, 323, 326, 328, 329, 331, 332, 333, 334, 335, 336, 338, 339, 340, 341, 344, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 371, 372, 373, 376, 377, 378, 379, 380, 381, 382, 383, 386, 389, 392, 393, 395, 396, 397, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 414, 416, 417, 418, 419, 420, 422, 423, 424, 425, 426, 429, 432, 434, 435, 436, 440, 444, 445, 446, 450, 451, 452, 453, 454, 455, 457, 458, 459, 461, 463, 464, 467, 479, 481, 482, 483, 484, 486, 487, 488, 489, 490, 491, 492, 494, 495, 498, 500, 502, 504, 505, 508, 516, 525, 526, 527, 528, 530, 533, 534, 535, 536, 537, 538, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 599, 600, 602, 603, 605, 606, 608, 609, 611, 612, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 625, 626, 627, 628, 629, 630, 631, 632, 635, 636, 637, 640, 641, 642, 644, 645, 646, 647, 649, 650, 652, 653, 658, 663, 667, 671, 674, 675, 676, 677, 678, 679, 681, 683, 684, 686, 687, 692, 693, 695, 696, 702, 703, 707, 708, 709, 711, 713, 714, 715, 722, 723, 726, 727, 729, 732, 733, 734, 737, 744, 745, 746, 747, 748, 749, 752, 755, 757, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 785, 786, 787, 789, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 804, 805, 806, 807, 808, 809, 810, 826, 828, 829, 830, 832, 833, 834, 835, 839, 842], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/rpm/__init__.py": [1, 18, 20, 21, 22, 23, 24, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 39, 40, 41, 44, 45, 46, 49, 50, 51, 52, 53, 54, 55, 58, 59, 60, 65, 66, 67, 68, 69, 71, 74, 75, 76, 77, 78, 80, 83, 85, 88, 90, 93, 95, 100, 101, 102, 103, 104, 107, 108, 109, 110, 111, 112, 113, 114, 120, 122, 124, 127, 128, 129, 130, 132, 134, 135, 136, 137, 138, 139, 140, 141, 143, 144, 145, 146, 150, 151, 158, 159, 162, 163, 164, 165, 168, 169, 170, 171, 172, 175, 180, 181, 183, 185, 187, 188, 189, 190, 191, 192, 195, 196, 204, 207, 208, 209, 210, 211, 213, 216, 218, 221, 222, 223, 224, 226, 228, 229, 230, 232, 234, 235, 236, 238, 240, 241, 243, 244, 245, 246, 248, 249, 252, 262, 263, 265, 269, 270, 271, 273, 276, 278, 279, 280, 282, 283, 285, 286, 288, 289, 292, 293, 294, 295, 296, 299, 300, 301, 302, 303, 305, 306, 308, 309, 310, 311, 312, 313, 314, 316, 318, 320, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 336, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 354, 357, 358, 359, 360, 362, 364, 365, 366, 367, 368, 369, 370, 372, 375, 376, 377, 378, 379, 380, 382, 385, 386, 387, 388, 389, 390, 391, 392, 393, 395, 396, 397, 398, 400, 402, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 417, 421, 422, 423, 425, 426, 427, 430, 433, 434, 435, 436, 440, 442, 443, 444, 445, 446, 448, 449, 450, 451, 452, 453, 455, 456, 457, 458, 459, 461, 463, 464, 465, 466, 467, 470, 471, 472, 473, 474, 475, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 500, 501, 503, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 518, 520, 522, 523, 525, 526, 527, 528, 529, 530, 531, 532, 534, 535, 536, 537, 538, 540, 542, 543, 544, 545, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 564, 566, 567, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 581, 582, 583, 584, 586, 587, 588, 590, 592, 594, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 607, 610, 611, 612, 614, 615, 616, 618, 619, 620, 623, 624, 625, 627, 628, 629, 630, 631, 635, 636, 637, 639, 643, 644, 645, 646, 649, 650, 652, 659, 660, 661, 662, 663, 665, 666, 670, 671, 673, 681, 682, 684, 685, 686, 687, 688, 689, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 702, 704, 706, 707, 708, 709, 710, 711, 712, 713, 716, 717, 718, 719, 720, 721, 722, 724, 725, 726, 727, 728, 729, 730, 731, 732, 734, 737, 738, 739, 740, 742, 745, 746, 747, 748, 749, 750, 752, 753, 755, 756, 757, 758, 759, 760, 761, 770, 771, 773, 778, 779, 780, 781, 782, 784, 785, 786, 788, 789, 791, 792, 794, 795, 797, 800, 802, 803, 804, 805, 809, 812, 814, 815, 816, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 833, 835, 836, 837, 838, 839, 840, 841, 843, 844, 845, 848, 852, 853, 854, 855, 859, 860, 863, 865, 866, 867, 868, 869, 870, 871, 874, 892, 893, 894, 895, 897, 898, 900, 903, 922, 924, 925, 926, 928, 929, 930, 931, 932, 934, 937, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 969, 985], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/fastimport.py": [129, 131, 135, 136, 137, 138, 140, 18, 20, 21, 22, 25, 26, 27, 29, 30, 31, 33, 38, 39, 40, 41, 42, 49, 50, 51, 52, 53, 54, 55, 56, 58, 59, 60, 61, 63, 76, 78, 87, 88, 89, 91, 102, 103, 104, 105, 107, 110, 112, 115, 116, 117, 118, 119, 120, 121, 122, 125], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/patch_series.py": [1, 2, 3, 17, 19, 20, 21, 22, 23, 26, 39, 40, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 58, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 82, 85, 109, 111, 112, 113, 114, 115, 116, 117, 119, 131, 132, 134, 135, 137, 139, 144, 146, 149, 151, 154, 156, 159, 162, 165, 166, 167, 169, 172, 174, 175, 186, 207, 208, 209, 210, 211, 212, 213, 214, 215, 217, 227, 228, 229, 230, 232, 244, 246, 258, 259, 261, 262, 263, 264, 265, 266, 268, 270, 280, 281, 282, 283], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/modifier.py": [1, 136, 138, 151, 167, 21, 23, 24, 25, 154, 27, 157, 30, 31, 32, 161, 35, 36, 37, 38, 39, 168, 41, 42, 44, 45, 48, 49, 50, 155, 59, 159, 60, 61, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 163, 84, 86, 87, 88, 164, 90, 91, 92, 93, 94, 95, 97, 99, 101, 165, 103, 105, 107, 109, 111, 113, 116, 118, 169, 153, 121, 123, 102, 166], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/vfs.py": [17, 19, 20, 23, 25, 30, 31, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 48, 50, 51, 53, 58, 59, 61, 62, 64, 66, 67, 68, 69, 70], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/common/buildpackage.py": [1, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 34, 37, 48, 49, 50, 54, 63, 64, 65, 66, 67, 69, 70, 73, 74, 76, 77, 78, 79, 80, 81, 82, 85, 88, 89, 92, 93, 94, 95, 98, 100, 103, 109, 110, 111, 112, 113, 116, 117, 118, 119, 120, 124, 126, 127, 128, 129, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 169, 170, 173, 175, 178, 180, 181, 182, 183, 186, 188, 189, 190], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/clone.py": [20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 73, 74, 75, 76, 78, 79, 80, 83, 84, 86, 87, 88, 90, 94, 96, 97, 98, 101, 102, 104, 105, 106, 107, 108, 112, 113, 116, 124, 125, 127, 128, 129, 130, 131, 134, 136, 138, 139, 140, 143, 146, 147, 148, 154, 157], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/import_dscs.py": [129, 133, 137, 138, 140, 141, 142, 143, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 159, 160, 33, 34, 35, 164, 37, 166, 177, 168, 41, 42, 172, 45, 174, 157, 49, 155, 158, 73, 173, 163, 84, 95, 96, 97, 98, 99, 100, 101, 165, 103, 104, 106, 108, 110, 154, 115, 170, 153, 148, 38, 124, 125, 126, 127], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/args.py": [1, 19, 21, 22, 25, 45, 47, 48, 49, 51, 53, 55, 59, 60, 61, 62, 63, 64, 68, 70, 78, 79, 80, 82, 90, 91, 93, 105, 106, 108, 109], "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/deb/changelog.py": [17, 19, 21, 22, 23, 24, 27, 28, 29, 32, 33, 34, 37, 38, 39, 40, 41, 43, 45, 47, 49, 51, 61, 62, 63, 64, 67, 68, 70, 77, 78, 79, 82, 85, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98, 99, 100, 101, 104, 106, 108, 111, 112, 113, 114, 116, 117, 118, 120, 124, 126, 127, 128, 130, 131, 133, 134, 136, 139, 141, 144, 146, 149, 151, 154, 156, 159, 161, 164, 166, 169, 171, 178, 180, 185, 187, 192, 194, 199, 201, 206, 207, 208, 209, 211, 212, 213, 215, 220, 222, 223, 224, 243, 244, 245, 246, 247, 248, 249, 250, 252, 253, 254, 255, 257, 258, 259, 260, 262, 263, 265, 266, 267, 268, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 282, 283, 285, 297, 299, 300, 316, 317, 319, 320]}} \ No newline at end of file diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/coverage.xml git-buildpackage-0.8.12.2ubuntu0~ppa1/coverage.xml --- git-buildpackage-0.7.5ubuntu0~ppa1/coverage.xml 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/coverage.xml 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,8013 @@ + + + + + + /var/scratch/src/git-buildpackage/git-buildpackage/gbp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/changelog git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/changelog --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/changelog 2016-08-07 18:15:10.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/changelog 2017-02-11 19:34:44.000000000 +0000 @@ -1,3 +1,425 @@ +git-buildpackage (0.8.12.2ubuntu0~ppa1) xenial; urgency=medium + + * Backport to Xenial. + + -- Dominik Stadler (Ubuntu key) Sat, 11 Feb 2017 20:34:25 +0100 + +git-buildpackage (0.8.12.2) unstable; urgency=medium + + * [80044e1] GitRepository: shorten reflog message. + Thanks to Chris Lamb for the report (Closes: #854333) + + -- Guido Günther Tue, 07 Feb 2017 07:34:57 +0100 + +git-buildpackage (0.8.12.1) unstable; urgency=medium + + * Upload to unstable + + -- Guido Günther Fri, 27 Jan 2017 14:50:30 +0100 + +git-buildpackage (0.8.12) experimental; urgency=medium + + [ Guido Günther ] + * [5c23d41] GitRepository: properly determine git-dir + instead of assuming '.git' + Heavily based on a patch by Markus Lehtonnen (Closes: #674015) + * [53b5af5] gbp dch: Allow to run from subdirectory + * [390d34a] git-pbuilder: print pdebuild command as executed + to ease debugging things like #852264 + * Test suite improvements + + [ Markus Lehtonen ] + * [f30bb98] buildpackage: fix exporting of working copy when .git is not a directory + as is the case with git submodules lately, for example + + -- Guido Günther Fri, 27 Jan 2017 14:06:33 +0100 + +git-buildpackage (0.8.11) experimental; urgency=medium + + * [8bd74df] command_wrappers: Simplify RunAtCommand + * [1140886] buildpackage: Don't set a compression level if unset and make + this the default. This allows compressors to use the their default + compression level. Only applies when not using pristine-tar. + Thanks to Antoine Beaupré for investigating (Closes: #820846) + * [0fdff8e] buildpackage: Use commit instead of tree to create archive. + This makes sure we use the timestamps of the commit when creating the + tarball. Only applies when not using pristine-tar + Thanks to Ximin Luo for investigating (Closes: #851645) + * [3f4b9f8] make: Check if we can use parallel flake + * [534c055] git-pbuilder: Don't remove changes file (Closes: #850478) + * [b863399] pull: Allow to specify remote on the command line + (Closes: #851844) + * [d3cb4db] gbp-posttag-push: add missing dry-run for debian branch push + * [f9a7640] buildpackage: verify generated tarballs when using pristine-tar + * [b8ea662] pq: Hardcode commit abbrev to 7 when exporting patches. + This avoids path churn with git >= 2.11.0 (Closes: #848354) + * Test suite enhancements + + -- Guido Günther Fri, 20 Jan 2017 12:54:40 +0100 + +git-buildpackage (0.8.10) unstable; urgency=medium + + * [ede603e] GitRepository: properly use pipe on empty strings. + (Closes: #850319) + * [42ee784] buildpackage: print proper dist when using sid. + * [e9ffa80] buildpackage: create all missing dirs with --export + Thanks to Andrea Zagli for the suggestion + * [42878ff] dch: honor --no-git-author + Thanks to David Kalnischkies for investigating (Closes: #796913) + * [4086fc9] import_dsc: Store debian/changelog in commit message + when importing packages. (Closes: #577810) + * [5fb0749] import_orig: Delay unpack of component tarballs. + (Closes: #840602) + * [67d8b9f] Move default gbp.conf back to the right location. + Thanks to Luca Boccassi (Closes: #850937) + * [80a1c39] Quote arguments passed to builder. + Thanks to Simon McVittie for the detailed report (Closes: #850869) + * [4a41d49] import-orig: Move orig.tar.gz with filter-pristine-tar. + (Closes: #558777) + * [661444b] Update docs regarding --download and drop it from completions + * flake8 test suite and example cleanups + * Update test data submodule URLs to https + * Make gbp-posttag-push easier to use + * [bba1ec7] docs: changelog entry is not created after gbp import-orig. + Thanks to Guillaume Millet + + -- Guido Günther Thu, 12 Jan 2017 10:08:28 +0100 + +git-buildpackage (0.8.9) unstable; urgency=medium + + [ Guido Günther ] + * [b6a94b6] git-pbuilder: Run actions under "set -x" + cowbuilder is currently very terse about certain errors so run the + action under "set -x" to print the exact command invocation. + This will also help to diagnose sudo issues. + * [ef1d8e7] create-remote-repo: allow to list config sections via + gbp create-remote-repo list + * [be44031] gbp create-remote-repo: autocomplete --remote-config= too + * [1291b17] Update to git-builder 1.43. Thanks Russ Allberry! + * [0e3deeb] setup.py: use a valid classifier + from https://pypi.python.org/pypi?%3Aaction=list_classifiers + * [9cbb9df] Use relative patch to install gbp.conf to make + pip install --user work + * [6f5070d] bash completion: don't complete options values with options. So + far hitting on --bar= would have all other options as suggestions + which is confusing. + * [a21e394] bash completion: complete tags on --upstream-vcs-tag= too + * [fe39b8e] bash completion: complete filenames on hooks, cleaners and builders + * [f7a61fa] Only set username and email when creating repos. Don't modify + existing ones. + * [cb8169d] gbp {clone, import_dsc, import_srpm}: Document new + --repo-{user,email} options + * [7b297b7] GitRepository: allow to check cleanliness of arbitrary paths + * [e31f15b] gbp pq: Don't fail --commit on empty commits. So far we would fail + empty commits with a confusing error + * [bad1f23] import-orig: Handle download errors properly. + * [d90e6be] import-orig: determine download automatically making --download + superfluous and deprecated. + * [58271d6] import-dsc: determine download automatically making --download + superfluous and deprecated. + * [8038a6f] import-dsc: Improve error message if there is no dsc file + instead of spewing the exception on the console. + * [9ecb5a4] Add helper to run tests in docker container + and use this on travisci. Some ideas taken form travis.debian.net. + * [3b1b9bc] GitRepository: use GitArgs for update_ref + * [1ac2724] GitRepository.commit_dir: add a proper reflog entry + otherwise 'gbp import-dsc' adds reflog entries without a description. + * [7ae2778] GitRepository: allow for dry-run push + * Various enhancements to the test-suite including tests that reach out to + the network to test these import options + * Various enhancements to the gbp-posttag-push example hook like trying the + git push with --dry-run before the upload. + + [ Michael Stapelberg ] + * [67cf3ed] gbp clone: configure user.email, user.name from DEBEMAIL/DEBFULLNAME. + Close: #845536 + + -- Guido Günther Sat, 31 Dec 2016 17:13:03 +0100 + +git-buildpackage (0.8.8) unstable; urgency=medium + + [ Chris Lamb ] + * [03276df] Add ability to specify the clone target to gbp-import-{dsc,srpm} + (Closes: #846567) + + [ Guido Günther ] + * [0a9cf44] docs: setting target dir is supported for --download too + * [f631e64] import_dsc: fail properly again without a package to import + * [a10c77b] import_srpm: allow for more than one argument otherwise giving a + target dir always raises an error + * [e1aec57,627b858] import_rpms: use upstream version for upstream tag + (Closes: #846936) + * [ce42aadc] pq_rpm: use relative path names for patches Based on a patch + from Tzafrir Cohen + (Closes: #834582) + * [fa091b6] rpm: improve error message on specfile patch parser errors. + * [bf4afbe] gbp-posttag-push: catch exceptions instead of printing the full + trace + * [1d44f48] buildpackage_rpm: drop unused vcs_info() + * flake8 cleanups all over the rpm code + + [ Tzafrir Cohen ] + * [73d30ef] specfile: handle %patch -F. + (Closes: #846479) + * [d9b28f9] gbp-mock: handle single letter options by properly handling '-?' + to request help output. + (Closes: #847464) + + -- Guido Günther Thu, 08 Dec 2016 14:52:18 +0100 + +git-buildpackage (0.8.7) unstable; urgency=medium + + [ Guido Günther ] + * [924f809] Build-depend on libdistro-info-perl. + This silences the testsuite and unbreaks the build on Ubuntu + (Closes: #842960) + * [36b8a58] rpm: don't warn about deprecated $repo/.gbp.conf. + People use it a lot with rpm based tools so don't warn there until we + clearly suggested a better location. + * [3c498e1] docs: Don't suggest deprecated section names in examples + * [42657fc] docs: Rework "upstream uses git" section + * [ced46db] tests: Move doctests to subdir + * [ea5775a] commands: allow to fall back to error reason if stderr is empty. + Use this in PristineTar and SrcRpmFile to give better error messages if + the command doesn't even get to print to stderr (i.e. missing on disk). + (Closes: #842592) + * [4cacaeb] Avoid printing deprecation twice. Some tools reparse the + config. We don't want another deprecation in this case. + * [039a286] Avoid deprecation outside of Debian package repositories. E.g. + ~ might have a .gbp.conf for the user and might be git managed. + * [acf7a73] Avoid deprecation on bash completion + * [6f75d7c] Fix new flake8 errors. (Closes: #844932) + * [420e299] DebianGitRepository: Handle dot escaping as specified in DEP-14 + (Closes: #843840) + * [d360a6d] DebianGitRepository: simplify version mangling '%' is not valid + in a Debian version number and we only want single character replacements + for now. + * [7ed5e2b] DebianGitRepository: Unmangle version. When mapping from a git + tag to a Debian version unamngle it. + * [0b317ee] docs: Use version mangling with care + * [c96a5b4] docs: Recommend DEP-14 + * [9cb3966] examples/gbp-posttag-push: allow to upload packages too after + pushing all the git data to the remote end. Making one more custom + packaging script obsolete. + + [ Jonas Meurer ] + * [dd5c3bc] Add version mangling. + This allows to replace characters in upstream version numbers. I.e. + replace '-' by '.'. (Closes: #842638) + + -- Guido Günther Mon, 28 Nov 2016 08:39:35 +0100 + +git-buildpackage (0.8.6) unstable; urgency=medium + + * [a35d7d6] buildpackage: handle /master + * [12fda23] create-remote-repo: print proper error message on missing + remote-configs instead of printing the exception to the console. + * [e917d3a] config: Turn dict of config files into a list so we get a fixed + order with all Python versions + * [c092d73] config: warn on deprecated $REPO/.gbp.conf location. The file + is deprecated at least since 2012 but we never warned about it. Warning + can be disabled via GBP_DISABLE_GBP_CONF_DEPRECTATION. + * [507ae50] import-orig: Document --rollback option + * [eb3be92] import-orig: Give some context on --merge-mode=replace option + + -- Guido Günther Sun, 23 Oct 2016 17:16:23 +0200 + +git-buildpackage (0.8.5) unstable; urgency=medium + + [ Guido Günther ] + * Fixes: + * [7c964ea] buildpackage: add back export-dir options + (Closes: #839581) + + * Improvements: + * [9817e89] posttag-push: Print branches we push to + + * Cleanups: + * [a5a8a1c] pq: remove redundancies in --pq-from code paths + * [59dce12] pq: introduce pq_on_upstream_tag + * [f31bcd2] pq: make TestFromTAG tests silent + * [c1ab85a] test_pq_rpm: flake8 clean + * [86068d4] test_pq_rpm.py: don't spew on stderr + * [46787e3] test_buildpackage_rpm.py: flake8 clean + * [f96c8e1] tests: capture stderr in gbp rpm-ch component tests - reduces + spurious output + * [e4c893d] tests: capture stderr in gbp import_srpm component tests - + reduces spurious output + * [43beb38] GitRepository.archive: use _git_inout instead of the + deprecated _git_getoutput that spews to stderr This silences a spurious + output to stderr in test_buildpackage_rpm + * [55e8c8f] GitRepository.list_submodules: use _git_inout and check exit + status. + * [53f9f40] test_buildpackage_rpm: check that we fail subtarball + generation correctly + * [f87c21c] tests/buildpackage: test --git-export-dir + + [ Linn Crosetto ] + * [c1b32fa] dch: avoid adding section in snapshot mode if distribution is + UNRELEASED. (Closes: #838714) + + -- Guido Günther Mon, 10 Oct 2016 18:06:32 +0200 + +git-buildpackage (0.8.4) unstable; urgency=medium + + [ Maximiliano Curia ] + * [e615c65] pq: Handle unmerged debian branches. This allows one to import + the patch-queue branch onto the upstream tag. + (Closes: #834726) + * [f6433f9] pq: Ensure we are working in the right git directory. + + [ Guido Günther ] + * [6909bb1] Unbreak gbp-pq manpage generation + * flake8 cleaniness + * [7a7068d] create_remote_repo: allow one to create non bare repositories + (Closes: #837158) + * [98cea5f] import_orig: Use gbp.scripts.common.hook + * [5ff1be8] test_rpm_ch: use GIT_AUTHOR_* env vars. + * [98ea945] flake8: Ignore rpm related files for now. This makes it easier + to integrate changes from git-buildpackage-rpm. + * [3ded91b] Move doc generation and test invocation to separate Makefile + * [2845359] Switch from pychecker to flake8. The later is maintained and + has more checks Use '-j1' for now since otherwise we need /dev/shm access + which fails in a pbuilder chroot with EPERM. + * [264090e] Rename README to README.md to get Markdown formatting + * [2809284] dch: document which options can't be set via gbp.conf + * [2122d8b] dch: document --security + * [ef7ca4a] config: allow one to specify short options + * [3feba49] dch: make urgency a config file option so it can be set via + gbp.conf (Closes: #837680) + * [fdcee06] dch: add missing short opts to manpage + * [dbb9623] Unbreak patch delta output broken by "pq: Ensure we are working + in the right git directory" + * [3e26d02] Vcs-Git: use https transport + * [74c7bc0] autopkgtest: Skip build if setuptools is not available + * [6ec588a] pq: restrict choices of pq-from to 'DEBIAN' and 'TAG' + + [ Markus Lehtonen ] + * [c6b32c8] Command: redirect stdout/stderr to sys.stdout/stderr. + * [245b443] tests: capture stderr in buildpackage-rpm unit tests. + Reduces spurious output from rpmbuild. (Closes: #829690) + + -- Guido Günther Tue, 27 Sep 2016 18:56:12 +0200 + +git-buildpackage (0.8.3) unstable; urgency=medium + + * Upload to unstable + * [51620e9] import-orig: export version information to postimport hook + (Closes: #833429) + * [086ff78] Drop dependencies on sp and jade. + Thanks to Neil Roeth + * [bf46e26] Update to git-pbuilder 1.42 + * [99e7703] import_orig: Properly abort merge on rollbacks. + If merging fails we need to call "git merge --abort" + * [a868977] tests: match env vars values in hook checks too + * [fae6456] tests: only check gbp related env vars in hooks. + This avoids test failures when env vars contain newlines + + -- Guido Günther Fri, 26 Aug 2016 14:18:17 +0200 + +git-buildpackage (0.8.2) experimental; urgency=medium + + * [1f0013c] import-orig: Switch to Debian branch before merging in changes + otherwise we'd always merge into the current working copy + (Closes: #832016) + * [a52aff5] download_orig: unlink file before raising the exception + otherwise we would not clean up + * [3d261da] import_orig: Only try rollbacks if necessary. + * [61e659d] pq: strip comments with multiple leading whitespace. Really + Closes: #825536 + * [68940fb] pq: Retry patch with whitespace fixup on failure. This helps + patches with CRLF line endings and we don't lose anything since we'd + failed otherwise anyway. (Closes: #833066) + * [e2671b9] docs: fix --postclone and --hooks options of git-clone. + Thanks to IOhannes m zmoelnig for pointing this out + * [e68a0a1] docs: Document --postclone hook behaviour with debian/gbp.conf + Thanks to IOhannes m zmoelnig for pointing this out + (Closes: #833143) + + -- Guido Günther Tue, 02 Aug 2016 19:26:33 +0200 + +git-buildpackage (0.8.1) experimental; urgency=medium + + [ Guido Günther ] + * [3a5a497] import_dsc: Use the same patch options as dpkg-source for 1.0 + packages (except for creating backup files) (Closes: #670099) + * [8d84fd3] dch: Match 'thanks' case insensitive (Closes: #746753) + * [29f16ca] Unbreak autopkgtest by setting git user and email + * [2b33349] import_orig: Drop duplicate log message when rolling back a branch + * [7ba43f6] Improve check for empty_repository. + Based on a patch by Carlos Maddela (Closes: #791472) + * [55fd73a] Remove outdated ref on git-import-dsc + * [1fae819] Use proper test fixtures. + (Closes: #723888) + * [95c8c53] clone: add postclone hook (Closes: #812816, #812815) + * [491adcf] clone: document missing directory option + + [ Michael Elovskikh ] + * [a6311e6] Added option `never` to dch `--spawn-editor` choices + + -- Guido Günther Fri, 08 Jul 2016 15:44:28 +0200 + +git-buildpackage (0.8.0) experimental; urgency=medium + + [ Markus Lehtonen ] + * [c5cfb5e] Introduce gbp-rpm-ch. + Initial version of gbp rpm-ch command, a tool for maintaining + RPM changelogs. The new command supports %changelog section inside spec + files as well as separate changelog files ("OBS style"). (Closes: #808027) + + [ Guido Günther ] + * [b4b7f9f] clone: Be a bit more verbose and let the user know that we + started cloning + * [1f58d21] PatchSeries: Strip comment from patch names (Closes: #825536) + * [1989c32] pq: Report number of imported patches + * [dcb145f] Use existing option as example in gbp-buildpackage manpage. + Thanks to Nicolas Braud-Santoni (Closes: #828703) + * [f1c64e2] manpages: add examples for gbp {clone,import-dsc} + * [83dfa67] GitRepository: Deleting a non-existing branch should not throw + an error + * [ba7b087] docs: Clarify some gbp pq options + * [ebc6b91] import_orig: Recover from import errors by winding back branches + and tags to their pre-error states (Closes: #828838) + * [4964234] dch: Log version number when preparing a snapshot + (Closes: #829025) + * [7a6641a] import-dsc: Don't fail on 1.0 non-native packages without a + Debian version + (Closes: #829070) + * [8c4460c] Actually install gbp-rpm-ch and unbreak manpage generation + * [d92b656] tests: Omit build dependend variables from epydocs + based on a patch from Sascha Steinbiss (Closes: #827546) + * [d977377] Set date in manpages based on last changelog entry + for reproducibility. This can be reverted once ocbook2man is fixed + (#800797). + Thanks to Sascha Steinbiss for the patch + * [53f37eb] import-orig: Make default import message more gbp-dch friendly. + * [312c9b9] Use imperative for git messages as suggested in gh:#26. + * [2bc3801] import_dsc: don't assume component tarballs have the correct name. + (Closes: #829458) + * [bc3805c] import_orig: add support for importing additional tarballs. + We expect the additional tarballs to be located next to the orig tarball + and to be already named properly. (Closes: #561071) + * [870c901] Docs: Clarify on possible key names and priorities in gbp.conf + * [7a521d4] Handle Ctrl-C more gracefully + * [b540c98] additional tarballs: allow one to configure components via gbp.conf + * [1d4d4a2] config: Allow one to give list values in plural form + * [700e164] config: Properly abort on config file parsing errors + instead of printing an exception on the console + * [3b4912d] config: always use 'gbp ' in help output. + The {git,gbp}- versions went away ages ago + * [f545010] Give more instructions when config is unparseable + and make return codes and messages consistent. + (Closes: #733640) + * [a0ed81b] Require python 2.7. It's the default up to Wheezy + (Closes: #685031) + + [ Otto Kekäläinen ] + * [af16f59] Fix simple spelling errors in comments and strings + * [f28a26b] Fix spelling of existant->existent in function names, strings + and comments + + -- Guido Günther Mon, 04 Jul 2016 21:47:42 +0200 + git-buildpackage (0.7.5ubuntu0~ppa1) xenial; urgency=medium * Backport to Xenial. diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/control git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/control --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/control 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/control 2017-02-11 19:33:12.000000000 +0000 @@ -7,11 +7,11 @@ debhelper (>= 9~), dh-python, docbook-utils, + flake8, gtk-doc-tools, - jade, + libdistro-info-perl, perl, - pychecker, - python (>> 2.6.6-3~), + python (>> 2.7.3), python-coverage, python-dateutil, python-epydoc, @@ -31,12 +31,15 @@ pristine-tar, rpm, unzip, - zipmerge -Standards-Version: 3.9.6 -Vcs-Git: git://honk.sigxcpu.org/git/git-buildpackage.git + zipmerge, +# For the network tests + curl, + python-requests, +Standards-Version: 3.9.8 +Vcs-Git: https://git.sigxcpu.org/cgit/git-buildpackage/ Vcs-Browser: https://git.sigxcpu.org/cgit/git-buildpackage/ Homepage: https://honk.sigxcpu.org/piki/projects/git-buildpackage/ -X-Python-Version: >= 2.6 +X-Python-Version: >= 2.7 Package: git-buildpackage Architecture: all diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/docs git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/docs --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/docs 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/docs 2017-02-11 19:33:12.000000000 +0000 @@ -1,3 +1,3 @@ -README +README.md docs/manual-html/ build/apidocs/ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/gbp.completion git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/gbp.completion --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/gbp.completion 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/gbp.completion 2017-02-11 19:33:12.000000000 +0000 @@ -21,8 +21,17 @@ } +_gbp_remote_configs () +{ + GBP_DISABLE_GBP_CONF_DEPRECTATION=true \ + GBP_DISABLE_SECTION_DEPRECTATION=true \ + gbp create-remote-repo list | sed -ne 's/^ \+\([a-z]\+\)/\1/p' +} + + _gbp_options () { + GBP_DISABLE_GBP_CONF_DEPRECTATION=true \ GBP_DISABLE_SECTION_DEPRECTATION=true \ gbp "${1}" --help | sed -ne 's/^ \+\(\(\-[a-z]\), \)\?\(\-\-[a-z\-]\+\=\?\).*/\2 \3/p' } @@ -40,14 +49,20 @@ local prev="${COMP_WORDS[COMP_CWORD - 1]}" local options=$1 local branch_opts=${2:-"--debian-branch\= --upstream-branch\="} - local tag_opts=${3:-"--debian-tag\= --upstream-tag\="} + local tag_opts=${3:-"--debian-tag\= --upstream-tag\= --upstream-vcs-tag\="} local tristate_opts=${4:-"--color\="} local cbdist_opts=${5:-"--git-dist\="} + local remote_config_opts="--remote-config\=" + local file_opts="--postimport\= --git-builder\= --git-cleaner\= \ + --git-export-dir\= --git-postbuild\= --git-postexport\= \ + --git-posttag\= --git-prebuild\= --git-tarball-dir\=" + local start_opt="" # COMPREPLY considers '=' as a word. For $prev we prefer the word before the actual "=" if [[ "$prev" == "=" ]]; then prev="${COMP_WORDS[COMP_CWORD - 2]}" elif [[ "$cur" == "=" ]]; then + start_opt=1 cur="" fi @@ -75,12 +90,27 @@ return 0 fi + if [[ "${remote_config_opts}" == *$prev* ]]; then + local remote_configs=$(_gbp_remote_configs) + COMPREPLY=( $(compgen -W "$remote_configs" -- $cur ) ) + return 0 + fi + + if [[ "${file_opts}" == *$prev* ]]; then + COMPREPLY=( $(compgen -f -- $cur ) ) + return 0 + fi + # separate opts by tab so we can append a space to all options not ending # with an equal sign tab_opts=$(echo "$options" | sed -e 's/ \+/\t/g' -e 's/[^=]$/& /g') type compopt &>/dev/null && compopt -o nospace local IFS=$'\t\n' - COMPREPLY=($(compgen -W "$tab_opts" -- $cur)) + if [ -n "$start_opt" ]; then + COMPREPLY="" # we don't have any good suggestions + else + COMPREPLY=($(compgen -W "$tab_opts" -- $cur)) + fi } # check if we can find a gbp command on the commandline @@ -120,6 +150,14 @@ _gbp_comp "$options" } + +_gbp-create-remote-repo () +{ + local options=$(_gbp_options create-remote-repo) + options="$options list" + _gbp_comp "$options" +} + _gbp-generic-cmd() { diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage.install git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage.install --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage.install 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage.install 2017-02-11 19:33:12.000000000 +0000 @@ -29,4 +29,4 @@ usr/lib/python2.?/dist-packages/gbp/tmpfile.py usr/lib/python2.?/dist-packages/gbp/tristate.py usr/lib/python2.?/dist-packages/gbp/version.py -etc/git-buildpackage/gbp.conf +usr/share/git-buildpackage/gbp.conf etc/git-buildpackage/ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage.postrm git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage.postrm --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage.postrm 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage.postrm 2017-02-11 19:33:12.000000000 +0000 @@ -1,5 +1,5 @@ #!/bin/sh -# postrm script for libvirt-daemon-system +# postrm script for git-buildpackage # # see: dh_installdeb(1) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage.preinst git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage.preinst --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage.preinst 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage.preinst 2017-02-11 19:33:12.000000000 +0000 @@ -1,5 +1,5 @@ #!/bin/sh -# preinst script for libvirt-daemon-system +# preinst script for git-buildpackage # # see: dh_installdeb(1) @@ -13,11 +13,26 @@ # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package +cleanup_misplaced() +{ + ver=$1 + misplaced=/etc/git-buildpackage/gbp.conf/gbp.conf + gbp_conf=/etc/git-buildpackage/gbp.conf + if [ -f "${misplaced}" ] && [ "$ver" = "0.8.9" ]; then + mv -f "${misplaced}" "${gbp_conf}.dpkg-bak" + if ! rmdir "${gbp_conf}"; then + echo "Cannot remove bad dir ${gbp_conf}, trying rename" 1>&2 + mv -f "${gbp_conf}" "${gbp_conf}".dpkg-dir-bak + fi + mv -f ${gbp_conf}.dpkg-bak ${gbp_conf} + fi +} case "$1" in install|upgrade) dpkg-maintscript-helper rm_conffile \ /etc/bash_completion.d/git-buildpackage 0.6.34~ git-buildpackage -- "$@" + cleanup_misplaced $2 ;; abort-upgrade) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage-rpm.install git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage-rpm.install --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage-rpm.install 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage-rpm.install 2017-02-11 19:33:12.000000000 +0000 @@ -3,3 +3,4 @@ usr/lib/python2.7/dist-packages/gbp/scripts/import_srpm.py usr/lib/python2.7/dist-packages/gbp/scripts/pq_rpm.py usr/lib/python2.7/dist-packages/gbp/scripts/buildpackage_rpm.py +usr/lib/python2.7/dist-packages/gbp/scripts/rpm_ch.py diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage-rpm.manpages git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage-rpm.manpages --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage-rpm.manpages 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage-rpm.manpages 2017-02-11 19:33:12.000000000 +0000 @@ -1,3 +1,4 @@ docs/gbp-import-srpm.1 docs/gbp-pq-rpm.1 docs/gbp-buildpackage-rpm.1 +docs/gbp-rpm-ch.1 diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage.zsh-completion git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage.zsh-completion --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/git-buildpackage.zsh-completion 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/git-buildpackage.zsh-completion 2017-02-11 19:33:12.000000000 +0000 @@ -76,7 +76,7 @@ __gbp_tag_format_options git- __gbp_tag_sign_options git- _arguments \ - '--git-ignore-new[build with uncommited changes in the source tree]' \ + '--git-ignore-new[build with uncommitted changes in the source tree]' \ '--git-no-ignore-new[negates --git-ignore-new]' \ '--git-tag[create a tag after a successful build]' \ '--git-tag-only[do not build, only tag and run the posttag hook]' \ @@ -157,7 +157,7 @@ '--git-author[Use git name configuration for changelog signature]' \ '(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Merge commits by maintainer]' \ '(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Do not merge commits by maintainer]' \ - '--spawn-editor=[Spawn an editor]:when:(always snapshot release)' \ + '--spawn-editor=[Spawn an editor]:when:(always never snapshot release)' \ '--commit-msg=[Commit message format string]' \ '--commit[Commit the generated changelog]' \ '*:Paths:_files -/' @@ -170,7 +170,6 @@ __gbp_tag_sign_options _arguments \ '--filter=-[Filter out files]' \ - '--download=-[Download the source package]' \ '--allow-unauthenticated[Skip signature verification on downloads]' \ '--allow-same-version[Import a package with the same debian version]' \ '--author-is-committer[Use the author identity as committer identity]' \ @@ -321,7 +320,7 @@ __gbp_tag_format_options git- __gbp_tag_sign_options git- _arguments \ - '--git-ignore-new[build with uncommited changes in the source tree]' \ + '--git-ignore-new[build with uncommitted changes in the source tree]' \ '--git-no-ignore-new[negates --git-ignore-new]' \ '--git-tag[create a tag after a successful build]' \ '--git-tag-only[do not build, only tag and run the posttag hook]' \ @@ -402,7 +401,7 @@ '--git-author[Use git name configuration for changelog signature]' \ '(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Merge commits by maintainer]' \ '(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Do not merge commits by maintainer]' \ - '--spawn-editor=[Spawn an editor]:when:(always snapshot release)' \ + '--spawn-editor=[Spawn an editor]:when:(always never snapshot release)' \ '--commit-msg=[Commit message format string]' \ '--commit[Commit the generated changelog]' \ '*:Paths:_files -/' @@ -415,7 +414,6 @@ __gbp_tag_sign_options _arguments \ '--filter=-[Filter out files]' \ - '--download=-[Download the source package]' \ '--allow-unauthenticated[Skip signature verification on downloads]' \ '--allow-same-version[Import a package with the same debian version]' \ '--author-is-committer[Use the author identity as committer identity]' \ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/NEWS git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/NEWS --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/NEWS 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/NEWS 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ git-buildpackage (0.6.26) unstable; urgency=medium - All gbp-* and git-* commands are now gone as as announced in the + All gbp-* and git-* commands are now gone as announced in the deprecation notice from June 2013. From now on only "gbp " is supported. diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/rules git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/rules --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/rules 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/rules 2017-02-11 19:33:12.000000000 +0000 @@ -14,28 +14,19 @@ PYCHECKER_ARGS=-boptparse --no-override --no-shadowbuiltin %: - dh $@ --with python2 + dh $@ --with python2 --buildsystem=python_distutils override_dh_auto_test: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) dh_auto_test - export GIT_AUTHOR_NAME="Gbp Tests"; \ - export GIT_AUTHOR_EMAIL=tests@example.com; \ - export GIT_COMMITTER_NAME=$$GIT_AUTHOR_NAME; \ - export GIT_COMMITTER_EMAIL=$$GIT_AUTHOR_EMAIL; \ - PYTHONPATH=. \ - python setup.py nosetests --with-xcoverage - - PYTHONPATH=. pychecker $(PYCHECKER_ARGS) -q \ - gbp gbp.scripts gbp.git gbp.deb + make else @echo "Checks disabled via DEB_BUILD_OPTIONS" endif override_dh_auto_build: dh_auto_build - epydoc -v --config=setup.cfg - make -C docs/ + make apidocs docs override_dh_auto_install: dh_auto_install diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/debian/tests/smoke-rpm git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/tests/smoke-rpm --- git-buildpackage-0.7.5ubuntu0~ppa1/debian/tests/smoke-rpm 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/debian/tests/smoke-rpm 2017-02-11 19:33:12.000000000 +0000 @@ -4,6 +4,8 @@ set -x git init . +git config user.email "you@example.com" +git config user.name "Doesnot Matter" git add . git commit -m"Smoketest" -a cat <> ~/.rpmmacros @@ -11,8 +13,10 @@ %python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib(1).replace('dist-', 'site-'))") EOF -# Build an RPM of ourselfes -gbp buildpackage-rpm --git-packaging-dir=packaging/ -bb --nodeps - -rm -r .git ~/.rpmmacros +gbp buildpackage-rpm --help +# Build an RPM of ourselfes if build-deps are available +if python -c "import setuptools"; then + gbp buildpackage-rpm --git-packaging-dir=packaging/ -bb --nodeps + rm -r .git ~/.rpmmacros +fi diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/chapters/building.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/chapters/building.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/chapters/building.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/chapters/building.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -61,7 +61,7 @@ If you want to default to build in a separate build area, you can specify the directory to use in the gbp.conf file. -[git-buildpackage] +[buildpackage] # use a build area relative to the git repository export-dir=../build-area # to use the same build area for all packages use an absolute path: @@ -174,7 +174,7 @@ by specifying the export directory: -[git-buildpackage] +[buildpackage] # use a build area relative to the git repository export-dir = ../build-area # disable the since the sources are being exported first diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/chapters/import.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/chapters/import.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/chapters/import.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/chapters/import.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -60,9 +60,9 @@ This puts the upstream sources onto the and tags them accordingly (the default tag format is upstream/%(version)s). - The result is then merged onto the , - and a new &debian; changelog entry is created. You can again specify - different branch names via the and + The result is then merged onto the . + You can again specify different branch names via + the and options. If you are using debian/watch to keep track of how to retrieve upstream sources, you can also simply use the option: @@ -89,12 +89,41 @@ option. This is recommended. To customize the commit message used by &gbp-import-orig;, use - the option. This string is a standard - Python format string, into which the - version variable is interpolated. (i.e., - use %(version)s in your message to get - the imported upstream version). + the option. This string is a + &pyformat;, into which the + version variable is + interpolated. (i.e., use %(version)s in + your message to get the imported upstream version). + + + Recovering from errors + In case of an error &gbp-import-orig; will by default + rollback (undo) all changes it has done to the repository so far: + + + $ &gbp; import-orig --verbose --filter='CVS/*' --filter='.bzr/*' --filter='.hg/*' --filter='.svn/*' --upstream-version=1.9 ../gif2apng-1.9.tar.gz + gbp:info: Importing '../gif2apng-1.9.tar.gz' to branch 'upstream' (filtering out ["'CVS/*'", "'.bzr/*'", "'.hg/*'", "'.svn/*'"])... + gbp:info: Source package is gif2apng + gbp:info: Upstream version is 1.9 + gbp:info: Merging to 'master' + gbp:error: Automatic merge failed. + gbp:error: Error detected, Will roll back changes. + gbp:info: Rolling back branch upstream by resetting it to a6733c1f1e190ac0ed4774abc3466e9986a6df5e + gbp:info: Rolling back branch pristine-tar by resetting it to 0ee24ac614c920e30af82d602882c2ee841c88e5 + gbp:info: Rolling back tag upstream/1.9 by deleting it + gbp:info: Rolling back branch master by resetting it to ce99782336e83a56e8e579b3cdadf93b0c19e1a8 + gbp:info: Rolling back failed merge of upstream/1.9 + gbp:error: Rolled back changes after import error. + + + In this case the import failed due to a merge conflict. Other + reasons are running out of disk space, problems when generating + the pristine-tar delta. If you don't want &gbp-import-orig; to + undo changes made to the repository use + the . + + @@ -197,40 +226,95 @@ When upstream uses Git - If upstream already uses git for packaging, there are several ways to handle packaging. Two of them will - be described in a bit detail here: + If upstream uses &git; for development (and you don't want to + ignore that fact entirely), there are at least three ways to + handle packaging. The first one uses &git; exclusively and + creates the upstream tarballs from the upstream tag while the + second one still uses upstream tarballs but links your packaging + &git; history with upstreams &git; history. The third one also + uses a tarballs but does not link to the upstream history. No upstream tarballs - If upstream doesn't build upstream tarballs, or you don't care about them, the simplest - way is to clone upstream's repository and create a separate packaging branch in there. + If upstream doesn't build upstream tarballs, or you + don't care about them, the simplest way is to clone + upstream's repository and create a separate packaging branch + in there. You will not need &gbp-import-orig; at all with + this workflow. &gbp-buildpackage; will handle creating the + upstream tarballs needed the Debian source package for you. - - In order to help &gbp-buildpackage; to find upstream tags, you need to specify the format - using the command line option or the the - configuration variable. + For that to work you need to tell &gbp; how the + upstream tag format looks. Therefore you either + use the command line option + or the configuration file + variable to specify upstream's tag format. - A common upstream format is to put a v in front of the version number. - In this case, the configuration option would look like: + A common upstream format is to put + a v in front of the version + number. In this case, the configuration option would look + like: -[git-buildpackage] +[buildpackage] upstream-tag = v%(version)s - version will be replaced with the upstream version number as read from - debian/changelog. + version will be replaced with the + upstream version number as determined from + debian/changelog. The %()s + might be familiar from &pyformat;s. + + + Some upstreams use other formats though and don't separate + numbers by dots but rather by + underscore(_), + hyphen(-) or anything else. In + order to cope with that you can use version mangling of these + characters via substitution. The substitution works as + follows: + + +[buildpackage] +upstream-tag = v%(version%.%_)s + + + This means that each occurrence + of . will be replaced + by _ in the upstream version + number. For example the upstream + version 1.2.3 as determined from + the debian/changelog will be looked up + as &git; tag v1_2_3 by + &gbp-buildpackage;. + + + If you want the substitution to be the % character + you have to escape it. E.g. %(version%-%\%)s will replace - with + %, transforming 1-A.B.C to 1%A.B.C. + Only a single replacement is supported and it can only replace a single character. + + + Since some of the possible mangling characters + like _ and % are also used to denote epochs and tilde revisions + these versions can't be reconstructed when mapping from &git; tags back to &debian; versions and will therefore break other tools + like &gbp-dch;. So use version mangling with care. It's better to come up with a Debian compatible tag format upstream, + see &dep14; for the currently used expansion rules for Debian versions. + + + + If you're using &pristine-tar;, you can make &gbp-buildpackage; commit the generated tarball back to the pristine-tar branch by using the option. This will make sure - others building your package can regenerate the tarball you generated for building the &debian; package. + others building your package can exactly regenerate the + tarball you created when building the &debian; package. - + Step by step To not make any assumptions about &gbp;'s configuration, the following steps have all options given in its long versions on the command line. You can add these @@ -275,7 +359,7 @@ - Upstream tarballs + Upstream tarballs and linked upstream history If you want to track upstream's &git; but continue to import the upstream tarballs, e.g. to make sure the tarball uploaded to &debian; has the same checksum as upstream's, you can use the option @@ -289,6 +373,35 @@ + + Upstream tarballs and separate upstream history + + If you want to have upstream's &git; history available but + don't want to link it to your packaging history you can + simply keep it as a separate history. E.g. if you already have + a &git; repository with your packaging, change into that + repository and do: + + &gitcmd; remote add upstream https://upstream.example.com/upstream.git + &gitcmd; fetch upstream + + This will pull in upstream's &git; history into your repo but since + your packaging commits and upstreams commits have no common + parents the two histories will stay nicely separated. + Of course you can browse it and cherry-pick from it but + any remote repos you push to will not get upstream's history + by default unless you push any of upstream's refs. + + + Since &git; has a single tag namespace pushing + changes with git push --tags will + push upstream's tags (and therefore it's history) too so + be shure to only push dedicated tag names. + + + + + Branch layout @@ -298,7 +411,7 @@ This layout is simple to get started but falls short if one needs to maintain several versions of - the package at the same time. Therefore the following layout is recommended: + the package at the same time. Therefore the following the &dep14; layout is recommended: @@ -316,17 +429,17 @@ - upstream/<release> + upstream/latest - the upstream sources for a release matching one of the above + the latest upstream sources. - dfsg/<release> + dfsg/latest diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/chapters/intro.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/chapters/intro.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/chapters/intro.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/chapters/intro.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -87,7 +87,7 @@ you have to use git push in order to publish your changes to remote repositories like git.debian.org; this can also be - automatized with &gbp-buildpackage;'s + automated with &gbp-buildpackage;'s hook. diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/chapters/special.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/chapters/special.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/chapters/special.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/chapters/special.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -142,7 +142,7 @@ Whenever you need to work on an arbitrary &debian; package, you can check it right into &git; with one command: - &gbp-import-dsc --download package + &gbp-import-dsc apt://package cd package &gitcmd; branch debian @@ -160,12 +160,11 @@ &gitcmd; diff debian -- - to get a nice patch that can be submitted to the &debian; BTS. You can also fetch the source package from a URL: - &gbp-import-dsc --download http://mentors.debian.net/debian/pool/main/i/ipsec-tools/ipsec-tools_0.7.3-9.dsc + &gbp-import-dsc http://mentors.debian.net/debian/pool/main/i/ipsec-tools/ipsec-tools_0.7.3-9.dsc The import works incrementally; you can import new versions on top of diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/common.ent git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/common.ent --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/common.ent 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/common.ent 2017-02-11 19:33:12.000000000 +0000 @@ -33,9 +33,11 @@ gbp buildpackage-rpm"> gbp import-srpm"> gbp pq-rpm"> + gbp rpm-ch"> rpmbuild"> gbp-builder-mock"> wget"> + uscan"> Debian"> Git"> @@ -55,3 +57,6 @@ mock"> GNU"> GPL"> + + Python format string"> + DEP-14"> \ No newline at end of file diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/Makefile git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/Makefile --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/Makefile 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/Makefile 2017-02-11 19:33:12.000000000 +0000 @@ -13,8 +13,9 @@ gbp-pq \ gbp-pull \ gbp-buildpackage-rpm \ - gbp-import-srpm \ - gbp-pq-rpm \ + gbp-import-srpm \ + gbp-pq-rpm \ + gbp-rpm-ch \ $(NULL) MAN5S = gbp.conf @@ -25,8 +26,9 @@ MANPAGES=$(SGML_MANPAGES) $(POD_MANPAGES) VERSION_ENT=version.ent GBP_VERSION=../gbp/version.py -DEB_VERSION=$(shell sed -ne 's/^gbp_version="\([.a-z0-9~-]\+\)"/\1/p' $(GBP_VERSION)) +DEB_VERSION=$(shell sed -ne 's/^gbp_version\s\+=\s\+"\([.a-z0-9~-]\+\)"/\1/p' $(GBP_VERSION)) CHANGELOG=../debian/changelog +MAN_DATE=$(shell dpkg-parsechangelog -l ../debian/changelog -SDate | TZ=UTC LC_ALL=C date -f- +'%d %B %Y') # Stuff to build docs outside Debian HAVE_SGML2X ?= 1 @@ -34,7 +36,7 @@ all: $(MANUAL) $(MANPAGES) -$(MANUAL): manual.sgml chapters/*.sgml manpages/*.sgml +$(MANUAL): manual.sgml chapters/*.sgml manpages/*.sgml common.ent $(VERSION_ENT) ifeq ($(HAVE_SGML2X),1) docbook-2-html -s local $< else @@ -49,12 +51,14 @@ buildxref/%.1 buildxref/%.5: man.%.sgml manpages/%.sgml docbook2man -o buildxref $< + sed -i -r "s/\"[^\"]+\"/\"$(MAN_DATE)\"/3" $@ manpage.refs: $(BUILD_MAN_XREF_PAGES) cp buildxref/$@ $@ %.1 %.5: manpage.refs docbook2man -o . man.$*.sgml + sed -i -r "s/\"[^\"]+\"/\"$(MAN_DATE)\"/3" $@ git-pbuilder.1: ../bin/git-pbuilder pod2man $< $@ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/man.gbp-rpm-ch.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/man.gbp-rpm-ch.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/man.gbp-rpm-ch.sgml 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/man.gbp-rpm-ch.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,11 @@ + + %COMMON; + + %MANPAGES; +]> + + +git-buildpackage-rpm Manual +&man.gbp.rpm.ch; + diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-buildpackage-rpm.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-buildpackage-rpm.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-buildpackage-rpm.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-buildpackage-rpm.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -639,6 +639,7 @@ , , + , rpmbuild 8 diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-buildpackage.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-buildpackage.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-buildpackage.sgml 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-buildpackage.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -52,7 +52,7 @@ DIRECTORY TYPE LEVEL - SUBTARBALL + component DIRECTORY TREEISH @@ -575,20 +575,22 @@ - SUBTARBALL + COMPONENT When generating tarballs create an additional original - tarball of directory SUBTARBALL + tarball of directory COMPONENT in the source tree. Using additional original tarballs is - a feature of the 3.0 (quilt) souce format. See + a feature of the 3.0 (quilt) source format. See the dpkg-source manpage for details. Note that the --git-pristine-tar-commit - option is currently incompatible with this option. It also can't be - set via &gbp.conf; since it's considered an experimental feature and - might change incompatibly. - + option is currently incompatible with this option. + + + This is considered an experimental feature and might + change incompatibly. + @@ -682,7 +684,7 @@ [buildpackage] - debian-dir = debian/sid + debian-branch = debian/sid diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-clone.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-clone.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-clone.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-clone.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -28,7 +28,12 @@ branch_name depth repository - remote_uri + COMMAND + + + + repository + directory @@ -91,8 +96,82 @@ Track pristine tar branch. + + + + + Enable running hooks. + + + + + COMMAND + + + Execute COMMAND after cloning the source + from the remote. + + + Exported environment variables are: GBP_GIT_DIR (the + repository the package is being built from). + + Note that if you clone a repository that contains a + hook configuration in debian/gbp.conf + this hook will not be run automatically to prevent execution + of untrusted code. + + + + + + + + When set to + use the DEBEMAIL environment variable to set the + user.email &git; configuration otherwise use &git;'s + defaults. + + + + + + + + When set to + use the DEBUSER environment variable to set the + user.name &git; configuration otherwise use &git;'s + defaults. + + + + + repository + + + The (possibly remote) repository to clone from. + + + + + directory + + + The directory to clone to. + + + + + EXAMPLES + + Clone a repository and setup a tracking branch for pristine-tar + as well: + + + &gbp-clone; --pristine-tar git://honk.sigxcpu.org/git/git-buildpackage.git + + &man.gbp.config-files; diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp.conf.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp.conf.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp.conf.sgml 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp.conf.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -56,15 +56,17 @@ zero or one sections for each &gbp; command. Additionally, there can be an arbitrary number of sections. Comments start with a - hash sign (). The syntax is: + hash sign (). The overall layout is: [DEFAULT] - # This section is for global settings. Affects all commands + # This section is for global settings. Affects all commands. + # Options set here have the lowest priority. key = value [<command>] # Specific sections for each command, like buildpackage + # Options set here have lower priority than command line options key = value [remote-config <name>] @@ -81,15 +83,20 @@ - The pairs of the command sections are - named like the command-line options of the corresponding command - with the '--' stripped off and can hold the same values (but see - below for details). For example, + The keys in the + =value pairs are named + like the command-line options of the corresponding command (with the + '--' stripped off) and can hold the same values, but see below for + details. In case of &gbp-buildpackage; and &gbp-buildpackage-rpm; + the key needs '--git-' instead of '--' stripped off. + + + For example, the manual page documents the =directory option which can be turned into configuration file setting by dropping the - prefix: + prefix: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-create-remote-repo.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-create-remote-repo.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-create-remote-repo.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-create-remote-repo.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -29,6 +29,11 @@ branch_name branch_name + + + create + list + @@ -47,6 +52,10 @@ class="groupname">collab-maint repository on git.debian.org. + + When invoked with it lists the available + remote config templates. + OPTIONS @@ -120,6 +129,14 @@ pristine-tar branches. + + + + + Whether to the remote repository should be a bare + repository (this is the default). + + diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-dch.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-dch.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-dch.sgml 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-dch.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -26,23 +26,42 @@ tag-format - - + + + + + + + + - - commitish + + + + + + commitish + commitish + + + + version + version - version + name - level + + level + level + @@ -53,10 +72,14 @@ - + msg-format - + + + + customization-file + [path1 path2] @@ -161,8 +184,9 @@ - Start reading commit messages at - committish. + Start reading commit messages at + committish. + This option can't be set via &gbp.conf;. @@ -171,8 +195,9 @@ - Guess the last commit documented in the changelog from the - snapshot banner (or from the last tag if no snapshot banner exists). + Guess the last commit documented in the changelog from the + snapshot banner (or from the last tag if no snapshot banner exists). + This option can't be set via &gbp.conf;. @@ -256,9 +281,10 @@ - Remove any snapshot release banners and version suffixes, set - the current distribution to unstable, and - open the changelog for final tweaking. + Remove any snapshot release banners and version suffixes, set + the current distribution to unstable, and + open the changelog for final tweaking. + This option can't be set via &gbp.conf;. @@ -272,6 +298,7 @@ newversion. Together with , the snapshot number will be appended to newversion. + This option can't be set via &gbp.conf;. @@ -280,7 +307,8 @@ - Create a Team upload changelog entry. + Create a Team upload changelog entry. + This option can't be set via &gbp.conf;. @@ -289,8 +317,9 @@ - Increment the Debian release number for an upload to backports, and - add a backport upload changelog comment. + Increment the Debian release number for an upload to backports, and + add a backport upload changelog comment. + This option can't be set via &gbp.conf;. @@ -299,7 +328,8 @@ - Increment the Debian release number for a non-maintainer upload. + Increment the Debian release number for a non-maintainer upload. + This option can't be set via &gbp.conf;. @@ -308,8 +338,21 @@ - Increment the Debian release number for a Debian QA Team upload, and - add a QA upload changelog comment. + Increment the Debian release number for a Debian QA Team upload, and + add a QA upload changelog comment. + This option can't be set via &gbp.conf;. + + + + + + + + + Increment the Debian release number for a Debian Security + Team non-maintainer upload, and add a "Security Team + upload" changelog comment. + This option can't be set via &gbp.conf;. @@ -318,7 +361,8 @@ - Set the distribution field to name. + Set the distribution field to name. + This option can't be set via &gbp.conf;. @@ -327,8 +371,9 @@ - Force the distribution specified with - to be used, even if it doesn't match the list of known distributions. + Force the distribution specified with + to be used, even if it doesn't match the list of known distributions. + This option can't be set via &gbp.conf;. @@ -390,11 +435,11 @@ - + - Whether to spawn an editor: always, when doing snapshots or when + Whether to spawn an editor: always, never, when doing snapshots or when doing a release. diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-import-dsc.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-import-dsc.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-import-dsc.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-import-dsc.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -25,40 +25,51 @@ branch_name tag-format - pattern gpg-keyid - + branch_name tag-format + + debian-source.dsc + target &gbp-import-dsc; - URL - source-package + target DESCRIPTION - &gbp-import-dsc; imports a &debian; source package into a &git; repository, - notes the package version in the commit logs, and commits the change. All - information, including package name, version, &debian; diffs, and upstream - source, is automatically detected from the source package. + &gbp-import-dsc; imports a &debian; source package into a &git; repository, + notes the package version in the commit logs, and commits the change. All + information, including package name, version, &debian; modifications and upstream + source, is automatically detected from the source package. After + import the repository can be used with the other &gbp; tools. - If the command is run from within an existing repository, it will import - into this; if not, a new repository named as the Debian source package is - created. + If the command is run from within an existing &git; repository, it will import + into it; if not, a new repository named as the Debian source package is + created. You can override the location of the new repository by specifying + the optional target argument. + + + When given a URL &gbp-import-dsc; + will download the source package prior to importing it. &dget; + is used for all schemes except for the special + scheme apt:// which uses &apt-get; + (and therefore needs deb-src + entries in your /etc/apt/sources.list). @@ -154,24 +165,13 @@ - - - - - Download the source package instead of looking for it in the local - file system. The argument can either be a - source-package name or a - URL. The former uses &apt-get; to download - the source while the later uses &dget;. - - - - - Whether to skip signature verification on downloads. + Whether to skip signature verification on + downloads. Passed on verbatim to &dget; and &apt-get; + respectively. Use with care. @@ -219,12 +219,56 @@ + + + + + When set to + use the DEBUSER environment variable to set the + user.name &git; configuration otherwise use &git;'s + defaults. Only affects newly created repos. + + + + + + + + When set to + use the DEBEMAIL environment variable to set the + user.email &git; configuration otherwise use &git;'s + defaults. Only affects newly created repos. + + + &man.gbp.config-files; + EXAMPLES + + Download and import a source package from a URL: + + + &gbp-import-dsc; http://http.debian.net/debian/pool/main/h/hello/hello_2.10-1.dsc + + + Download and import a source package via apt-get + source from unstable: + + + &gbp-import-dsc; apt://hello/sid + + + Import a source package in the local file system: + + + &gbp-import-dsc; ../hello_2.10-1.dsc + + + SEE ALSO @@ -237,6 +281,10 @@ 1 , + sources.list + 5 + , + dget 1 , diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-import-dscs.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-import-dscs.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-import-dscs.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-import-dscs.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -20,7 +20,7 @@ &gbp-import-dscs; - + pkg_1.dsc pkg_2.dsc ... @@ -32,7 +32,7 @@ &gbp-import-dscs; --debsnap - + package diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-import-orig.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-import-orig.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-import-orig.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-import-orig.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -30,15 +30,17 @@ gpg-keyid tag-format - pattern + pattern + component - + - upstream-source + filename + url @@ -46,20 +48,60 @@ DESCRIPTION - &gbp-import-orig; imports upstream-source into - the &git; repository. upstream-source can either - be a gzip, bzip2, lzma or xz compressed tar archive, a zip archive, or an - already unpacked source tree. If it is already of the form - package-name_version.orig.tar.gz, the version - information is read from the tarball's filename, otherwise it can be given - on the command line via . If the source - package name or version can't be determined, &gbp-import-orig; will prompt - for it unless is given. + &gbp-import-orig; imports upstream sources into a &git; + repository. It can import from three sources: + + + + filename: A file in the local + file system. Gzip, bzip2, lzma and xz compressed tar + archives, zip archives and already unpacked source trees are + supported. + + + + + url: The tarball is downloaded + from a http + or https url. + This needs the python-request package installed. + + + + + : The latest upstream version is fetched + via &uscan; relying on debian/watch. + + + - The sources are placed on the upstream branch (default: - upstream), tagged and merged onto the debian - branch (default: master). + If the tarballs name is already of the form + package-name_version.orig.tar.gz, the + version information is determined from the tarball's filename, + otherwise it can be given on the command line + via . If the source package + name or version can't be determined, &gbp-import-orig; will + prompt for it unless is given. + + + The sources are placed on the upstream branch (default: + upstream), tagged and merged onto the + debian branch (default: master). This + is either done using git merge in case + of merge + (the default) or by creating a new tree that consists of the new + upstream version plus the debian/ + directory. This behaviour can be enabled via + the replace + option and is preferable for source format 3.0 (quilt) packages + since direct modifications of the upstream sources are not + allowed in that format and so a 1:1 replacement of the upstream + sources is almost always desired. + + In case of an error &gbp-import-orig; will rollback (undo) + all changes it has done to the repository (see + the option). @@ -179,7 +221,7 @@ use this format string for the commit message when importing upstream versions, default is - Imported Upstream version %(version)s + New upstream version %(version)s @@ -193,6 +235,27 @@ + COMPONENT + + + + When importing the upstream tarball also look for an additional tarball + with component name COMPONENT. E.g. in + hello-debhelper_1.0.orig-foo.tar.gz + the component would be foo. The additional + tarball is expected to be in the same directory than the upstream tarball + and to use the same compression type. + + + Using additional original tarballs is a feature of the 3.0 + (quilt) source format. See + the dpkg-source manpage for + details. This is currently considered an experimental + feature and might change incompatibly. + + + + @@ -229,7 +292,35 @@ - run cmd after the import. + Run cmd after the import. The + hook gets the following environment variables passed: + + + GBP_BRANCH + + The name of the Debian packaging branch + + + + GBP_TAG + + The name of the just created upstream tag + + + + GBP_UPSTREAM_VERSION + + The just imported upstream version + + + + GBP_DEBIAN_VERSION + + The Debian version of the package with a Debian + revision of '-1' + + + @@ -237,25 +328,24 @@ - Use uscan to fetch new upstream version. + Use &uscan; to fetch new upstream version. - + - Download the tarball from the given HTTP URL. This needs - python-request installed. + Run command interactively, i.e. ask package name and version if + needed. - + - Run command interactively, i.e. ask package name and version if - needed. + Rollback changes in case of an error. @@ -270,7 +360,13 @@ &gbp-import-orig; --uscan - After downloading an upstream tarball by hand, import it + Fetch tarball from an URL + + + &gbp-import-orig; https://debian.example.com/sid/upstream-tarball-0.1.tar.gz + + + Import a local tarball &gbp-import-orig; ../upstream-tarball-0.1.tar.gz @@ -287,6 +383,10 @@ , , , + + uscan + 1 + , &man.seealso.common; diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-import-srpm.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-import-srpm.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-import-srpm.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-import-srpm.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -25,7 +25,6 @@ BRANCH-NAME TAG-FORMAT - DIRECTORY PATTERN GPG-KEYID @@ -35,17 +34,21 @@ BRANCH-NAME TAG-FORMAT - SRPM + + + + SRPM + DIRECTORY + + target &gbp-import-srpm; - URL - SRC.RPM - DIRECTORY + target @@ -54,8 +57,11 @@ &gbp-import-srpm; imports an RPM source package into a &git; repository, notes the package version in the commit logs, and commits the change. All information, including package name, version and upstream source is - automatically detected from the source package. The tool supports importing - both archived (src.rpm files) or unpacked (directory) source RPMs. + automatically detected from the source package but you can override the + location of the new repository by optionally specifying the + target argument. The tool supports importing + both archived (src.rpm files) or unpacked (directory) source RPMs. It also imports + from http(s)-URLs. @@ -158,18 +164,6 @@ - - - - - Download the source package instead of looking for it in the local - file system. The argument can either be a plain package name or an - URI. The former uses yumdownloader to download the - source while the later uses &wget;. - - - - @@ -221,6 +215,28 @@ + + + + + When set to + use the DEBUSER environment variable to set the + user.name &git; configuration otherwise use &git;'s + defaults. Only affects newly created repos. + + + + + + + + When set to + use the DEBEMAIL environment variable to set the + user.email &git; configuration otherwise use &git;'s + defaults. Only affects newly created repos. + + + @@ -232,6 +248,7 @@ , , + , , &man.seealso.common; diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-pq.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-pq.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-pq.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-pq.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -29,6 +29,8 @@ + [DEBIAN|TAG] + tag-format @@ -194,15 +196,16 @@ - Whether to drop (delete) the patch queue branch after + Whether to automatically drop (delete) the patch queue branch after a successful export - In case of , import even if the branch already - exists + In case of , import even if the + patch-queue branch already exists and overwrite its + content with debian/patches. @@ -229,6 +232,29 @@ + + [DEBIAN|TAG] + + + + How to find the starting point for the patch queue base. The options are DEBIAN, that will use the Debian branch as the base for the patch queue branch, and TAG, that will use the corresponding upstream tag as a base for the patch queue branch. + + + This is only needed if your upstream branch is not merged in the Debian branch. + The default is DEBIAN. + + + + + TAG-FORMAT + + + + Use this tag format when looking for tags of upstream versions, + default is upstream/%(version)s. + + + diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-pull.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-pull.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-pull.sgml 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-pull.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -29,6 +29,7 @@ branch_name branch_name depth + repository @@ -36,9 +37,16 @@ &gbp-pull; updates the debian, upstream and pristine-tar - branches from a remote repository in one go. It checks if the update is safe (would + branches from remote repositories in one go. It checks if the update is safe (would result in a fast-forward merge) and aborts otherwise. + + If given on the command line the changes are fetched from the + given repository otherwise the default + for repository is read from + the remote configuration for each + branch (in git's configuration). + OPTIONS diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-rpm-ch.sgml git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-rpm-ch.sgml --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/gbp-rpm-ch.sgml 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/gbp-rpm-ch.sgml 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,355 @@ + + +
+ &rpm-email; +
+ + &rpm-firstname; + &rpm-surname; + +
+ + gbp-rpm-ch + &rpm-mansection; + + + gbp-rpm-ch; + Generate the RPM changelog from git commit messages + + + + &gbp-rpm-ch; + &man.common.options.synopsis; + =DIRECTORY + =VENDOR + BRANCH-NAME + TAG-FORMAT + + DIRECTORY + FILEPATH + FILEPATH + COMMITISH + + + + NUMBER + REGEX + REV-FORMAT + GIT-LOG-OPTIONS + + EDITOR + CUSTOMIZATION-FILE + [PATH1 PATH2] + + + + DESCRIPTION + + &gbp-rpm-ch; reads git commit messages up to the current tip of the current + branch and updates the RPM changelog from them. + + + By default, &gbp-rpm-ch; tries to guess the last &git; commit documented in + the changelog. Alternatively, can be used to + tell &gbp-rpm-ch; at which point it should start in the &git; history, or, + to use all commits from the &git; history. + + + The additional path arguments can be used to restrict the repository paths + &gbp-rpm-ch; looks at. For even more detailed control, you can use + to restrict the generated changelog entries + further. E.g. by using + "--author=Foo Bar". + + + + OPTIONS + + &man.common.options.description; + + + =DIRECTORY + + + + Base directory under which temporary directories are created. + + + + + =VENDOR + + + + Distribution vendor name. + + + + + =BRANCH-NAME + + + + The branch in the Git repository the package is being developed on, + default is master. + + + + + + + + + Don't check if the current branch matches + PACKAGING-BRANCH. + + + + + TAG-FORMAT + + + + Tag format used, when tagging releases, + default is %(vendor)s/%(version)s + + + + + DIRECTORY + + + + Subdirectory that contains the RPM packaging files. + + + + + FILEPATH + + + + Relative path to the changelog file to use. Special value + auto causes &gbp; to guess, + SPEC uses the spec file, + CHANGES uses a separate changelog file + (name derived spec file name with .spec suffix replaced by .changes). + Guessing logic is simple: use separate changelog file if it is found, + otherwise use the spec file. + + + + + FILEPATH + + + + Relative path to the spec file to use. Special value + auto causes &gbp; to search and guess. + Other values cause the option to be + ignored: the directory of the spec file is used, instead. + + + + + COMMITTISH + + + + Start reading commit messages at + COMMITTISH. + + + + + + + + + Do not create a new changelog section, just update the last + changelog section. + + + + + + + + + Include the full commit message in the changelog output. + + + + + GIT-LOG-OPTIONS + + + + Options passed on verbatim to git-log(1). + + + + + N + + + + Include N digits of the commit id in the + changelog entry. Default is to not include any commit ids at all. + + + + + REGEX + + + + Ignore lines in commit message matching + REGEX when generating the changelog. + + + + + REV-FORMAT + + + + Format string to use for revision field in the changelog header. The + following string fields are accepted: + %(upstreamversion)s the upstream version; + %(release)s the rpm patchlevel, i.e. + Release; %(version)s full rpm package + version; %(tagname)s tag/commit, i.e. + basically what git-describe would give. + If empty or not defined the default from packaging policy is used. + + + + + REGEX + + + + Ignore commit lines matching REGEX + when generating the changelog. + + + + + + + + + Use user.name and user.email from + git-config(1) for the changelog header. + + + + + + + + + Whether to spawn an editor: always, when doing a release or never. + + + + + + + + + The editor to use for editing the changelog. + + + + + CUSTOMIZATION-FILE + + + + Load Python code from CUSTOMIZATION-FILE. + At the moment, the only useful thing the code can do is define a + custom ChangelogEntryFormatter class. + + + + + + + META TAGS + + Additional to the above options the formatting of the new changelog entries + (one-per-commit) in the changelog can be modified by special tags (called + Meta Tags) given in the git commit message. The tags must start at the + first column of a commit message but can appear on any line. They are of + the form : VALUE. Valid + Meta Tags are: + + + + : ACTION + + + + Supported actions are: Ignore which will + ignore this commit when generating new changelog entries. + Short which will only use the description + (the first line) of the commit message when generating the changelog + entry (useful when is given) and + Full which will use the full commit + message when generating the changelog entry (useful when + is not given). + + + + + : BUGNUMBER + + + + Indicate in the changelog entry that bug + BUGNUMBER was addressed in this commit. + + + + + + The following git commit message: + + + Document meta tags + + so one doesn't have to consult the manual + + Git-Rpm-Ch: Short + Closes: #636088 + + + Results in this changelog entry: + + + - Document meta tags (Closes: #636088) + + + + &man.gbp.config-files; + + + SEE ALSO + + , + , + , + &man.seealso.common; + + Cl2vcs, + + + + AUTHOR + + &rpm-username; &rpm-email; + + +
diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/manpages.ent git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/manpages.ent --- git-buildpackage-0.7.5ubuntu0~ppa1/docs/manpages/manpages.ent 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/docs/manpages/manpages.ent 2017-02-11 19:33:12.000000000 +0000 @@ -15,5 +15,6 @@ + %COMMON.OPTIONS; diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/examples/gbp-add-patch git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/gbp-add-patch --- git-buildpackage-0.7.5ubuntu0~ppa1/examples/gbp-add-patch 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/gbp-add-patch 2017-02-11 19:33:12.000000000 +0000 @@ -35,9 +35,10 @@ import re import sys -import os, os.path +import os +import os.path from gbp.command_wrappers import (Command) -from gbp.config import (GbpOptionParserDebian, GbpOptionGroup) +from gbp.config import GbpOptionParserDebian from gbp.errors import GbpError from gbp.git import (GitRepositoryError, GitRepository) from gbp.patch_series import Patch @@ -58,7 +59,7 @@ closes += line + '\n' patch_name = os.path.basename(patch.path) - msg="""New patch %s + msg = """New patch %s %s %s @@ -70,9 +71,9 @@ retval = 0 parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] - add a new patch') + usage='%prog [options] - add a new patch') parser.add_config_file_option(option_name="meta-closes", dest="meta_closes", - help="Meta tags for the bts close commands, default is '%(meta-closes)s'") + help="Meta tags for the bts close commands, default is '%(meta-closes)s'") parser.add_option("-e", "--edit", action="store_true", dest="edit", default=False, help="edit commit message before committing") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, @@ -113,6 +114,7 @@ return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/examples/gbp-posttag-push git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/gbp-posttag-push --- git-buildpackage-0.7.5ubuntu0~ppa1/examples/gbp-posttag-push 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/gbp-posttag-push 2017-02-11 19:33:12.000000000 +0000 @@ -1,35 +1,58 @@ #!/usr/bin/python # vim: set fileencoding=utf-8 : # -# (C) 2009,2012,2015 Guido Guenther +# (C) 2009,2012,2015,2016 Guido Guenther # -# gbp-posttag-push: post tag hook to be called by git-buildpackage to push out -# the newly created tag and to forward the remote branch to that position -# -# it checks for explicit push destinations, if none are found it pushes back to -# where the branch got merged from. Before pushing it checks if the tag is -# signed. -# -# use: -# [git-buildpackage] -# posttag = gbp-posttag-push -# -# Options: -# -d: dry-run -# -u: push upstream branch too, if not on remote already -# --verbose: verbose command output +"""gbp-posttag-push: post tag hook to be called by 'gbp buildpackage' to push out +the newly created tag and to forward the remote branch to that position. +It checks for explicit push destinations, if none are found it pushes +to where the branch got merged from. Before pushing it checks if the +tag is signed. + +It will only push changes up to the tag and it will figure out if it +needs to push an upstream tag and the upstream branch as well (given +the -u option). It will push the pristine-tar branch if configured. + +Before performing a package upload it checks if it can push the +changes to the repo to ensure the Debian archive and the VCS stay in +sync (as good as possible given the async nature of the upload into +the archive). + +Configuration +------------- +In your gbp.conf use + + [buildpackage] + posttag = gbp-posttag-push -u + +to enable the hook. To also enable archive uploads configure an +apropriate upload command: + + [gbp-posttag-push] + upload-cmd = dput + +Options +------- +-d: dry-run +-u: push upstream branch too, if not on remote already +--verbose: verbose command output +""" from __future__ import print_function -from six.moves import configparser +import glob import os import subprocess import sys import gbp.log -from gbp.config import GbpOptionParser -from gbp.deb.git import DebianGitRepository - +from gbp.command_wrappers import Command, CommandExecFailed +from gbp.config import GbpOptionParserDebian +from gbp.deb.git import DebianGitRepository, GitRepositoryError +from gbp.deb.source import DebianSource +from gbp.errors import GbpError +from gbp.git.vfs import GitVfs +from gbp.scripts.common import ExitCodes class Env(object): @@ -44,9 +67,9 @@ if not len(remote): continue repo, refspec = remote.split() - repo = ".".join(repo.split('.')[1:-1]) # remote..push + repo = ".".join(repo.split('.')[1:-1]) # remote..push try: - remote = refspec.split(':')[1] # src:dest + remote = refspec.split(':')[1] # src:dest except IndexError: remote = refspec dests[repo] = remote @@ -56,10 +79,10 @@ def get_pull(env): """where did we pull from?""" cmd = 'git config --get branch."%s".remote' % env.branch - remote = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()[0].strip() + remote = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()[0].strip() if not remote: remote = 'origin' - return { remote: env.branch } + return {remote: env.branch} def git_push_sim(*args): @@ -69,7 +92,6 @@ def get_upstream_tag(repo, tag, tag_format): # FIXME: This assumes the debian version is the last part after the slash: version = tag.split('/')[-1] - no_epoch = version.split(':')[-1] upstream = version.rsplit('-')[0] tag = tag_format % dict(version=upstream) if repo.has_tag(tag): @@ -77,16 +99,19 @@ return None -def main(argv): - env = Env() - upstream_sha1 = None +def build_parser(name): + + # Until we moved this out of examples + os.environ['GBP_DISABLE_SECTION_DEPRECTATION'] = '1' + GbpOptionParserDebian.defaults['upload-cmd'] = "" + GbpOptionParserDebian.help['upload-cmd'] = "Upload command, default is '%(upload-cmd)s'" try: - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] paths') - except configparser.ParsingError as err: - gbp.log.error(err) - return 1 + parser = GbpOptionParserDebian(command=os.path.basename(name), + usage='%prog [options]') + except GbpError as err: + gbp.log.err(err) + return None parser.add_option("-d", "--dry-run", dest="dryrun", default=False, action="store_true", help="dry run, don't push.") @@ -98,25 +123,90 @@ dest="upstream_branch") parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag") + parser.add_config_file_option(option_name="debian-tag", + dest="debian_tag") + parser.add_config_file_option(option_name="upload-cmd", + dest="upload_cmd") + parser.add_boolean_config_file_option(option_name="pristine-tar", + dest="pristine_tar") + parser.add_config_file_option(option_name="color", dest="color", type='tristate') + parser.add_config_file_option(option_name="color-scheme", + dest="color_scheme") parser.add_option("--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") + return parser - (options, args) = parser.parse_args() - gbp.log.setup(False, options.verbose) - repo = DebianGitRepository('.') +def parse_args(argv): + parser = build_parser(argv[0]) + if not parser: + return None, None + return parser.parse_args(argv) + + +def find_changes(sourcename, version): + glob_ex = "../%s_%s_*.changes" % (sourcename, version) + gbp.log.info("Looking for changes at %s" % glob_ex) + # FIXME: verify version in .changes file + return glob.glob(glob_ex) + + +def upload_changes(changes, cmd, dryrun): + ret = 0 + for name in changes: + gbp.log.info("Running %s" % " ".join([cmd, name])) + try: + if not dryrun: + Command(cmd, [name], shell=False)() + except CommandExecFailed: + gbp.log.err("Upload of '%s' failed." % name) + ret = 1 + return ret + + +def do_push(repo, dests, debian_tag, debian_sha1, upstream_tag, upstream_sha1, upstream_branch, pristine_tar_sha1, dry_run): + verb = "Dry-run: Pushing" if dry_run else "Pushing" + for dest in dests: + gbp.log.info("%s %s to %s" % (verb, debian_tag, dest)) + repo.push_tag(dest, debian_tag, dry_run) + gbp.log.info("%s %s to %s:%s" % (verb, debian_sha1, dest, dests[dest])) + repo.push(dest, debian_sha1, dests[dest], dry_run) + if upstream_tag: + gbp.log.info("%s %s to %s" % (verb, upstream_tag, dest)) + repo.push_tag(dest, upstream_tag, dry_run) + if not repo.branch_contains("%s/%s" % (dest, upstream_branch), + upstream_sha1, remote=True): + gbp.log.info("%s %s to %s:%s" % (verb, upstream_sha1, dest, upstream_branch)) + repo.push(dest, upstream_sha1, upstream_branch, dry_run) + if pristine_tar_sha1: + branch = repo.pristine_tar.branch + gbp.log.info("%s %s to %s:%s" % (verb, pristine_tar_sha1, dest, branch)) + repo.push(dest, pristine_tar_sha1, branch, dry_run) + +def main(argv): + retval = 0 + env = Env() + upstream_sha1 = None + + (options, args) = parse_args(argv) + if not options: + return ExitCodes.parse_error + + gbp.log.setup(options.color, options.verbose, options.color_scheme) + + repo = DebianGitRepository('.') if options.dryrun: - print("Dry run mode. Not pushing.") + gbp.log.warn("Dry run mode. Not pushing, not uploading.") repo.push = git_push_sim repo.push_tag = git_push_sim - for envvar in [ "GBP_TAG", "GBP_BRANCH", "GBP_SHA1" ]: + for envvar in ["GBP_TAG", "GBP_BRANCH", "GBP_SHA1"]: var = os.getenv(envvar) if var: - env.__dict__.setdefault( "%s" % envvar.split("_")[1].lower(), var) + env.__dict__.setdefault("%s" % envvar.split("_")[1].lower(), var) else: - print("%s not set." % envvar, file=sys.stderr) + gbp.log.err("%s not set." % envvar) return 1 dests = get_push_targets(env) @@ -128,22 +218,53 @@ upstream_sha1 = repo.rev_parse("%s^{}" % upstream_tag) if not repo.verify_tag(env.tag): - print("Not pushing nonexistent or unsigned tag '%s'." % env.tag, file=sys.stderr) + gbp.log.info("Not pushing non-existent or unsigned tag '%s'." % env.tag) return 0 - for dest in dests: - print("Pushing %s to %s" % (env.tag, dest)) - repo.push_tag(dest, env.tag) - print("Pushing %s to %s" % (env.sha1, dest)) - repo.push(dest, env.sha1, dests[dest]) - if options.push_upstream and upstream_tag: - print("Pushing %s to %s" % (upstream_tag, dest)) - repo.push_tag(dest, upstream_tag) - if not repo.branch_contains("%s/%s" % (dest, options.upstream_branch), - upstream_sha1, remote=True): - print("Pushing %s to %s" % (upstream_sha1, dest)) - repo.push(dest, upstream_sha1, options.upstream_branch) - print("done.") + source = DebianSource(GitVfs(repo, env.tag)) + version = source.changelog.noepoch + + if source.is_native(): + pristine_tar_sha1 = None + else: + upstream_version = source.changelog.upstream_version + pristine_tar_sha1 = repo.pristine_tar.get_commit('%s_%s.orig.tar.*' % (source.sourcepkg, upstream_version)) + + try: + if options.upload_cmd: + do_push(repo, + dests, + env.tag, + env.sha1, + upstream_tag if options.push_upstream and upstream_tag else None, + upstream_sha1, + options.upstream_branch, + pristine_tar_sha1 if options.pristine_tar else None, + dry_run=True) + changes = find_changes(source.sourcepkg, version) + if len(changes): + retval = upload_changes(changes, options.upload_cmd, options.dryrun) + else: + gbp.log.info("No changes file found, nothing to upload.") + else: + gbp.log.info("No upload command defined, not uploading to the archive") + + do_push(repo, + dests, + env.tag, + env.sha1, + upstream_tag if options.push_upstream and upstream_tag else None, + upstream_sha1, + options.upstream_branch, + pristine_tar_sha1 if options.pristine_tar else None, + dry_run=False) + except (GbpError, GitRepositoryError) as err: + if str(err): + gbp.log.err(err) + retval = 1 + + return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/examples/jenkins-scratchbuilder git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/jenkins-scratchbuilder --- git-buildpackage-0.7.5ubuntu0~ppa1/examples/jenkins-scratchbuilder 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/jenkins-scratchbuilder 2017-02-11 19:33:12.000000000 +0000 @@ -32,7 +32,7 @@ # Reset the changelog git checkout -f debian/changelog -# Create a monitonically increasing changelog by including the build number +# Create a monotonically increasing changelog by including the build number gbp dch -S -a --ignore-branch --snapshot-number=${BUILD_NUMBER} # Build the package diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/examples/wrap_cl.py git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/wrap_cl.py --- git-buildpackage-0.7.5ubuntu0~ppa1/examples/wrap_cl.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/wrap_cl.py 2017-02-11 19:33:12.000000000 +0000 @@ -8,6 +8,7 @@ import textwrap import gbp.dch + def format_changelog_entry(commit_info, options, last_commit=False): entry = gbp.dch.format_changelog_entry(commit_info, options, last_commit) if entry: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/examples/zeitgeist-git.py git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/zeitgeist-git.py --- git-buildpackage-0.7.5ubuntu0~ppa1/examples/zeitgeist-git.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/examples/zeitgeist-git.py 2017-02-11 19:33:12.000000000 +0000 @@ -48,14 +48,14 @@ try: CLIENT = ZeitgeistClient() except RuntimeError as e: - print("Unable to connect to Zeitgeist, won't send events. Reason: '%s'" %e) + print("Unable to connect to Zeitgeist, won't send events. Reason: '%s'" % e) def get_repo(): """Get uri of remote repository and its name""" repo = None uri = subprocess.Popen(['git', 'config', '--get', 'remote.origin.url'], - stdout=subprocess.PIPE).communicate()[0] + stdout=subprocess.PIPE).communicate()[0] if uri: uri = uri.strip().decode(sys.getfilesystemencoding()) @@ -65,7 +65,7 @@ sep = ':' try: repo = unicode(uri.rsplit(sep, 1)[1]) - except IndexError: # no known separator + except IndexError: # no known separator repo = uri repo = repo.rsplit(u'.git', 1)[0] return repo, uri @@ -86,19 +86,19 @@ origin = uri subject = Subject.new_for_values( - uri = uri, - interpretation = Interpretation.DOCUMENT.TEXT_DOCUMENT.PLAIN_TEXT_DOCUMENT.SOURCE_CODE.uri, - manifestation = Manifestation.FILE_DATA_OBJECT.uri, - text = repo, - origin = origin) + uri=uri, + interpretation=Interpretation.DOCUMENT.TEXT_DOCUMENT.PLAIN_TEXT_DOCUMENT.SOURCE_CODE.uri, + manifestation=Manifestation.FILE_DATA_OBJECT.uri, + text=repo, + origin=origin) event = Event.new_for_values( - timestamp = int(time.time() * 1000), - interpretation = interpretation, - manifestation = Manifestation.USER_ACTIVITY.uri, - actor = "application://gitg.desktop", - subjects = [subject]) + timestamp=int(time.time() * 1000), + interpretation=interpretation, + manifestation=Manifestation.USER_ACTIVITY.uri, + actor="application://gitg.desktop", + subjects=[subject]) CLIENT.insert_event(event) + if __name__ == '__main__': main(sys.argv) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/command_wrappers.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/command_wrappers.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/command_wrappers.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/command_wrappers.py 2017-02-11 19:33:12.000000000 +0000 @@ -21,19 +21,55 @@ import subprocess import os -import os.path import signal +import sys +from contextlib import contextmanager +from tempfile import TemporaryFile + import gbp.log as log + class CommandExecFailed(Exception): """Exception raised by the Command class""" pass +@contextmanager +def proxy_stdf(): + """ + Circulate stdout/stderr via a proper file object. Designed to work around a + problem where Python nose replaces sys.stdout/stderr with a custom 'Tee' + object that is not a file object (compatible) and thus causes a crash with + Popen. + """ + stdout = None + if not hasattr(sys.stdout, 'fileno'): + stdout = sys.stdout + sys.stdout = TemporaryFile() + stderr = None + if not hasattr(sys.stderr, 'fileno'): + stderr = sys.stderr + sys.stderr = TemporaryFile() + try: + yield + finally: + if stdout: + sys.stdout.seek(0) + stdout.write(sys.stdout.read()) + sys.stdout = stdout + if stderr: + sys.stderr.seek(0) + stderr.write(sys.stderr.read()) + sys.stderr = stderr + + class Command(object): """ Wraps a shell command, so we don't have to store any kind of command line options in one of the git-buildpackage commands + + Note that it does not do any shell quoting even with shell=True so + you have to quote arguments yourself if necessary. """ def __init__(self, cmd, args=[], shell=False, extra_env=None, cwd=None, capture_stderr=False, @@ -67,26 +103,26 @@ log.debug("%s %s %s" % (self.cmd, self.args, args)) self._reset_state() - stdout_arg = subprocess.PIPE if self.capture_stdout else None - stderr_arg = subprocess.PIPE if self.capture_stderr else None - cmd = [ self.cmd ] + self.args + args + cmd = [self.cmd] + self.args + args if self.shell: # subprocess.call only cares about the first argument if shell=True cmd = " ".join(cmd) - - try: - popen = subprocess.Popen(cmd, - cwd=self.cwd, - shell=self.shell, - env=self.env, - preexec_fn=default_sigpipe, - stdout=stdout_arg, - stderr=stderr_arg) - (self.stdout, self.stderr) = popen.communicate() - except OSError as err: - self.err_reason = "execution failed: %s" % str(err) - self.retcode = 1 - raise + with proxy_stdf(): + stdout_arg = subprocess.PIPE if self.capture_stdout else sys.stdout + stderr_arg = subprocess.PIPE if self.capture_stderr else sys.stderr + try: + popen = subprocess.Popen(cmd, + cwd=self.cwd, + shell=self.shell, + env=self.env, + preexec_fn=default_sigpipe, + stdout=stdout_arg, + stderr=stderr_arg) + (self.stdout, self.stderr) = popen.communicate() + except OSError as err: + self.err_reason = "execution failed: %s" % str(err) + self.retcode = 1 + raise self.retcode = popen.returncode if self.retcode < 0: @@ -107,8 +143,10 @@ """ stdout = self.stdout.rstrip() if self.stdout else self.stdout stderr = self.stderr.rstrip() if self.stderr else self.stderr + stderr_or_reason = self.stderr.rstrip() if self.stderr else self.err_reason return self.run_error.format(stdout=stdout, stderr=stderr, + stderr_or_reason=stderr_or_reason, err_reason=self.err_reason) def __call__(self, args=[], quiet=False): @@ -117,7 +155,7 @@ If run quietly it will not print an error message via the L{gbp.log} logging API. - Wether the command prints anything to stdout/stderr depends on + Whether the command prints anything to stdout/stderr depends on the I{capture_stderr}, I{capture_stdout} instance variables. All errors will be reported as subclass of the @@ -142,10 +180,9 @@ ret = 1 if ret: if not quiet: - self._log_err() + self._log_err() raise CommandExecFailed(self._format_err()) - def call(self, args, quiet=True): """Like L{__call__} but let the caller handle the return status. @@ -200,10 +237,8 @@ try: os.chdir(dir) Command.__call__(self, list(*args)) + finally: os.chdir(curdir) - except Exception: - os.chdir(curdir) - raise class UnpackTarArchive(Command): @@ -217,7 +252,7 @@ compression = '-a' Command.__init__(self, 'tar', exclude + - ['-C', dir, compression, '-xf', archive ]) + ['-C', dir, compression, '-xf', archive]) self.run_error = 'Couldn\'t unpack "%s": {err_reason}' % self.archive @@ -250,7 +285,7 @@ "Wrap rm to remove a whole directory tree" def __init__(self, tree): self.tree = tree - Command.__init__(self, 'rm', [ '-rf', tree ]) + Command.__init__(self, 'rm', ['-rf', tree]) self.run_error = 'Couldn\'t remove "%s": {err_reason}' % self.tree @@ -283,7 +318,7 @@ self.archive = archive self.dir = dir - Command.__init__(self, 'unzip', [ "-q", archive, '-d', dir ]) + Command.__init__(self, 'unzip', ["-q", archive, '-d', dir]) self.run_error = 'Couldn\'t unpack "%s": {err_reason}' % self.archive @@ -295,7 +330,7 @@ def __call__(self, target): self.run_error = 'Couldn\'t append "%s" to "%s": {err_reason}' % \ - (target, self.archive) + (target, self.archive) Command.__call__(self, [target]) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/config.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/config.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/config.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/config.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ -# vim: set fileencoding=utf-8 : +# vim: set fileencoding=utf-8: # -# (C) 2006,2007,2010-2012,2015 Guido Guenther +# (C) 2006,2007,2010-2012,2015,2016 Guido Guenther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -23,6 +23,7 @@ import os.path import sys +from gbp.errors import GbpError try: from gbp.version import gbp_version @@ -38,10 +39,12 @@ on howto create it otherwise use --upstream-branch to specify it. """ + def expand_path(option, opt, value): value = os.path.expandvars(value) return os.path.expanduser(value) + def check_tristate(option, opt, value): try: val = gbp.tristate.Tristate(value) @@ -52,14 +55,16 @@ return val -def safe_option(f): +def save_option(f): + """save options on the underlying parser""" def _decorator(self, *args, **kwargs): obj = self option_name = kwargs.get('option_name') if not option_name and len(args): option_name = args[0] - # We're decorating GbpOption not GbpOptionParser + # We're decorating GbpOption but store valid_options on + # GbpOptionParser if not hasattr(obj, 'valid_options'): if not hasattr(obj, 'parser'): raise ValueError("Can only decorete GbpOptionParser and GbpOptionGroup not %s" % obj) @@ -78,6 +83,7 @@ TYPE_CHECKER['path'] = expand_path TYPE_CHECKER['tristate'] = check_tristate + class GbpOptionParser(OptionParser): """ Handles commandline options and parsing of config files @@ -95,248 +101,282 @@ @cvar def_config_files: config files we parse @type def_config_files: dict (type, path) """ - defaults = { 'debian-branch' : 'master', - 'upstream-branch' : 'upstream', - 'upstream-tree' : 'TAG', - 'pristine-tar' : 'False', - 'pristine-tar-commit': 'False', - 'filter-pristine-tar' : 'False', - 'sign-tags' : 'False', - 'force-create' : 'False', - 'no-create-orig' : 'False', - 'cleaner' : '/bin/true', - 'keyid' : '', - 'posttag' : '', - 'postbuild' : '', - 'prebuild' : '', - 'postexport' : '', - 'postimport' : '', - 'hooks' : 'True', - 'debian-tag' : 'debian/%(version)s', - 'debian-tag-msg' : '%(pkg)s Debian release %(version)s', - 'upstream-tag' : 'upstream/%(version)s', - 'import-msg' : 'Imported Upstream version %(version)s', - 'commit-msg' : 'Update changelog for %(version)s release', - 'filter' : [], - 'snapshot-number' : 'snapshot + 1', - 'git-log' : '--no-merges', - 'export' : 'HEAD', - 'export-dir' : '', - 'overlay' : 'False', - 'tarball-dir' : '', - 'ignore-new' : 'False', - 'ignore-branch' : 'False', - 'meta' : 'True', - 'meta-closes' : 'Closes|LP', - 'meta-closes-bugnum' : r'(?:bug|issue)?\#?\s?\d+', - 'full' : 'False', - 'id-length' : '0', - 'git-author' : 'False', - 'ignore-regex' : '', - 'compression' : 'auto', - 'compression-level': '9', - 'remote-url-pattern' : 'ssh://git.debian.org/git/collab-maint/%(pkg)s.git', - 'multimaint' : 'True', - 'multimaint-merge': 'False', - 'pbuilder' : 'False', - 'qemubuilder' : 'False', - 'dist' : 'sid', - 'arch' : '', - 'interactive' : 'True', - 'color' : 'auto', - 'color-scheme' : '', - 'customizations' : '', - 'spawn-editor' : 'release', - 'patch-numbers' : 'True', - 'patch-num-format': '%04d-', - 'renumber' : 'False', - 'notify' : 'auto', - 'merge' : 'True', - 'merge-mode' : 'merge', - 'track' : 'True', - 'author-is-committer': 'False', - 'author-date-is-committer-date': 'False', - 'create-missing-branches': 'False', - 'submodules' : 'False', - 'time-machine' : 1, - 'pbuilder-autoconf' : 'True', - 'pbuilder-options': '', - 'template-dir': '', - 'remote-config': '', - 'allow-unauthenticated': 'False', - 'symlink-orig': 'True', - 'purge': 'True', - 'drop': 'False', - 'commit': 'False', - 'upstream-vcs-tag': '', - } + defaults = {'debian-branch': 'master', + 'upstream-branch': 'upstream', + 'upstream-tree': 'TAG', + 'pq-from': 'DEBIAN', + 'pristine-tar': 'False', + 'pristine-tar-commit': 'False', + 'filter-pristine-tar': 'False', + 'sign-tags': 'False', + 'force-create': 'False', + 'no-create-orig': 'False', + 'cleaner': '/bin/true', + 'keyid': '', + 'posttag': '', + 'postbuild': '', + 'prebuild': '', + 'postclone': '', + 'postexport': '', + 'postimport': '', + 'hooks': 'True', + 'debian-tag': 'debian/%(version)s', + 'debian-tag-msg': '%(pkg)s Debian release %(version)s', + 'upstream-tag': 'upstream/%(version)s', + 'import-msg': 'New upstream version %(version)s', + 'commit-msg': 'Update changelog for %(version)s release', + 'filter': [], + 'snapshot-number': 'snapshot + 1', + 'git-log': '--no-merges', + 'export': 'HEAD', + 'export-dir': '', + 'overlay': 'False', + 'tarball-dir': '', + 'ignore-new': 'False', + 'ignore-branch': 'False', + 'meta': 'True', + 'meta-closes': 'Closes|LP', + 'meta-closes-bugnum': r'(?:bug|issue)?\#?\s?\d+', + 'full': 'False', + 'id-length': '0', + 'git-author': 'False', + 'ignore-regex': '', + 'compression': 'auto', + 'compression-level': '', + 'remote-url-pattern': 'ssh://git.debian.org/git/collab-maint/%(pkg)s.git', + 'multimaint': 'True', + 'multimaint-merge': 'False', + 'pbuilder': 'False', + 'qemubuilder': 'False', + 'dist': 'sid', + 'arch': '', + 'interactive': 'True', + 'color': 'auto', + 'color-scheme': '', + 'customizations': '', + 'spawn-editor': 'release', + 'patch-numbers': 'True', + 'patch-num-format': '%04d-', + 'renumber': 'False', + 'notify': 'auto', + 'merge': 'True', + 'merge-mode': 'merge', + 'track': 'True', + 'author-is-committer': 'False', + 'author-date-is-committer-date': 'False', + 'create-missing-branches': 'False', + 'submodules': 'False', + 'time-machine': 1, + 'pbuilder-autoconf': 'True', + 'pbuilder-options': '', + 'template-dir': '', + 'remote-config': '', + 'allow-unauthenticated': 'False', + 'symlink-orig': 'True', + 'purge': 'True', + 'drop': 'False', + 'commit': 'False', + 'upstream-vcs-tag': '', + 'rollback': 'True', + 'component': [], + 'bare': 'True', + 'urgency': 'medium', + 'repo-user': 'DEBIAN', + 'repo-email': 'DEBIAN', + } help = { - 'debian-branch': - ("Branch the Debian package is being developed on, " - "default is '%(debian-branch)s'"), - 'upstream-branch': - "Upstream branch, default is '%(upstream-branch)s'", - 'upstream-tree': - ("Where to generate the upstream tarball from " - "(tag or branch), default is '%(upstream-tree)s'"), - 'debian-tag': - ("Format string for debian tags, " - "default is '%(debian-tag)s'"), - 'debian-tag-msg': - ("Format string for signed debian-tag messages, " - "default is '%(debian-tag-msg)s'"), - 'upstream-tag': - ("Format string for upstream tags, " - "default is '%(upstream-tag)s'"), - 'sign-tags': - "Whether to sign tags, default is '%(sign-tags)s'", - 'keyid': - "GPG keyid to sign tags with, default is '%(keyid)s'", - 'import-msg': - ("Format string for commit message used to commit " - "the upstream tarball, default is '%(import-msg)s'"), - 'commit-msg': - ("Format string for commit messag used to commit, " - "the changelog, default is '%(commit-msg)s'"), - 'pristine-tar': - ("Use pristine-tar to create orig tarball, " - "default is '%(pristine-tar)s'"), - 'pristine-tar-commit': - ("When generating a tarball commit it to the pristine-tar branch '%(pristine-tar-commit)s' " - "default is '%(pristine-tar-commit)s'"), - 'filter-pristine-tar': - "Filter pristine-tar when filter option is used, default is '%(filter-pristine-tar)s'", - 'filter': - "Files to filter out during import (can be given multiple times), default is %(filter)s", - 'git-author': - "Use name and email from git-config for changelog trailer, default is '%(git-author)s'", - 'full': - "Include the full commit message instead of only the first line, default is '%(full)s'", - 'meta': - "Parse meta tags in commit messages, default is '%(meta)s'", - 'meta-closes': - "Meta tags for the bts close commands, default is '%(meta-closes)s'", - 'meta-closes-bugnum': - "Meta bug number format, default is '%(meta-closes-bugnum)s'", - 'ignore-new': - "Build with uncommited changes in the source tree, default is '%(ignore-new)s'", - 'ignore-branch': - ("Build although debian-branch != current branch, " - "default is '%(ignore-branch)s'"), - 'overlay': - ("extract orig tarball when using export-dir option, " - "default is '%(overlay)s'"), - 'remote-url-pattern': - ("Remote url pattern to create the repo at, " - "default is '%(remote-url-pattern)s'"), - 'multimaint': - "Note multiple maintainers, default is '%(multimaint)s'", - 'multimaint-merge': - ("Merge commits by maintainer, " - "default is '%(multimaint-merge)s'"), - 'pbuilder': - ("Invoke git-pbuilder for building, " - "default is '%(pbuilder)s'"), - 'dist': - ("Build for this distribution when using git-pbuilder, " - "default is '%(dist)s'"), - 'arch': - ("Build for this architecture when using git-pbuilder, " - "default is '%(arch)s'"), - 'qemubuilder': - ("Invoke git-pbuilder with qemubuilder for building, " - "default is '%(qemubuilder)s'"), - 'interactive': - "Run command interactively, default is '%(interactive)s'", - 'color': - "Whether to use colored output, default is '%(color)s'", - 'color-scheme': - ("Colors to use in output (when color is enabled), format " - "is ':::', e.g. " - "'cyan:34::'. Numerical values and color names are " - "accepted, empty fields indicate using the default."), - 'spawn-editor': - ("Whether to spawn an editor after adding the " - "changelog entry, default is '%(spawn-editor)s'"), - 'patch-numbers': - ("Whether to number patch files, " - "default is %(patch-numbers)s"), - 'patch-num-format': - ("The format specifier for patch number prefixes, " - "default is %(patch-num-format)s"), - 'renumber': - ("Whether to renumber patches exported from patch queues, " - "instead of preserving the number specified in " - "'Gbp-Pq: Name' tags, default is %(renumber)s"), - 'notify': - ("Whether to send a desktop notification after the build, " - "default is '%(notify)s'"), - 'merge': - ("After the import merge the result to the debian branch, " - "default is '%(merge)s'"), - 'merge-mode': - ("Howto merge the new upstream sources onto the debian branch" - "default is '%(merge-mode)s'"), - 'track': - ("Set up tracking for remote branches, " - "default is '%(track)s'"), - 'author-is-committer': - ("Use the authors's name also as the committer's name, " - "default is '%(author-is-committer)s'"), - 'author-date-is-committer-date': - ("Use the authors's date as the committer's date, " - "default is '%(author-date-is-committer-date)s'"), - 'create-missing-branches': - ("Create missing branches automatically, " - "default is '%(create-missing-branches)s'"), - 'submodules': - ("Transparently handle submodules in the upstream tree, " - "default is '%(submodules)s'"), - 'postimport': - ("hook run after a successful import, " - "default is '%(postimport)s'"), - 'hooks': - ("Enable running all hooks, default is %(hooks)s"), - 'time-machine': - ("don't try head commit only to apply the patch queue " - "but look TIME_MACHINE commits back, " - "default is '%(time-machine)d'"), - 'pbuilder-autoconf': - ("Wheter to configure pbuilder automatically, " - "default is '%(pbuilder-autoconf)s'"), - 'pbuilder-options': - ("Options to pass to pbuilder, " - "default is '%(pbuilder-options)s'"), - 'template-dir': - ("Template directory used by git init, " - "default is '%(template-dir)s'"), - 'remote-config': - ("Remote defintion in gbp.conf used to create the remote " - "repository, default is '%(remote-config)s'"), - 'allow-unauthenticated': - ("Don't verify integrity of downloaded source, " - "default is '%(allow-unauthenticated)s'"), - 'symlink-orig': - ("Whether to creat a symlink from the upstream tarball " - "to the orig.tar.gz if needed, default is " - "'%(symlink-orig)s'"), - 'purge': - "Purge exported package build directory. Default is '%(purge)s'", - 'drop': - ("In case of 'export' drop the patch-queue branch " - "after export. Default is '%(drop)s'"), - 'commit': - "commit changes after export, Default is '%(commit)s'", - } - - def_config_files = {'/etc/git-buildpackage/gbp.conf': 'system', - '~/.gbp.conf': 'global', - '%(top_dir)s/.gbp.conf': None, - '%(top_dir)s/debian/gbp.conf': 'debian', - '%(git_dir)s/gbp.conf': None} + 'debian-branch': + "Branch the Debian package is being developed on, " + "default is '%(debian-branch)s'", + 'upstream-branch': + "Upstream branch, default is '%(upstream-branch)s'", + 'upstream-tree': + "Where to generate the upstream tarball from " + "(tag or branch), default is '%(upstream-tree)s'", + 'pq-from': + "How to find the patch queue base. DEBIAN or TAG, " + "the default is '%(pq-from)s'", + 'debian-tag': + "Format string for debian tags, " + "default is '%(debian-tag)s'", + 'debian-tag-msg': + "Format string for signed debian-tag messages, " + "default is '%(debian-tag-msg)s'", + 'upstream-tag': + "Format string for upstream tags, " + "default is '%(upstream-tag)s'", + 'sign-tags': + "Whether to sign tags, default is '%(sign-tags)s'", + 'keyid': + "GPG keyid to sign tags with, default is '%(keyid)s'", + 'import-msg': + "Format string for commit message used to commit " + "the upstream tarball, default is '%(import-msg)s'", + 'commit-msg': + "Format string for commit messag used to commit, " + "the changelog, default is '%(commit-msg)s'", + 'pristine-tar': + "Use pristine-tar to create orig tarball, " + "default is '%(pristine-tar)s'", + 'pristine-tar-commit': + "When generating a tarball commit it to the pristine-tar branch '%(pristine-tar-commit)s' " + "default is '%(pristine-tar-commit)s'", + 'filter-pristine-tar': + "Filter pristine-tar when filter option is used, default is '%(filter-pristine-tar)s'", + 'filter': + "Files to filter out during import (can be given multiple times), default is %(filter)s", + 'git-author': + "Use name and email from git-config for changelog trailer, default is '%(git-author)s'", + 'full': + "Include the full commit message instead of only the first line, default is '%(full)s'", + 'meta': + "Parse meta tags in commit messages, default is '%(meta)s'", + 'meta-closes': + "Meta tags for the bts close commands, default is '%(meta-closes)s'", + 'meta-closes-bugnum': + "Meta bug number format, default is '%(meta-closes-bugnum)s'", + 'ignore-new': + "Build with uncommitted changes in the source tree, default is '%(ignore-new)s'", + 'ignore-branch': + "Build although debian-branch != current branch, " + "default is '%(ignore-branch)s'", + 'overlay': + "extract orig tarball when using export-dir option, " + "default is '%(overlay)s'", + 'remote-url-pattern': + "Remote url pattern to create the repo at, " + "default is '%(remote-url-pattern)s'", + 'multimaint': + "Note multiple maintainers, default is '%(multimaint)s'", + 'multimaint-merge': + "Merge commits by maintainer, " + "default is '%(multimaint-merge)s'", + 'pbuilder': + "Invoke git-pbuilder for building, " + "default is '%(pbuilder)s'", + 'dist': + "Build for this distribution when using git-pbuilder, " + "default is '%(dist)s'", + 'arch': + "Build for this architecture when using git-pbuilder, " + "default is '%(arch)s'", + 'qemubuilder': + "Invoke git-pbuilder with qemubuilder for building, " + "default is '%(qemubuilder)s'", + 'interactive': + "Run command interactively, default is '%(interactive)s'", + 'color': + "Whether to use colored output, default is '%(color)s'", + 'color-scheme': + "Colors to use in output (when color is enabled), format " + "is ':::', e.g. " + "'cyan:34::'. Numerical values and color names are " + "accepted, empty fields indicate using the default.", + 'spawn-editor': + "Whether to spawn an editor after adding the " + "changelog entry, default is '%(spawn-editor)s'", + 'patch-numbers': + "Whether to number patch files, " + "default is %(patch-numbers)s", + 'patch-num-format': + "The format specifier for patch number prefixes, " + "default is %(patch-num-format)s", + 'renumber': + "Whether to renumber patches exported from patch queues, " + "instead of preserving the number specified in " + "'Gbp-Pq: Name' tags, default is %(renumber)s", + 'notify': + "Whether to send a desktop notification after the build, " + "default is '%(notify)s'", + 'merge': + "After the import merge the result to the debian branch, " + "default is '%(merge)s'", + 'merge-mode': + "Howto merge the new upstream sources onto the debian branch" + "default is '%(merge-mode)s'", + 'track': + "Set up tracking for remote branches, " + "default is '%(track)s'", + 'author-is-committer': + "Use the authors's name also as the committer's name, " + "default is '%(author-is-committer)s'", + 'author-date-is-committer-date': + "Use the authors's date as the committer's date, " + "default is '%(author-date-is-committer-date)s'", + 'create-missing-branches': + "Create missing branches automatically, " + "default is '%(create-missing-branches)s'", + 'submodules': + "Transparently handle submodules in the upstream tree, " + "default is '%(submodules)s'", + 'postimport': + "hook run after a successful import, " + "default is '%(postimport)s'", + 'hooks': + "Enable running all hooks, default is %(hooks)s", + 'time-machine': + "don't try head commit only to apply the patch queue " + "but look TIME_MACHINE commits back, " + "default is '%(time-machine)d'", + 'pbuilder-autoconf': + "Whether to configure pbuilder automatically, " + "default is '%(pbuilder-autoconf)s'", + 'pbuilder-options': + "Options to pass to pbuilder, " + "default is '%(pbuilder-options)s'", + 'template-dir': + "Template directory used by git init, " + "default is '%(template-dir)s'", + 'remote-config': + "Remote defintion in gbp.conf used to create the remote " + "repository, default is '%(remote-config)s'", + 'allow-unauthenticated': + "Don't verify integrity of downloaded source, " + "default is '%(allow-unauthenticated)s'", + 'symlink-orig': + "Whether to creat a symlink from the upstream tarball " + "to the orig.tar.gz if needed, default is " + "'%(symlink-orig)s'", + 'purge': + "Purge exported package build directory. Default is '%(purge)s'", + 'drop': + "In case of 'export' drop the patch-queue branch " + "after export. Default is '%(drop)s'", + 'commit': + "commit changes after export, Default is '%(commit)s'", + 'rollback': + "Rollback repository changes when encountering an error", + 'component': + 'component name for additional tarballs', + 'bare': + "wether to create a bare repository on the remote side. " + "'Default is '%(bare)s'.", + 'urgency': + "Set urgency level, default is '%(urgency)s'", + 'repo-user': + "Set repo username from the DEBFULLNAME and DEBEMAIL " + "environment variables ('DEBIAN') or fallback to the " + "git configuration ('GIT'), default is '%(repo-user)s'", + 'repo-email': + "Set repo email from the DEBFULLNAME and DEBEMAIL " + "environment variables ('DEBIAN') or fallback to the " + "git configuration ('GIT'), default is '%(repo-email)s'" + } + + short_opts = { + 'urgency': '-U', + } + + def_config_files = [('/etc/git-buildpackage/gbp.conf', 'system'), + ('~/.gbp.conf', 'global'), + ('%(top_dir)s/.gbp.conf', None), + ('%(top_dir)s/debian/gbp.conf', 'debian'), + ('%(git_dir)s/gbp.conf', None)] + + list_opts = ['filter', 'component'] @classmethod - def get_config_files(klass, no_local=False): + def get_config_files(cls, no_local=False): """ Get list of config files from the I{GBP_CONF_FILES} environment variable. @@ -346,15 +386,16 @@ @return: list of config files we need to parse @rtype: C{list} + >>> import re >>> conf_backup = os.getenv('GBP_CONF_FILES') >>> if conf_backup is not None: del os.environ['GBP_CONF_FILES'] >>> homedir = os.path.expanduser("~") >>> files = GbpOptionParser.get_config_files() - >>> files_mangled = [file.replace(homedir, 'HOME') for file in files] + >>> files_mangled = [re.sub("^%s" % homedir, 'HOME', file) for file in files] >>> sorted(files_mangled) ['%(git_dir)s/gbp.conf', '%(top_dir)s/.gbp.conf', '%(top_dir)s/debian/gbp.conf', '/etc/git-buildpackage/gbp.conf', 'HOME/.gbp.conf'] >>> files = GbpOptionParser.get_config_files(no_local=True) - >>> files_mangled = [file.replace(homedir, 'HOME') for file in files] + >>> files_mangled = [re.sub("^%s" % homedir, 'HOME', file) for file in files] >>> sorted(files_mangled) ['/etc/git-buildpackage/gbp.conf', 'HOME/.gbp.conf'] >>> os.environ['GBP_CONF_FILES'] = 'test1:test2' @@ -364,13 +405,13 @@ >>> if conf_backup is not None: os.environ['GBP_CONF_FILES'] = conf_backup """ envvar = os.environ.get('GBP_CONF_FILES') - files = envvar.split(':') if envvar else klass.def_config_files.keys() + files = envvar.split(':') if envvar else [f for (f, _) in cls.def_config_files] files = [os.path.expanduser(fname) for fname in files] if no_local: files = [fname for fname in files if fname.startswith('/')] return files - def _read_config_file(self, parser, repo, filename): + def _read_config_file(self, repo, filename): """Read config file""" str_fields = {} if repo: @@ -382,23 +423,81 @@ except KeyError: # Skip if filename wasn't expanded, i.e. we're not in git repo return - parser.read(filename) + if (repo and + filename == os.path.join(repo.path, '.gbp.conf') and + os.path.exists(filename)): + self._warn_old_gbp_conf(filename) + self.config_parser.read(filename) def _warn_old_config_section(self, oldcmd, cmd): if not os.getenv("GBP_DISABLE_SECTION_DEPRECTATION"): gbp.log.warn("Old style config section [%s] found " "please rename to [%s]" % (oldcmd, cmd)) + def _warn_old_gbp_conf(self, gbp_conf): + if (not os.getenv("GBP_DISABLE_GBP_CONF_DEPRECTATION") and + not self._warned_old_gbp_conf): + gbp.log.warn("Deprecated configuration file found at %s, " + "check gbp.conf(5) for alternatives" % gbp_conf) + self._warned_old_gbp_conf = True + + @property + def config_file_sections(self): + """List of all found config file sections""" + return self.config_parser.sections() + + @staticmethod + def _listify(value): + """ + >>> GbpOptionParser._listify(None) + [] + >>> GbpOptionParser._listify('string') + ['string'] + >>> GbpOptionParser._listify('["q", "e", "d"] ') + ['q', 'e', 'd'] + >>> GbpOptionParser._listify('[') + Traceback (most recent call last): + ... + Error: [ is not a proper list + """ + # filter can be either a list or a string, always build a list: + if value: + if value.startswith('['): + try: + return eval(value) + except SyntaxError: + raise configparser.Error("%s is not a proper list" % value) + else: + return [value] + else: + return [] + + def parse_lists(self): + """ + Parse options that can be given as lists + + Since they take multiple arguments they can also be given in plural form + e.g. components instead of component. + """ + for opt in self.list_opts: + try: + plural_opt = opt + 's' + valp = self._listify(self.config.get(plural_opt, None)) + vals = self._listify(self.config[opt]) + if valp and vals: + raise configparser.Error("Found %s and %s - use only one" % (valp, vals)) + self.config[opt] = valp or vals + except ValueError: + raise configparser.Error("Failed to parse %s: %s" % (opt, self.config[opt])) + def parse_config_files(self): """ Parse the possible config files and set appropriate values default values """ - parser = configparser.SafeConfigParser() + parser = self.config_parser # Fill in the built in values self.config = dict(self.__class__.defaults) - # Update with the values from the defaults section. This is needed - # in case the config file doesn't have a [] section at all config_files = self.get_config_files() try: repo = GitRepository(".") @@ -406,13 +505,15 @@ repo = None # Read all config files for filename in config_files: - self._read_config_file(parser, repo, filename) + self._read_config_file(repo, filename) + # Update with the values from the defaults section. This is needed + # in case the config file doesn't have a [] section at all self.config.update(dict(parser.defaults())) # Make sure we read any legacy sections prior to the real subcommands # section i.e. read [gbp-pull] prior to [pull] if (self.command.startswith('gbp-') or - self.command.startswith('git-')): + self.command.startswith('git-')): cmd = self.command[4:] oldcmd = self.command if parser.has_section(oldcmd): @@ -437,16 +538,9 @@ self.config.update(dict(parser._sections[section].items())) else: raise configparser.NoSectionError( - "Mandatory section [%s] does not exist." % section) + "Mandatory section [%s] does not exist." % section) - # filter can be either a list or a string, always build a list: - if self.config['filter']: - if self.config['filter'].startswith('['): - self.config['filter'] = eval(self.config['filter']) - else: - self.config['filter'] = [ self.config['filter'] ] - else: - self.config['filter'] = [] + self.parse_lists() def __init__(self, command, prefix='', usage=None, sections=[]): """ @@ -464,15 +558,17 @@ self.sections = sections self.prefix = prefix self.config = {} - self.parse_config_files() self.valid_options = [] + self.config_parser = configparser.SafeConfigParser() + self._warned_old_gbp_conf = False + + try: + self.parse_config_files() + except configparser.ParsingError as err: + raise GbpError(str(err) + "\nSee 'man gbp.conf' for the format.") - if self.command.startswith('git-') or self.command.startswith('gbp-'): - prog = self.command - else: - prog = "gbp %s" % self.command OptionParser.__init__(self, option_class=GbpOption, - prog=prog, + prog="gbp %s" % self.command, usage=usage, version='%s %s' % (self.command, gbp_version)) @@ -480,10 +576,10 @@ """is option_name a boolean option""" ret = False try: - if kwargs['action'] in [ 'store_true', 'store_false' ]: - ret=True + if kwargs['action'] in ['store_true', 'store_false']: + ret = True except KeyError: - ret=False + ret = False return ret def _get_bool_default(self, option_name): @@ -503,9 +599,9 @@ except KeyError: default = self.config[neg] - if default.lower() in ["true", "1" ]: + if default.lower() in ["true", "1"]: val = 'True' - elif default.lower() in ["false", "0" ]: + elif default.lower() in ["false", "0"]: val = 'False' else: raise ValueError("Boolean options must be True or False") @@ -519,7 +615,15 @@ default = self.config[option_name] return default - @safe_option + def get_opt_names(self, option_name): + names = ["--%s%s" % (self.prefix, option_name)] + if option_name in self.short_opts: + if self.prefix: + raise ValueError("Options with prefix cannot have a short option") + names.insert(0, self.short_opts[option_name]) + return names + + @save_option def add_config_file_option(self, option_name, dest, help=None, **kwargs): """ set a option for the command line parser, the default is read from the config file @@ -532,7 +636,8 @@ """ if not help: help = self.help[option_name] - OptionParser.add_option(self, "--%s%s" % (self.prefix, option_name), dest=dest, + opt_names = self.get_opt_names(option_name) + OptionParser.add_option(self, *opt_names, dest=dest, default=self.get_default(option_name, **kwargs), help=help % self.config, **kwargs) @@ -579,7 +684,7 @@ >>> GbpOptionParser._name_to_filename('debian') '%(top_dir)s/debian/gbp.conf' """ - for k, v in cls.def_config_files.items(): + for k, v in cls.def_config_files: if name == v: return k else: @@ -608,7 +713,7 @@ class GbpOptionGroup(OptionGroup): - @safe_option + @save_option def add_config_file_option(self, option_name, dest, help=None, **kwargs): """ set a option for the command line parser, the default is read from the config file @@ -621,9 +726,10 @@ """ if not help: help = self.parser.help[option_name] - OptionGroup.add_option(self, "--%s%s" % (self.parser.prefix, option_name), dest=dest, - default=self.parser.get_default(option_name, **kwargs), - help=help % self.parser.config, **kwargs) + opt_names = self.parser.get_opt_names(option_name) + OptionGroup.add_option(self, *opt_names, dest=dest, + default=self.parser.get_default(option_name, **kwargs), + help=help % self.parser.config, **kwargs) def add_boolean_config_file_option(self, option_name, dest): self.add_config_file_option(option_name=option_name, dest=dest, action="store_true") @@ -636,9 +742,13 @@ Handles commandline options and parsing of config files for Debian tools """ defaults = dict(GbpOptionParser.defaults) - defaults.update( { - 'builder' : 'debuild -i -I', - } ) + defaults.update({ + 'builder': 'debuild -i -I', + }) + + def _warn_old_gbp_conf(self, gbp_conf): + if os.path.exists("debian/control"): + GbpOptionParser._warn_old_gbp_conf(self, gbp_conf) class GbpOptionParserRpm(GbpOptionParser): @@ -647,28 +757,32 @@ """ defaults = dict(GbpOptionParser.defaults) defaults.update({ - 'tmp-dir' : '/var/tmp/gbp/', - 'vendor' : 'Downstream', - 'packaging-branch' : 'master', - 'packaging-dir' : '', - 'packaging-tag-msg' : ('%(pkg)s (vendor)s release ' - '%(version)s'), - 'packaging-tag' : 'packaging/%(version)s', - 'export-sourcedir' : 'SOURCES', - 'export-specdir' : 'SPECS', - 'export-dir' : '../rpmbuild', - 'builder' : 'rpmbuild', - 'spec-file' : '', - 'mock' : 'False', - 'dist' : '', - 'arch' : '', - 'mock-root' : '', - 'mock-options' : '', - 'native' : 'auto', - }) + 'tmp-dir': '/var/tmp/gbp/', + 'vendor': 'Downstream', + 'packaging-branch': 'master', + 'packaging-dir': '', + 'packaging-tag-msg': '%(pkg)s (vendor)s release %(version)s', + 'packaging-tag': 'packaging/%(version)s', + 'export-sourcedir': 'SOURCES', + 'export-specdir': 'SPECS', + 'export-dir': '../rpmbuild', + 'builder': 'rpmbuild', + 'spec-file': '', + 'mock': 'False', + 'dist': '', + 'arch': '', + 'mock-root': '', + 'mock-options': '', + 'native': 'auto', + 'changelog-file': 'auto', + 'changelog-revision': '', + 'spawn-editor': 'always', + 'editor-cmd': 'vim', + }) help = dict(GbpOptionParser.help) - help.update({ + help.update( + { 'tmp-dir': "Base directory under which temporary directories are " "created, default is '%(tmp-dir)s'", @@ -685,8 +799,8 @@ "Format string for packaging tags, RPM counterpart of the " "'debian-tag' option, default is '%(packaging-tag)s'", 'packaging-tag-msg': - ("Format string for packaging tag messages, " - "default is '%(packaging-tag-msg)s'"), + "Format string for packaging tag messages, " + "default is '%(packaging-tag-msg)s'", 'spec-file': "Spec file to use, causes the packaging-dir option to be " "ignored, default is '%(spec-file)s'", @@ -697,23 +811,39 @@ 'export-specdir': "Subdir (under EXPORT_DIR) where package spec file is " "exported default is '%(export-specdir)s'", - 'mock': - ("Invoke mock for building using gbp-builder-mock, " - "default is '%(mock)s'"), - 'dist': - ("Build for this distribution when using mock. E.g.: epel-6, " - "default is '%(dist)s'"), - 'arch': - ("Build for this architecture when using mock, " - "default is '%(arch)s'"), - 'mock-root': - ("The mock root (-r) name for building with mock: -, " - "default is '%(mock-root)s'"), - 'mock-options': - ("Options to pass to mock, " - "default is '%(mock-options)s'"), + 'mock': + "Invoke mock for building using gbp-builder-mock, " + "default is '%(mock)s'", + 'dist': + "Build for this distribution when using mock. E.g.: epel-6, " + "default is '%(dist)s'", + 'arch': + "Build for this architecture when using mock, " + "default is '%(arch)s'", + 'mock-root': + "The mock root (-r) name for building with mock: -, " + "default is '%(mock-root)s'", + 'mock-options': + "Options to pass to mock, " + "default is '%(mock-options)s'", 'native': "Treat this package as native, default is '%(native)s'", - }) + 'changelog-file': + "Changelog file to be used, default is '%(changelog-file)s'", + 'changelog-revision': + "Format string for the revision field in the changelog header. " + "If empty or not defined the default from packaging policy is " + "used.", + 'editor-cmd': + "Editor command to use", + 'git-author': + "Use name and email from git-config for the changelog header, " + "default is '%(git-author)s'", + }) + + def _warn_old_gbp_conf(self, gbp_conf): + # The rpm based tools use $repo/.gbp.conf a lot, don't + # warn there yet + pass # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/dch.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/dch.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/dch.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/dch.py 2017-02-11 19:33:12.000000000 +0000 @@ -20,6 +20,7 @@ MAX_CHANGELOG_LINE_LENGTH = 76 + def extract_git_dch_cmds(lines, options): """Return a dictionary of all Git-Dch: commands found in lines. The command keys will be lowercased, i.e. {'ignore' : True, @@ -45,6 +46,7 @@ else: return lines + def extract_bts_cmds(lines, opts): """Return a dictionary of the bug tracking system commands contained in the the given lines. i.e. {'closed' : [1], 'fixed': @@ -58,7 +60,7 @@ for line in lines: m = bts_rx.match(line) if m: - bug_nums = [ bug.strip() for bug in _bug_re.findall(line, re.I) ] + bug_nums = [bug.strip() for bug in _bug_re.findall(line, re.I)] try: commands[m.group('bts')] += bug_nums except KeyError: @@ -72,9 +74,10 @@ """Return a list of all of the Thanks: entries, and a list of all of the lines that do not contain Thanks: entries.""" thanks = [] + thanks_re = re.compile(r'thanks:\s+', re.I) other_lines = [] for line in lines: - if line.startswith('Thanks: '): + if thanks_re.match(line): thanks.append(line.split(' ', 1)[1].strip()) else: other_lines.append(line) @@ -113,13 +116,13 @@ entry[0] = '[%s] ' % commitid[0:options.idlen] + entry[0] bts_cmds = {} - thanks = [] + thanks = [] if options.meta: (bts_cmds, body) = extract_bts_cmds(body, options) (thanks, body) = extract_thanks_info(body, options) body = filter_ignore_rx_matches(body, options) - if 'full' in git_dch_cmds or (options.full and not 'short' in git_dch_cmds): + if 'full' in git_dch_cmds or (options.full and 'short' not in git_dch_cmds): # Add all non-blank body lines. entry.extend([line for line in body if line.strip()]) if thanks: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/changelog.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/changelog.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/changelog.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/changelog.py 2017-02-11 19:33:12.000000000 +0000 @@ -23,10 +23,12 @@ import subprocess from gbp.command_wrappers import Command + class NoChangeLogError(Exception): """No changelog found""" pass + class ParseChangeLogError(Exception): """Problem parsing changelog""" pass @@ -47,7 +49,7 @@ return self._version @classmethod - def parse(klass, section): + def parse(cls, section): """ Parse one changelog section @@ -59,7 +61,7 @@ header = section.split('\n')[0] package = header.split()[0] version = header.split()[1][1:-1] - return klass(package, version) + return cls(package, version) class ChangeLog(object): @@ -89,16 +91,21 @@ self._read() self._parse() - def _parse(self): - """Parse a changelog based on the already read contents.""" - cmd = subprocess.Popen(['dpkg-parsechangelog', '-l-'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + def _run_parsechangelog(self, options=None): + options = options if options is not None else [] + cmd = subprocess.Popen(['dpkg-parsechangelog', '-l-'] + options, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) (output, errors) = cmd.communicate(self._contents) if cmd.returncode: raise ParseChangeLogError("Failed to parse changelog. " "dpkg-parsechangelog said:\n%s" % (errors, )) + return output + + def _parse(self): + """Parse a changelog based on the already read contents.""" + output = self._run_parsechangelog() # Parse the result of dpkg-parsechangelog (which looks like # email headers) cp = email.message_from_string(output) @@ -138,8 +145,8 @@ @property def version(self): - """The full version string""" - return self._cp['Version'] + """The full version string""" + return self._cp['Version'] @property def upstream_version(self): @@ -198,7 +205,7 @@ """ section = '' for line in self._contents.split('\n'): - if line and line[0] not in [ ' ', '\t' ]: + if line and line[0] not in [' ', '\t']: section += line else: if section: @@ -308,3 +315,6 @@ """ self.spawn_dch(msg=msg, newversion=True, version=version, author=author, email=email, distribution=distribution, dch_options=dch_options) + + def get_changes(self, since='0~'): + return self._run_parsechangelog(['-v%s' % since, '-SChanges']) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/control.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/control.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/control.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/control.py 2017-02-11 19:33:12.000000000 +0000 @@ -19,14 +19,17 @@ import email import os + class NoControlError(Exception): """No control found""" pass + class ParseControlError(Exception): """Problem parsing control""" pass + class Control(object): """A Debian control""" diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/dscfile.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/dscfile.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/dscfile.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/dscfile.py 2017-02-11 19:33:12.000000000 +0000 @@ -29,16 +29,16 @@ compressions = r"(%s)" % '|'.join(DebianUpstreamSource.known_compressions()) pkg_re = re.compile(r'Source:\s+(?P.+)\s*') version_re = re.compile(r'Version:\s((?P\d+)\:)?' - '(?P[%s]+)\s*$' + '(?P[%s]+)\s*$' % DebianPkgPolicy.debianversion_chars) tar_re = re.compile(r'^\s\w+\s\d+\s+(?P[^_]+_[^_]+' - '(\.orig)?\.tar\.%s)' % compressions) + '(\.orig)?\.tar\.%s)' % compressions) add_tar_re = re.compile(r'^\s\w+\s\d+\s+(?P[^_]+_[^_]+' '\.orig-(?P[a-z0-9-]+)\.tar\.%s)' % compressions) diff_re = re.compile(r'^\s\w+\s\d+\s+(?P[^_]+_[^_]+' - '\.diff.(gz|bz2))') + '\.diff.(gz|bz2))') deb_tgz_re = re.compile(r'^\s\w+\s\d+\s+(?P[^_]+_[^_]+' - '\.debian.tar.%s)' % compressions) + '\.debian.tar.%s)' % compressions) format_re = re.compile(r'Format:\s+(?P[0-9.]+)\s*') def __init__(self, dscfile): @@ -63,7 +63,7 @@ self.upstream_version = "-".join(m.group('version').split("-")[0:-1]) self.native = False else: - self.native = True # Debian native package + self.native = True # Debian native package self.upstream_version = m.group('version') if m.group('epoch'): self.epoch = m.group('epoch') @@ -97,22 +97,30 @@ continue f.close() + # Source format 1.0 can have non-native packages without a Debian revision: + # e.g. http://snapshot.debian.org/archive/debian/20090801T192339Z/pool/main/l/latencytop/latencytop_0.5.dsc + if self.pkgformat == "1.0" and self.diff: + self.native = False + elif not self.native and not self.debian_version: + raise GbpError("Cannot parse Debian version number from '%s'" % self.dscfile) + if not self.pkg: raise GbpError("Cannot parse package name from '%s'" % self.dscfile) elif not self.tgz: raise GbpError("Cannot parse archive name from '%s'" % self.dscfile) if not self.upstream_version: raise GbpError("Cannot parse version number from '%s'" % self.dscfile) - if not self.native and not self.debian_version: - raise GbpError("Cannot parse Debian version number from '%s'" % self.dscfile) self.additional_tarballs = dict(add_tars) def _get_version(self): - version = [ "", self.epoch + ":" ][len(self.epoch) > 0] + version = ["", self.epoch + ":"][len(self.epoch) > 0] if self.native: version += self.upstream_version else: - version += "%s-%s" % (self.upstream_version, self.debian_version) + if self.debian_version != '': + version += "%s-%s" % (self.upstream_version, self.debian_version) + else: # possible in 1.0 + version += "%s" % self.upstream_version return version version = property(_get_version) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/format.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/format.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/format.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/format.py 2017-02-11 19:33:12.000000000 +0000 @@ -16,9 +16,11 @@ # """Parse debian/source/format""" + class DebianSourceFormatError(Exception): pass + class DebianSourceFormat(object): """ Contents of debian/source/format @@ -47,8 +49,7 @@ self._version = parts[0] if len(parts) == 2: - if (parts[1][0] == '(' and - parts[1][-1] == ')'): + if (parts[1][0] == '(' and parts[1][-1] == ')'): self._type = parts[1][1:-1] else: raise DebianSourceFormatError("Cannot get source format from " @@ -73,7 +74,7 @@ return "%s (%s)" % (self._version, self._type) @classmethod - def parse_file(klass, filename): + def parse_file(cls, filename): """ Parse debian/source/format file @@ -94,10 +95,10 @@ >>> os.unlink(t.name) """ with open(filename) as f: - return klass(f.read()) + return cls(f.read()) @classmethod - def from_content(klass, version, type, format_file=None): + def from_content(cls, version, type, format_file=None): """ Write a format file from I{type} and I{format} at I{format_file} @@ -107,10 +108,11 @@ @param format_file: the format file to create with the above parameters """ - format_file = format_file or klass.format_file - with open(klass.format_file, 'w') as f: + format_file = format_file or cls.format_file + with open(cls.format_file, 'w') as f: f.write("%s (%s)" % (version, type)) - return klass.parse_file(klass.format_file) + return cls.parse_file(cls.format_file) + if __name__ == "__main__": import doctest diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/git.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/git.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/git.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/git.py 2017-02-11 19:33:12.000000000 +0000 @@ -21,11 +21,19 @@ from gbp.deb.pristinetar import DebianPristineTar from gbp.format import format_str +import gbp.log + + class DebianGitRepository(GitRepository): """A git repository that holds the source of a Debian package""" - def __init__(self, path): - super(DebianGitRepository, self).__init__(path) + version_mangle_re = (r'%\(version' + '%(?P[^%])' + '%(?P([^%]|\\%))+' + '\)s') + + def __init__(self, *args, **kwargs): + super(DebianGitRepository, self).__init__(*args, **kwargs) self.pristine_tar = DebianPristineTar(self) def tree_drop_dirs(self, tree, dirs): @@ -72,7 +80,7 @@ """ tag = self.version_to_tag(format, version) legacy_tag = self._build_legacy_tag(format, version) - if self.has_tag(tag): # new tags are injective + if self.has_tag(tag): # new tags are injective # dereference to a commit object return self.rev_parse("%s^0" % tag) elif self.has_tag(legacy_tag): @@ -83,7 +91,7 @@ if line.endswith(" %s\n" % version): # dereference to a commit object return self.rev_parse("%s^0" % legacy_tag) - elif line.startswith('---'): # GPG signature start + elif line.startswith('---'): # GPG signature start return None return None @@ -124,13 +132,13 @@ >>> DebianGitRepository._build_legacy_tag('upstream/%(version)s', '1:2.0~3') 'upstream/2.0.3' """ - if ':' in version: # strip of any epochs + if ':' in version: # strip of any epochs version = version.split(':', 1)[1] version = version.replace('~', '.') return format % dict(version=version) - @staticmethod - def version_to_tag(format, version): + @classmethod + def version_to_tag(cls, format, version): """Generate a tag from a given format and a version %(version)s provides a clean version that works as a git tag. @@ -139,19 +147,69 @@ hversion is useful for upstreams with tagging policies that prohibit . characters. + %(version%A%B)s provides %(version)s with string 'A' replaced by 'B'. + This way, simple version mangling is possible via substitution. + Inside the substition string, '%' needs to be escaped. See the + examples below. + >>> DebianGitRepository.version_to_tag("debian/%(version)s", "0:0~0") 'debian/0%0_0' >>> DebianGitRepository.version_to_tag("libfoo-%(hversion)s", "1.8.1") 'libfoo-1-8-1' + >>> DebianGitRepository.version_to_tag("v%(version%.%_)s", "1.2.3") + 'v1_2_3' + >>> DebianGitRepository.version_to_tag("%(version%-%\%)s", "0-1.2.3") + '0%1.2.3' + """ + f, v = cls._mangle_version(format, version) + return format_str(f, dict(version=cls._sanitize_version(v), + hversion=cls._sanitize_version(v).replace('.', '-'))) + @classmethod + def _mangle_version(cls, format, version): """ - return format_str(format, dict(version=DebianGitRepository._sanitize_version(version), - hversion=DebianGitRepository._sanitize_version(version).replace('.','-'))) + Basic version mangling to replce single characters + + >>> DebianGitRepository._mangle_version("%(version%-%\%)s", "0-1.2.3") + ('%(version)s', '0%1.2.3') + """ + r = re.search(cls.version_mangle_re, format) + if r: + f = re.sub(cls.version_mangle_re, "%(version)s", format) + v = version.replace(r.group('M'), r.group('R').replace('\%', '%')) + return f, v + else: + return format, version + + @classmethod + def _unmangle_format(cls, format): + """ + Reverse of _mangle_version for format + """ + r = re.search(cls.version_mangle_re, format) + if r: + return re.sub(cls.version_mangle_re, "%(version)s", format) + else: + return format + + @classmethod + def _unmangle_version(cls, format, tag): + """ + Reverse of _mangle_version for version + """ + r = re.search(cls.version_mangle_re, format) + if r: + v = tag.replace(r.group('R').replace('\%', '%'), r.group('M')) + return v + else: + return tag @staticmethod def _sanitize_version(version): """sanitize a version so git accepts it as a tag + as descirbed in DEP14 + >>> DebianGitRepository._sanitize_version("0.0.0") '0.0.0' >>> DebianGitRepository._sanitize_version("0.0~0") @@ -160,25 +218,47 @@ '0%0.0' >>> DebianGitRepository._sanitize_version("0%0~0") '0%0_0' + >>> DebianGitRepository._sanitize_version("0....0") + '0.#.#.#.0' + >>> DebianGitRepository._sanitize_version("0.lock") + '0.#lock' """ - return version.replace('~', '_').replace(':', '%') + v = re.sub('\.(?=\.|$|lock$)', '.#', version) + return v.replace('~', '_').replace(':', '%') @staticmethod - def tag_to_version(tag, format): + def _unsanitize_version(tag): + """Reverse _sanitize_version + + as descirbed in DEP14 + + >>> DebianGitRepository._unsanitize_version("1%0_bpo3") + '1:0~bpo3' + >>> DebianGitRepository._unsanitize_version("1%0_bpo3.#.") + '1:0~bpo3..' + """ + return tag.replace('_', '~').replace('%', ':').replace('#', '') + + @classmethod + def tag_to_version(cls, tag, format): """Extract the version from a tag >>> DebianGitRepository.tag_to_version("upstream/1%2_3-4", "upstream/%(version)s") '1:2~3-4' >>> DebianGitRepository.tag_to_version("foo/2.3.4", "foo/%(version)s") '2.3.4' + >>> DebianGitRepository.tag_to_version("v1-2-3", "v%(version%.%-)s") + '1.2.3' + >>> DebianGitRepository.tag_to_version("v1.#.2", "v%(version%.%-)s") + '1..2' >>> DebianGitRepository.tag_to_version("foo/2.3.4", "upstream/%(version)s") """ - version_re = format.replace('%(version)s', - '(?P[\w_%+-.]+)') + f = cls._unmangle_format(format) + version_re = f.replace('%(version)s', '(?P[\w_%+-.#]+)') r = re.match(version_re, tag) if r: - version = r.group('version').replace('_', '~').replace('%', ':') - return version + v = cls._unsanitize_version(r.group('version')) + return cls._unmangle_version(format, v) return None @property @@ -191,7 +271,7 @@ def has_pristine_tar_branch(self): """ - Wheter the repo has a I{pristine-tar} branch. + Whether the repo has a I{pristine-tar} branch. @return: C{True} if the repo has pristine-tar commits already, C{False} otherwise @@ -199,4 +279,25 @@ """ return True if self.has_branch(self.pristine_tar_branch) else False + def create_pristinetar_commits(self, upstream_tree, tarball, component_tarballs): + """ + Create pristine-tar commits for a package with main tarball tarball + and (optionl) component tarballs based on upstream_tree + + @param tarball: path to main tarball + @param component_tarballs: C{list} of C{tuple}s of component + name and path to additional tarball + @param upstream_tree: the treeish in the git repo to create the commits against + """ + components = [c for (c, t) in component_tarballs] + main_tree = self.tree_drop_dirs(upstream_tree, components) + + for component, name in component_tarballs: + subtree = self.tree_get_dir(upstream_tree, component) + if not subtree: + raise GitRepositoryError("No tree for '%s' found in '%s' to create pristine tar commit from" % (component, upstream_tree)) + gbp.log.debug("Creating pristine tar commit '%s' from '%s'" % (component, subtree)) + self.pristine_tar.commit(name, subtree) + self.pristine_tar.commit(tarball, main_tree) + # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/__init__.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -27,6 +27,7 @@ from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.deb.policy import DebianPkgPolicy + class DpkgCompareVersions(gbpc.Command): dpkg = '/usr/bin/dpkg' @@ -43,16 +44,16 @@ @raises CommandExecFailed: if the version comparison fails """ self.run_error = "Couldn't compare %s with %s" % (version1, version2) - res = self.call([ version1, 'lt', version2 ]) - if res not in [ 0, 1 ]: + res = self.call([version1, 'lt', version2]) + if res not in [0, 1]: if self.stderr: self.run_error += ' (%s)' % self.stderr raise gbpc.CommandExecFailed("%s: bad return code %d" % (self.run_error, res)) if res == 0: return -1 elif res == 1: - res = self.call([ version1, 'gt', version2 ]) - if res not in [ 0, 1 ]: + res = self.call([version1, 'gt', version2]) + if res not in [0, 1]: if self.stderr: self.run_error += ' (%s)' % self.stderr raise gbpc.CommandExecFailed("%s: bad return code %d" % (self.run_error, res)) @@ -80,7 +81,7 @@ return ChangeLog(repo.show(sha)) -def orig_file(cp, compression, subtarball=None): +def orig_file(cp, compression, component=None): """ The name of the orig file belonging to changelog cp @@ -88,13 +89,13 @@ 'foo_1.0.orig.tar.bz2' >>> orig_file({'Source': 'bar', 'Upstream-Version': '0.0~git1234'}, "xz") 'bar_0.0~git1234.orig.tar.xz' - >>> orig_file({'Source': 'bar', 'Upstream-Version': '0.0~git1234'}, "xz", subtarball="sub1") + >>> orig_file({'Source': 'bar', 'Upstream-Version': '0.0~git1234'}, "xz", component="sub1") 'bar_0.0~git1234.orig-sub1.tar.xz' """ return DebianPkgPolicy.build_tarball_name(cp['Source'], cp['Upstream-Version'], compression, - subtarball=subtarball) + component=component) def get_arch(): diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/policy.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/policy.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/policy.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/policy.py 2017-02-11 19:33:12.000000000 +0000 @@ -62,7 +62,7 @@ debianversion_chars = 'a-zA-Z\\d.~+-' @staticmethod - def build_tarball_name(name, version, compression, dir=None, subtarball=None): + def build_tarball_name(name, version, compression, dir=None, component=None): """ Given a source package's I{name}, I{version} and I{compression} return the name of the corresponding upstream tarball. @@ -71,7 +71,7 @@ 'foo_1.0.orig.tar.bz2' >>> DebianPkgPolicy.build_tarball_name('bar', '0.0~git1234', 'xz') 'bar_0.0~git1234.orig.tar.xz' - >>> DebianPkgPolicy.build_tarball_name('bar', '0.0~git1234', 'xz', subtarball="foo") + >>> DebianPkgPolicy.build_tarball_name('bar', '0.0~git1234', 'xz', component="foo") 'bar_0.0~git1234.orig-foo.tar.xz' @param name: the source package's name @@ -86,7 +86,7 @@ @rtype: C{str} """ ext = compressor_opts[compression][1] - sub = '-{0}'.format(subtarball) if subtarball else '' + sub = '-{0}'.format(component) if component else '' tarball = "%s_%s.orig%s.tar.%s" % (name, version, sub, ext) if dir: tarball = os.path.join(dir, tarball) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/pristinetar.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/pristinetar.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/pristinetar.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/pristinetar.py 2017-02-11 19:33:12.000000000 +0000 @@ -20,6 +20,7 @@ from gbp.pkg.pristinetar import PristineTar from gbp.deb import DebianPkgPolicy + class DebianPristineTar(PristineTar): """The pristine-tar branch in a Debian git repository""" def has_commit(self, package, version, comp_type=None): @@ -43,7 +44,7 @@ return super(DebianPristineTar, self).has_commit(name_regexp) - def checkout(self, package, version, comp_type, output_dir, subtarball=None): + def checkout(self, package, version, comp_type, output_dir, component=None): """ Checkout the orig tarball for package I{package} of I{version} and compression type I{comp_type} to I{output_dir} @@ -61,6 +62,5 @@ version, comp_type, output_dir, - subtarball=subtarball) + component=component) super(DebianPristineTar, self).checkout(name) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/source.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/source.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/source.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/source.py 2017-02-11 19:33:12.000000000 +0000 @@ -22,10 +22,11 @@ import six + class FileVfs(object): def __init__(self, dir): """ - Access files in a unpaced Debian source package. + Access files in an unpacked Debian source package. @param dir: the toplevel of the source tree @type dir: C{str} @@ -36,9 +37,11 @@ flags = flags or 'r' return open(os.path.join(self._dir, path), flags) + class DebianSourceError(Exception): pass + class DebianSource(object): """ A debianized source tree @@ -63,15 +66,15 @@ Whether this is a native Debian package """ try: - ff = self._vfs.open('debian/source/format') - f = DebianSourceFormat(ff.read()) + with self._vfs.open('debian/source/format') as ff: + f = DebianSourceFormat(ff.read()) if f.type: return f.type == 'native' except IOError as e: - pass # Fall back to changelog parsing + pass # Fall back to changelog parsing try: - return not '-' in self.changelog.version + return '-' not in self.changelog.version except IOError as e: raise DebianSourceError("Failed to determine source format: %s" % e) @@ -82,8 +85,8 @@ """ if not self._changelog: try: - clf = self._vfs.open('debian/changelog') - self._changelog = ChangeLog(clf.read()) + with self._vfs.open('debian/changelog') as clf: + self._changelog = ChangeLog(clf.read()) except IOError as err: raise DebianSourceError('Failed to read changelog: %s' % err) return self._changelog diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/upstreamsource.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/upstreamsource.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/upstreamsource.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/upstreamsource.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,7 @@ # vim: set fileencoding=utf-8 : # # (C) 2013 Intel Corporation +# (C) 2016 Guido Guenther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -18,6 +19,11 @@ from gbp.pkg import UpstreamSource from gbp.deb.policy import DebianPkgPolicy +import gbp.command_wrappers + +import os +import shutil +import tempfile class DebianUpstreamSource(UpstreamSource): @@ -26,3 +32,25 @@ super(DebianUpstreamSource, self).__init__(name, unpacked, DebianPkgPolicy) + + +def unpack_component_tarball(dest, component, tarball, filters): + """ + Unpack the tarball I{tarball} into dest naming it I{component}. + Apply filters during unpack. + """ + olddir = os.path.abspath(os.path.curdir) + tmpdir = None + try: + tmpdir = os.path.abspath(tempfile.mkdtemp(dir=os.path.join(dest, '..'))) + source = DebianUpstreamSource(tarball) + source.unpack(tmpdir, filters) + + newdest = os.path.join(dest, component) + if os.path.exists(newdest): + shutil.rmtree(newdest) + shutil.move(source.unpacked, newdest) + finally: + os.chdir(olddir) + if tmpdir is not None: + gbp.command_wrappers.RemoveTree(tmpdir)() diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/uscan.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/uscan.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/deb/uscan.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/deb/uscan.py 2017-02-11 19:33:12.000000000 +0000 @@ -16,11 +16,15 @@ # """Interface to uscan""" -import os, re, subprocess +import os +import re +import subprocess + class UscanError(Exception): pass + class Uscan(object): cmd = '/usr/bin/uscan' @@ -84,7 +88,7 @@ for n in ('package', 'upstream-version', 'upstream-url'): - m = re.match("<%s>(.*)" % (n,n), row) + m = re.match("<%s>(.*)" % (n, n), row) if m: d[n] = m.group(1) d["ext"] = os.path.splitext(d['upstream-url'])[1] @@ -94,10 +98,10 @@ # Fall back to the upstream source name otherwise if not os.path.exists(source): - source = "../%s" % d['upstream-url'].rsplit('/',1)[1] + source = "../%s" % d['upstream-url'].rsplit('/', 1)[1] if not os.path.exists(source): raise UscanError("Couldn't find tarball at '%s'" % - source) + source) except KeyError as e: raise UscanError("Couldn't find '%s' in uscan output" % e.args[0]) @@ -157,7 +161,7 @@ msg = None for n in ('errors', 'warnings'): - m = re.search("<%s>(.*)" % (n,n), out, re.DOTALL) + m = re.search("<%s>(.*)" % (n, n), out, re.DOTALL) if m: msg = "Uscan failed: %s" % m.group(1) break @@ -166,7 +170,6 @@ msg = "Uscan failed - debug by running 'uscan --verbose'" raise UscanError(msg) - def scan(self, destdir='..'): """Invoke uscan to fetch a new upstream version""" p = subprocess.Popen(['uscan', '--symlink', '--destdir=%s' % destdir, @@ -174,7 +177,7 @@ cwd=self._dir, stdout=subprocess.PIPE) out = p.communicate()[0] - # uscan exits with 1 in case of uptodate and when an error occured. + # uscan exits with 1 in case of uptodate and when an error occurred. # Don't fail in the uptodate case: self._parse_uptodate(out) if not self.uptodate: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/errors.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/errors.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/errors.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/errors.py 2017-02-11 19:33:12.000000000 +0000 @@ -16,6 +16,7 @@ # """Errors raised in gbp commands""" + class GbpError(Exception): """Generic exception raised in git-buildpackage commands""" pass diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/format.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/format.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/format.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/format.py 2017-02-11 19:33:12.000000000 +0000 @@ -18,6 +18,7 @@ from gbp.errors import GbpError + def format_str(msg, args): """ Format a string with the given dict. Be a bit more verbose than @@ -41,5 +42,3 @@ except KeyError as e: raise GbpError("Failed to format %s: Missing value %s in %s" % (msg, e, args)) - - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/args.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/args.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/args.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/args.py 2017-02-11 19:33:12.000000000 +0000 @@ -21,6 +21,7 @@ import six import collections + class GitArgs(object): """ Handle arguments to git commands @@ -106,4 +107,3 @@ else: self.add(noopt) return self - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/commit.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/commit.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/commit.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/commit.py 2017-02-11 19:33:12.000000000 +0000 @@ -18,7 +18,6 @@ import re -from gbp.git.errors import GitError class GitCommit(object): """A git commit""" @@ -44,5 +43,3 @@ @rtype: C{bool} """ return True if GitCommit.sha1_re.match(value) else False - - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/errors.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/errors.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/errors.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/errors.py 2017-02-11 19:33:12.000000000 +0000 @@ -16,7 +16,7 @@ # """Git base error exception""" + class GitError(Exception): """Exception thrown by Git related classes""" pass - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/fastimport.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/fastimport.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/fastimport.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/fastimport.py 2017-02-11 19:33:12.000000000 +0000 @@ -21,12 +21,13 @@ import time from gbp.errors import GbpError + class FastImport(object): """Add data to a git repository using I{git fast-import}""" _bufsize = 1024 m_regular = 644 - m_exec = 755 + m_exec = 755 m_symlink = 120000 def __init__(self, repo): @@ -36,7 +37,7 @@ """ self._repo = repo try: - self._fi = subprocess.Popen([ 'git', 'fast-import', '--quiet'], + self._fi = subprocess.Popen(['git', 'fast-import', '--quiet'], stdin=subprocess.PIPE, cwd=repo.path) self._out = self._fi.stdin except OSError as err: @@ -112,14 +113,14 @@ committer %(name)s <%(email)s> %(time)s data %(length)s %(msg)s%(from)s""" % - { 'branch': branch, - 'name': committer.name, - 'email': committer.email, - 'time': committer.date, - 'length': length, - 'msg': msg, - 'from': from_, - }) + {'branch': branch, + 'name': committer.name, + 'email': committer.email, + 'time': committer.date, + 'length': length, + 'msg': msg, + 'from': from_, + }) def deleteall(self): """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/__init__.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -19,13 +19,14 @@ import calendar import dateutil.parser -from gbp.git.modifier import GitModifier -from gbp.git.commit import GitCommit -from gbp.git.errors import GitError -from gbp.git.repository import GitRepository, GitRepositoryError -from gbp.git.fastimport import FastImport -from gbp.git.args import GitArgs -from gbp.git.vfs import GitVfs +from gbp.git.modifier import GitModifier # noqa: F401 +from gbp.git.commit import GitCommit # noqa: F401 +from gbp.git.errors import GitError # noqa: F401 +from gbp.git.repository import ( # noqa: F401 + GitRepository, GitRepositoryError) +from gbp.git.fastimport import FastImport # noqa: F401 +from gbp.git.args import GitArgs # noqa: F401 +from gbp.git.vfs import GitVfs # noqa: F401 def rfc822_date_to_git(rfc822_date): diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/modifier.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/modifier.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/modifier.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/modifier.py 2017-02-11 19:33:12.000000000 +0000 @@ -21,14 +21,17 @@ """ import six -import calendar, datetime +import calendar +import datetime from gbp.git.errors import GitError + class GitModifierError(GitError): """Exception thrown by L{GitModifier}""" pass + class GitTz(datetime.tzinfo): """Simple class to store the utc offset only""" def __init__(self, offset_sec=0, *args, **kwargs): @@ -41,6 +44,7 @@ def dst(self, dt): return datetime.timedelta(0) + class GitModifier(object): """Stores authorship/committer information""" def __init__(self, name=None, email=None, date=None): @@ -64,16 +68,16 @@ timestamp, offset = date.split() offset_h = int(offset[:-2]) offset_m = int(offset[-2:]) - tz = GitTz(offset_h*3600 + offset_m*60) + tz = GitTz(offset_h * 3600 + offset_m * 60) self._date = datetime.datetime.fromtimestamp(int(timestamp), tz) - elif type(date) in [ type(0), type(0.0) ]: + elif type(date) in [type(0), type(0.0)]: self._date = datetime.datetime.fromtimestamp(date, tz) elif isinstance(date, datetime.datetime): if date.tzinfo: self._date = date else: self._date = date.replace(tzinfo=tz) - elif date != None: + elif date is not None: raise ValueError("Date '%s' not timestamp, " "datetime object or git raw date" % date) @@ -141,7 +145,7 @@ >>> g.get_committer_env()['GIT_COMMITTER_NAME'] 'Joey Ramone' - @return: Commiter information suitable to use as environment variables + @return: Committer information suitable to use as environment variables @rtype: C{dict} """ return self._get_env('committer') @@ -154,7 +158,7 @@ @staticmethod def keys(): - return [ 'name', 'email', 'date' ] + return ['name', 'email', 'date'] def items(self): items = [] diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/repository.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/repository.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/repository.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/repository.py 2017-02-11 19:33:12.000000000 +0000 @@ -85,21 +85,48 @@ raise GitRepositoryError( "Failed to get repository state at '%s'" % self.path) self._bare = False if out.strip() != 'true' else True - self._git_dir = '' if self._bare else '.git' - def __init__(self, path): - self._path = os.path.abspath(path) - self._bare = False + def _get_git_dir(self): + out, dummy, ret = self._git_inout('rev-parse', ['--git-dir'], + capture_stderr=True) + if ret: + raise GitRepositoryError( + "Failed to determine repos git-dir at '%s'" % self.path) + git_dir = out.strip() + if os.path.isabs(git_dir): + self._git_dir = git_dir + else: + self._git_dir = os.path.abspath(os.path.join(self.path, git_dir)) + + def _check_repo(self, path, toplevel): try: out, dummy, ret = self._git_inout('rev-parse', ['--show-cdup'], + cwd=path, capture_stderr=True) - if ret or out.strip(): - raise GitRepositoryError("No Git repository at '%s': '%s'" % (self.path, out)) + cdup = out.strip() + if ret: + raise GitRepositoryError("No Git repository at '%s': '%s'" % (path, cdup)) + if toplevel and cdup: + raise GitRepositoryError("Not the toplevel of a Git repository at '%s': '%s'" % (path, cdup)) + ret = os.path.abspath(os.path.join(path, cdup or '.')) except GitRepositoryError: - raise # We already have a useful error message + raise # We already have a useful error message except: - raise GitRepositoryError("No Git repository at '%s'" % self.path) + raise GitRepositoryError("No Git repository at '%s'" % path) + return ret + + def __init__(self, path, toplevel=True): + """ + @param path: path to git repo (or subdir) + @type path: C{str} + @param toplevel: whether path points to the toplevel dir of + git repository + @type toplevel: C{bool} + """ + self._bare = False + self._path = self._check_repo(path, toplevel) self._check_bare() + self._get_git_dir() @staticmethod def __build_env(extra_env): @@ -120,7 +147,7 @@ @type args: C{list} @param extra_env: extra environment variables to pass @type extra_env: C{dict} - @param cwd: directory to swith to when running the command, defaults to I{self.path} + @param cwd: directory to switch to when running the command, defaults to I{self.path} @type cwd: C{str} @return: stdout, return code @rtype: C{tuple} of C{list} of C{str} and C{int} @@ -136,13 +163,13 @@ cmd = ['git', command] + args log.debug(cmd) popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env, cwd=cwd) - while popen.poll() == None: + while popen.poll() is None: output += popen.stdout.readlines() output += popen.stdout.readlines() return output, popen.returncode def _git_inout(self, command, args, input=None, extra_env=None, cwd=None, - capture_stderr=False): + capture_stderr=False, config_args=None): """ Run a git command with input and return output @@ -154,6 +181,8 @@ @type args: C{list} @param extra_env: extra environment variables to pass @type extra_env: C{dict} + @param cwd: directory to switch to when running the command, defaults to I{self.path} + @type cwd: C{str} @param capture_stderr: whether to capture stderr @type capture_stderr: C{bool} @return: stdout, stderr, return code @@ -161,17 +190,22 @@ """ if not cwd: cwd = self.path - return self.__git_inout(command, args, input, extra_env, cwd, capture_stderr) + return self.__git_inout(command, args, input, extra_env, cwd, capture_stderr, config_args) @classmethod - def __git_inout(cls, command, args, input, extra_env, cwd, capture_stderr): + def __git_inout(cls, command, args, input, extra_env, cwd, capture_stderr, config_args=None): """ As _git_inout but can be used without an instance """ - cmd = ['git', command] + args + config_opts = [] + config_args = config_args or [] + for arg in config_args: + config_opts.extend(['-c', arg]) + + cmd = ['git'] + config_opts + [command] + args env = cls.__build_env(extra_env) stderr_arg = subprocess.PIPE if capture_stderr else None - stdin_arg = subprocess.PIPE if input else None + stdin_arg = subprocess.PIPE if input is not None else None log.debug(cmd) popen = subprocess.Popen(cmd, @@ -207,7 +241,6 @@ if ret: raise GitRepositoryError("Error running git %s: %s" % (command, stderr)) - def _cmd_has_feature(self, command, feature): """ Check if the git command has certain feature enabled. @@ -221,9 +254,9 @@ """ args = GitArgs(command, '-m') help, stderr, ret = self._git_inout('help', - args.args, - extra_env={'LC_ALL': 'C'}, - capture_stderr=True) + args.args, + extra_env={'LC_ALL': 'C'}, + capture_stderr=True) if ret: raise GitRepositoryError("Invalid git command '%s': %s" % (command, stderr[:-1])) @@ -264,7 +297,7 @@ @property def bare(self): - """Wheter this is a bare repository""" + """Whether this is a bare repository""" return self._bare @property @@ -320,6 +353,9 @@ @param remote: delete a remote branch @param remote: C{bool} """ + if not self.has_branch(branch): + return + args = GitArgs('-D') args.add_true(remote, '-r') args.add(branch) @@ -338,8 +374,8 @@ @raises GitRepositoryError: if HEAD is not a symbolic ref (e.g. when in detached HEAD state) """ - out, dummy, ret = self._git_inout('symbolic-ref', [ 'HEAD' ], - capture_stderr=True) + out, dummy, ret = self._git_inout('symbolic-ref', ['HEAD'], + capture_stderr=True) if ret: # We don't append stderr since # "fatal: ref HEAD is not a symbolic ref" confuses people @@ -348,13 +384,12 @@ # Check if ref really exists try: - self._git_command('show-ref', [ ref ]) - branch = ref[11:] # strip /refs/heads + self._git_command('show-ref', [ref]) + branch = ref[11:] # strip /refs/heads except GitRepositoryError: branch = None # empty repo return branch - def has_branch(self, branch, remote=False): """ Check if the repository has branch named I{branch}. @@ -370,7 +405,7 @@ else: ref = 'refs/heads/%s' % branch try: - self._git_command('show-ref', [ ref ]) + self._git_command('show-ref', [ref]) except GitRepositoryError: return False return True @@ -387,9 +422,9 @@ if self.bare: self._git_command("symbolic-ref", - [ 'HEAD', 'refs/heads/%s' % branch ]) + ['HEAD', 'refs/heads/%s' % branch]) else: - self._git_command("checkout", [ branch ]) + self._git_command("checkout", [branch]) def get_merge_branch(self, branch): """ @@ -403,7 +438,7 @@ merge = self.get_config("branch.%s.merge" % branch) except KeyError: return None - remote += merge.replace("refs/heads","", 1) + remote += merge.replace("refs/heads", "", 1) return remote def get_merge_base(self, commit1, commit2): @@ -437,7 +472,7 @@ @type commit: C{str} @param verbose: whether to print a summary after the merge @type verbose: C{bool} - @param edit: wheter to invoke an editor to edit the merge message + @param edit: whether to invoke an editor to edit the merge message @type edit: C{bool} """ args = GitArgs() @@ -450,6 +485,12 @@ args.add(commit) self._git_command("merge", args.args) + def abort_merge(self): + """ + Abort a merge + """ + self._git_command("merge", ["--abort"]) + def is_fast_forward(self, from_branch, to_branch): """ Check if an update I{from from_branch} to I{to_branch} would be a fast @@ -460,11 +501,12 @@ """ has_local = False # local repo has new commits has_remote = False # remote repo has new commits - out = self._git_getoutput('rev-list', ["--left-right", + out = self._git_getoutput('rev-list', + ["--left-right", "%s...%s" % (from_branch, to_branch), "--"])[0] - if not out: # both branches have the same commits + if not out: # both branches have the same commits return True, True for line in out: @@ -489,10 +531,10 @@ @return: local or remote branches @rtype: C{list} """ - args = [ '--format=%(refname:short)' ] - args += [ 'refs/remotes/' ] if remote else [ 'refs/heads/' ] + args = ['--format=%(refname:short)'] + args += ['refs/remotes/'] if remote else ['refs/heads/'] out = self._git_getoutput('for-each-ref', args)[0] - return [ ref.strip() for ref in out ] + return [ref.strip() for ref in out] def get_local_branches(self): """ @@ -503,7 +545,6 @@ """ return self._get_branches(remote=False) - def get_remote_branches(self): """ Get a list of remote branches @@ -527,12 +568,11 @@ @param msg: the reason for the update @type msg: C{str} """ - args = [ ref, new ] - if old: - args += [ old ] - if msg: - args = [ '-m', msg ] + args - self._git_command("update-ref", args) + args = GitArgs() + args.add_true(msg, '-m', msg) + args.add(ref, new) + args.add_true(old, old) + self._git_command("update-ref", args.args) def branch_contains(self, branch, commit, remote=False): """ @@ -550,7 +590,7 @@ args.add('--contains') args.add(commit) - out, ret = self._git_getoutput('branch', args.args) + out, ret = self._git_getoutput('branch', args.args) for line in out: # remove prefix '*' for current branch before comparing line = line.replace('*', '') @@ -626,12 +666,12 @@ @type keyid: C{str} """ args = [] - args += [ '-m', msg ] if msg else [] + args += ['-m', msg] if msg else [] if sign: - args += [ '-s' ] - args += [ '-u', keyid ] if keyid else [] - args += [ name ] - args += [ commit ] if commit else [] + args += ['-s'] + args += ['-u', keyid] if keyid else [] + args += [name] + args += [commit] if commit else [] self._git_command("tag", args) def delete_tag(self, tag): @@ -642,10 +682,10 @@ @type tag: C{str} """ if self.has_tag(tag): - self._git_command("tag", [ "-d", tag ]) + self._git_command("tag", ["-d", tag]) def move_tag(self, old, new): - self._git_command("tag", [ new, old ]) + self._git_command("tag", [new, old]) self.delete_tag(old) def has_tag(self, tag): @@ -657,8 +697,8 @@ @return: C{True} if the repository has that tag, C{False} otherwise @rtype: C{bool} """ - out, ret = self._git_getoutput('tag', [ '-l', tag ]) - return [ False, True ][len(out)] + out, ret = self._git_getoutput('tag', ['-l', tag]) + return [False, True][len(out)] def describe(self, commitish, pattern=None, longfmt=False, always=False, abbrev=None, tags=False, exact_match=False): @@ -684,7 +724,7 @@ @rtype: C{str} """ args = GitArgs() - args.add_true(pattern, ['--match' , pattern]) + args.add_true(pattern, ['--match', pattern]) args.add_true(longfmt, '--long') # 'long' and 'abbrev=0' are incompatible, behave similar to # 'always' and 'abbrev=0' @@ -742,8 +782,8 @@ @return: tags @rtype: C{list} of C{str} """ - args = [ '-l', pattern ] if pattern else [] - return [ line.strip() for line in self._git_getoutput('tag', args)[0] ] + args = ['-l', pattern] if pattern else [] + return [line.strip() for line in self._git_getoutput('tag', args)[0]] def verify_tag(self, tag): """ @@ -776,33 +816,40 @@ if self.bare: ref = "refs/heads/%s" % self.get_branch() - self._git_command("update-ref", [ ref, commit ]) + self._git_command("update-ref", [ref, commit]) else: args = ['--quiet'] if hard: - args += [ '--hard' ] - args += [ commit, '--' ] + args += ['--hard'] + args += [commit, '--'] self._git_command("reset", args) - def _status(self, porcelain, ignore_untracked): + def _status(self, porcelain, ignore_untracked, paths): args = GitArgs() args.add_true(ignore_untracked, '-uno') args.add_true(porcelain, '--porcelain') + if paths is None: + paths = [] + elif isinstance(paths, six.string_types): + paths = [paths] + out, ret = self._git_getoutput('status', - args.args, + args.args + paths, extra_env={'LC_ALL': 'C'}) if ret: raise GitRepositoryError("Can't get repository status") return out - def is_clean(self, ignore_untracked=False): + def is_clean(self, ignore_untracked=False, paths=None): """ Does the repository contain any uncommitted modifications? @param ignore_untracked: whether to ignore untracked files when checking the repository status @type ignore_untracked: C{bool} + @param paths: only check changes on paths + @type paths: C{list} of C{stings} @return: C{True} if the repository is clean, C{False} otherwise and Git's status message @rtype: C{tuple} @@ -811,11 +858,13 @@ return (True, '') out = self._status(porcelain=True, - ignore_untracked=ignore_untracked) + ignore_untracked=ignore_untracked, + paths=paths) if out: # Get a more helpful error message. out = self._status(porcelain=False, - ignore_untracked=ignore_untracked) + ignore_untracked=ignore_untracked, + paths=paths) return (False, "".join(out)) else: return (True, '') @@ -883,7 +932,7 @@ @rtype: C{bool} """ # an empty repo has no branches: - return False if self.branch else True + return len(self.get_local_branches()) == 0 def rev_parse(self, name, short=0): """ @@ -954,9 +1003,9 @@ @return: C{True} if the repository has that tree, C{False} otherwise @rtype: C{bool} """ - _out, _err, ret = self._git_inout('ls-tree', [treeish], - capture_stderr=True) - return [ True, False ][ret != 0] + _out, _err, ret = self._git_inout('ls-tree', [treeish], + capture_stderr=True) + return [True, False][ret != 0] def write_tree(self, index_file=None): """ @@ -968,7 +1017,7 @@ @rtype: C{str} """ if index_file: - extra_env = {'GIT_INDEX_FILE': index_file } + extra_env = {'GIT_INDEX_FILE': index_file} else: extra_env = None @@ -981,20 +1030,21 @@ def make_tree(self, contents): """ - Create a tree based on contents. I{contents} has the same format than - the I{GitRepository.list_tree} output. + Create a tree based on contents. + + @param contents: same format as I{GitRepository.list_tree} output. + @type contents: C{list} of C{str} """ - out='' + objs = '' args = GitArgs('-z') - for obj in contents: - mode, type, sha1, name = obj - out += '%s %s %s\t%s\0' % (mode, type, sha1, name) - - sha1, err, ret = self._git_inout('mktree', - args.args, - out, - capture_stderr=True) + for mode, type, sha1, name in contents: + objs += '%s %s %s\t%s\0' % (mode, type, sha1, name) + + sha1, err, ret = self._git_inout('mktree', + args.args, + objs, + capture_stderr=True) if ret: raise GitRepositoryError("Failed to mktree: '%s'" % err) return self.strip_sha1(sha1) @@ -1016,7 +1066,7 @@ def list_tree(self, treeish, recurse=False, paths=None): """ Get a trees content. It returns a list of objects that match the - 'ls-tree' output: [ mode, type, sha1, path ]. + 'ls-tree' output: [mode, type, sha1, path]. @param treeish: the treeish object to list @type treeish: C{str} @@ -1031,7 +1081,7 @@ args.add("--") args.add_cond(paths, paths) - out, err, ret = self._git_inout('ls-tree', args.args, capture_stderr=True) + out, err, ret = self._git_inout('ls-tree', args.args, capture_stderr=True) if ret: raise GitRepositoryError("Failed to ls-tree '%s': '%s'" % (treeish, err)) @@ -1051,9 +1101,28 @@ @return: fetched config value @rtype: C{str} """ - value, ret = self._git_getoutput('config', [ name ]) - if ret: raise KeyError - return value[0][:-1] # first line with \n ending removed + value, ret = self._git_getoutput('config', [name]) + if ret: + raise KeyError + return value[0][:-1] # first line with \n ending removed + + def set_user_name(self, name): + """ + Sets the full name to use for git commits. + + @param name: full name to use + """ + args = GitArgs('user.name', name) + self._git_command("config", args.args) + + def set_user_email(self, email): + """ + Sets the email address to use for git commits. + + @param email: email address to use + """ + args = GitArgs('user.email', email) + self._git_command("config", args.args) def get_author_info(self): """ @@ -1064,11 +1133,11 @@ @rtype: L{GitModifier} """ try: - name = self.get_config("user.name") + name = self.get_config("user.name") except KeyError: - name = os.getenv("USER") + name = os.getenv("USER") try: - email = self.get_config("user.email") + email = self.get_config("user.email") except KeyError: email = os.getenv("EMAIL") email = os.getenv("GIT_AUTHOR_EMAIL", email) @@ -1122,7 +1191,7 @@ @rtype: C{list} of C{str} """ out = self._git_getoutput('remote')[0] - return [ remote.strip() for remote in out ] + return [remote.strip() for remote in out] def has_remote_repo(self, name): """ @@ -1208,7 +1277,7 @@ self._git_command("pull", args.args) def push(self, repo=None, src=None, dst=None, ff_only=True, force=False, - tags=False): + tags=False, dry_run=False): """ Push changes to the remote repo @@ -1225,14 +1294,17 @@ @type force: C{bool} @param tags: push all refs under refs/tags, in addition to other refs @type tags: C{bool} + @param dry_run: dry run + @type dry_run: C{bool} """ args = GitArgs() args.add_cond(repo, repo) args.add_true(force, "-f") args.add_true(tags, "--tags") + args.add_true(dry_run, "--dry-run") # Allow for src == '' to delete dst on the remote - if src != None: + if src is not None: refspec = src if dst: refspec += ':%s' % dst @@ -1242,7 +1314,7 @@ self._git_command("push", args.args) - def push_tag(self, repo, tag): + def push_tag(self, repo, tag, dry_run=False): """ Push a tag to the remote repo @@ -1250,8 +1322,11 @@ @type repo: C{str} @param tag: the name of the tag @type tag: C{str} + @param dry_run: dry run + @type dry_run: C{bool} """ args = GitArgs(repo, 'tag', tag) + args.add_true(dry_run, "--dry-run") self._git_command("push", args.args) #{ Files @@ -1270,12 +1345,12 @@ extra_env = {} if isinstance(paths, six.string_types): - paths = [ paths ] + paths = [paths] - args = [ '-f' ] if force else [] + args = ['-f'] if force else [] if index_file: - extra_env['GIT_INDEX_FILE'] = index_file + extra_env['GIT_INDEX_FILE'] = index_file if work_tree: extra_env['GIT_WORK_TREE'] = work_tree @@ -1292,9 +1367,9 @@ @type verbose: C{bool} """ if isinstance(paths, six.string_types): - paths = [ paths ] + paths = [paths] - args = [] if verbose else ['--quiet'] + args = [] if verbose else ['--quiet'] self._git_command("rm", args + paths) def list_files(self, types=['cached']): @@ -1306,24 +1381,23 @@ @return: list of files @rtype: C{list} of C{str} """ - all_types = [ 'cached', 'deleted', 'others', 'ignored', 'stage' - 'unmerged', 'killed', 'modified' ] - args = [ '-z' ] + all_types = ['cached', 'deleted', 'others', 'ignored', 'stage' + 'unmerged', 'killed', 'modified'] + args = ['-z'] for t in types: if t in all_types: - args += [ '--%s' % t ] + args += ['--%s' % t] else: raise GitRepositoryError("Unknown type '%s'" % t) out, ret = self._git_getoutput('ls-files', args) if ret: raise GitRepositoryError("Error listing files: '%d'" % ret) if out: - return [ file for file in out[0].split('\0') if file ] + return [file for file in out[0].split('\0') if file] else: return [] - def write_file(self, filename, filters=True): """ Hash a single file and write it into the object database @@ -1366,7 +1440,7 @@ @type edit: C{bool} """ args = GitArgs() - args.add_true(edit, '--edit') + args.add_true(edit, '--edit') self._commit(msg=msg, args=args.args, author_info=author_info) def commit_all(self, msg, author_info=None, edit=False): @@ -1378,7 +1452,7 @@ @type author_info: L{GitModifier} """ args = GitArgs('-a') - args.add_true(edit, '--edit') + args.add_true(edit, '--edit') self._commit(msg=msg, args=args.args, author_info=author_info) def commit_files(self, files, msg, author_info=None): @@ -1393,7 +1467,7 @@ @type author_info: L{GitModifier} """ if isinstance(files, six.string_types): - files = [ files ] + files = [files] self._commit(msg=msg, args=files, author_info=author_info) def commit_dir(self, unpack_dir, msg, branch, other_parents=None, @@ -1437,25 +1511,26 @@ cur = None else: raise - else: # emtpy repo + else: # empty repo cur = None branch = 'master' # Build list of parents: parents = [] if cur: - parents = [ cur ] + parents.append(cur) if other_parents: for parent in other_parents: sha = self.rev_parse(parent) if sha not in parents: - parents += [ sha ] + parents.append(sha) commit = self.commit_tree(tree=tree, msg=msg, parents=parents, author=author, committer=committer) if not commit: raise GitRepositoryError("Failed to commit tree") - self.update_ref("refs/heads/%s" % branch, commit, cur) + self.update_ref("refs/heads/%s" % branch, commit, cur, + msg="gbp: %s" % msg.split('\n')[0]) return commit def commit_tree(self, tree, msg, parents, author={}, committer={}): @@ -1478,9 +1553,9 @@ if val: extra_env['GIT_COMMITTER_%s' % key.upper()] = val - args = [ tree ] + args = [tree] for parent in parents: - args += [ '-p' , parent ] + args += ['-p', parent] sha1, stderr, ret = self._git_inout('commit-tree', args, msg, @@ -1522,20 +1597,20 @@ args.add_cond(options, options) args.add("--") if isinstance(paths, six.string_types): - paths = [ paths ] + paths = [paths] args.add_cond(paths, paths) commits, ret = self._git_getoutput('log', args.args) if ret: where = " on %s" % paths if paths else "" raise GitRepositoryError("Error getting commits %s..%s%s" % - (since, until, where)) - return [ commit.strip() for commit in commits ] + (since, until, where)) + return [commit.strip() for commit in commits] def show(self, id): """git-show id""" obj, stderr, ret = self._git_inout('show', ["--pretty=medium", id], - capture_stderr=True) + capture_stderr=True) if ret: raise GitRepositoryError("can't get %s: %s" % (id, stderr.rstrip())) return obj @@ -1561,7 +1636,7 @@ raise GitRepositoryError("Error grepping log for %s: %s" % (regex, stderr[:-1])) if stdout: - return [ commit.strip() for commit in stdout.split('\n')[::-1] ] + return [commit.strip() for commit in stdout.split('\n')[::-1]] else: return [] @@ -1590,7 +1665,7 @@ args = GitArgs('--pretty=format:%an%x00%ae%x00%ad%x00%cn%x00%ce%x00%cd%x00%s%x00%f%x00%b%x00', '-z', '--date=raw', '--no-renames', '--name-status', commit_sha1) - out, err, ret = self._git_inout('show', args.args) + out, err, ret = self._git_inout('show', args.args) if ret: raise GitRepositoryError("Unable to retrieve commit info for %s" % commitish) @@ -1607,19 +1682,20 @@ files = defaultdict(list) file_fields = fields[9:] # For some reason git returns one extra empty field for merge commits - if file_fields[0] == '': file_fields.pop(0) + if file_fields[0] == '': + file_fields.pop(0) while len(file_fields) and file_fields[0] != '': status = file_fields.pop(0).strip() path = file_fields.pop(0) files[status].append(path) - return {'id' : commitish, - 'author' : author, - 'committer' : committer, - 'subject' : fields[6], - 'patchname' : fields[7], - 'body' : fields[8], - 'files' : files} + return {'id': commitish, + 'author': author, + 'committer': committer, + 'subject': fields[6], + 'patchname': fields[7], + 'body': fields[8], + 'files': files} #{ Patches def format_patches(self, start, end, output_dir, @@ -1646,22 +1722,24 @@ options.add_cond(thread, '--thread=%s' % thread, '--no-thread') output, ret = self._git_getoutput('format-patch', options.args) - return [ line.strip() for line in output ] + return [line.strip() for line in output] - def apply_patch(self, patch, index=True, context=None, strip=None): + def apply_patch(self, patch, index=True, context=None, strip=None, fix_ws=False): """Apply a patch using git apply""" args = [] if context: - args += [ '-C', context ] + args += ['-C', context] if index: args.append("--index") - if strip != None: - args += [ '-p', str(strip) ] + if fix_ws: + args.append("--whitespace=fix") + if strip is not None: + args += ['-p', str(strip)] args.append(patch) self._git_command("apply", args) def diff(self, obj1, obj2=None, paths=None, stat=False, summary=False, - text=False, ignore_submodules=True): + text=False, ignore_submodules=True, abbrev=None): """ Diff two git repository objects @@ -1683,6 +1761,7 @@ @rtype: C{str} """ options = GitArgs('-p', '--no-ext-diff') + config_args = GitArgs() if stat is True: options.add('--stat') elif stat: @@ -1694,7 +1773,11 @@ options.add_true(obj2, obj2) if paths: options.add('--', paths) - output, stderr, ret = self._git_inout('diff', options.args) + if abbrev is not None: + config_args.add('core.abbrev=%d' % abbrev) + output, stderr, ret = self._git_inout('diff', + options.args, + config_args=config_args.args) if ret: raise GitRepositoryError("Git diff failed") return output @@ -1727,7 +1810,7 @@ return result #} - def archive(self, format, prefix, output, treeish, **kwargs): + def archive(self, format, prefix, output, treeish, cwd=None): """ Create an archive from a treeish @@ -1739,23 +1822,33 @@ @type output: C{str} @param treeish: the treeish to create the archive from @type treeish: C{str} - @param kwargs: additional commandline options passed to git-archive + @param cwd: The directory to run in. Defaults to the current dir + @type cwd: C{str} """ - args = [ '--format=%s' % format, '--prefix=%s' % prefix, - '--output=%s' % output, treeish ] - out, ret = self._git_getoutput('archive', args, **kwargs) + args = ['--format=%s' % format, + '--prefix=%s' % prefix, + '--output=%s' % output, + treeish] + out, err, ret = self._git_inout('archive', args, cwd=cwd, capture_stderr=True) if ret: - raise GitRepositoryError("Unable to archive %s" % treeish) + raise GitRepositoryError("Unable to archive %s: %s" % (treeish, err.strip())) - def collect_garbage(self, auto=False): + def collect_garbage(self, auto=False, prune=False, aggressive=False): """ Cleanup unnecessary files and optimize the local repository param auto: only cleanup if required param auto: C{bool} """ - args = [ '--auto' ] if auto else [] - self._git_command("gc", args) + args = GitArgs('--quiet') + if prune is True: + args.add('--prune') + else: + args.add_true(prune, '--prune=%s' % prune) + args.add_true(aggressive, '--aggressive') + args.add_true(auto, '--auto') + self._git_command("gc", args.args) + #{ Submodules @@ -1777,7 +1870,6 @@ return True return os.path.exists(os.path.join(self.path, '.gitmodules')) - def add_submodule(self, repo_path): """ Add a submodule @@ -1785,8 +1877,7 @@ @param repo_path: path to submodule @type repo_path: C{str} """ - self._git_command("submodule", [ "add", repo_path ]) - + self._git_command("submodule", ["add", repo_path]) def update_submodules(self, init=True, recursive=True, fetch=False): """ @@ -1802,7 +1893,7 @@ if not self.has_submodules(): return - args = [ "update" ] + args = ["update"] if recursive: args.append("--recursive") if init: @@ -1812,7 +1903,6 @@ self._git_command("submodule", args) - def get_submodules(self, treeish, path=None, recursive=True): """ List the submodules of treeish @@ -1827,18 +1917,26 @@ if path is None: path = self.path - args = [ treeish ] + args = [treeish] if recursive: args += ['-r'] - out, ret = self._git_getoutput('ls-tree', args, cwd=path) - for line in out: - mode, objtype, commit, name = line[:-1].split(None, 3) + out, err, ret = self._git_inout('ls-tree', + args, + cwd=path, + capture_stderr=True) + if ret: + raise GitRepositoryError("Failed to list submodules of %s: %s" % + (treeish, err.strip())) + for line in out.split('\n'): + if not line: + continue + mode, objtype, commit, name = line.split(None, 3) # A submodules is shown as "commit" object in ls-tree: if objtype == "commit": nextpath = os.path.join(path, name) - submodules.append( (nextpath.replace(self.path,'').lstrip('/'), - commit) ) + submodules.append((nextpath.replace(self.path, '').lstrip('/'), + commit)) if recursive: submodules += self.get_submodules(commit, path=nextpath, recursive=recursive) @@ -1847,7 +1945,7 @@ #{ Repository Creation @classmethod - def create(klass, path, description=None, bare=False): + def create(cls, path, description=None, bare=False): """ Create a repository at path @@ -1868,12 +1966,12 @@ if not os.path.exists(abspath): os.makedirs(abspath) try: - stdout, stderr, ret = klass.__git_inout(command='init', - args=args.args, - input=None, - extra_env=None, - cwd=abspath, - capture_stderr=True) + stdout, stderr, ret = cls.__git_inout(command='init', + args=args.args, + input=None, + extra_env=None, + cwd=abspath, + capture_stderr=True) except Exception as excobj: raise GitRepositoryError("Error running git init: %s" % excobj) if ret: @@ -1883,14 +1981,14 @@ with open(os.path.join(abspath, git_dir, "description"), 'w') as f: description += '\n' if description[-1] != '\n' else '' f.write(description) - return klass(abspath) + return cls(abspath) except OSError as err: raise GitRepositoryError("Cannot create Git repository at '%s': %s" % (abspath, err[1])) return None @classmethod - def clone(klass, path, remote, depth=0, recursive=False, mirror=False, + def clone(cls, path, remote, depth=0, recursive=False, mirror=False, bare=False, auto_name=True, reference=None): """ Clone a git repository at I{remote} to I{path}. @@ -1922,7 +2020,7 @@ abspath, name = abspath.rsplit('/', 1) args = GitArgs('--quiet') - args.add_true(depth, '--depth', depth) + args.add_true(depth, '--depth', depth) args.add_true(recursive, '--recursive') args.add_true(mirror, '--mirror') args.add_true(bare, '--bare') @@ -1934,12 +2032,12 @@ os.makedirs(abspath) try: - stdout, stderr, ret = klass.__git_inout(command='clone', - args=args.args, - input=None, - extra_env=None, - cwd=abspath, - capture_stderr=True) + stdout, stderr, ret = cls.__git_inout(command='clone', + args=args.args, + input=None, + extra_env=None, + cwd=abspath, + capture_stderr=True) except Exception as excobj: raise GitRepositoryError("Error running git clone: %s" % excobj) if ret: @@ -1947,7 +2045,7 @@ if not name: try: - name = remote.rstrip('/').rsplit('/',1)[1] + name = remote.rstrip('/').rsplit('/', 1)[1] except IndexError: name = remote.split(':', 1)[1] if (mirror or bare): @@ -1955,11 +2053,10 @@ name = "%s.git" % name elif name.endswith('.git'): name = name[:-4] - return klass(os.path.join(abspath, name)) + return cls(os.path.join(abspath, name)) except OSError as err: raise GitRepositoryError("Cannot clone Git repository " "'%s' to '%s': %s" % (remote, abspath, err[1])) return None #} - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/vfs.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/vfs.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/git/vfs.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/git/vfs.py 2017-02-11 19:33:12.000000000 +0000 @@ -17,7 +17,8 @@ """Make blobs in a git repository accessible as file like objects""" from six import StringIO -from gbp.git.repository import GitRepositoryError +from gbp.git.repository import GitRepositoryError + class GitVfs(object): @@ -43,6 +44,12 @@ def close(self): return self._data.close() + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.close() + def __init__(self, repo, committish=None): """ @param repo: the git repository to act on diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/log.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/log.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/log.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/log.py 2017-02-11 19:33:12.000000000 +0000 @@ -124,24 +124,22 @@ """Logs a message with level ERROR on the GBP logger""" LOGGER.error(msg) -def error(msg): - err(msg) def warn(msg): """Logs a message with level WARNING on the GBP logger""" LOGGER.warning(msg) -def warning(msg): - warn(msg) def info(msg): """Logs a message with level INFO on the GBP logger""" LOGGER.info(msg) + def debug(msg): """Logs a message with level DEBUG on the GBP logger""" LOGGER.debug(msg) + def _parse_color_scheme(color_scheme=""): """Set logging colors""" scheme = {} @@ -159,9 +157,11 @@ except ValueError: try: scheme[level] = COLORS[color.lower()] - except KeyError: pass + except KeyError: + pass return scheme + def setup(color, verbose, color_scheme=""): """Basic logger setup""" LOGGER.set_color(color) @@ -176,4 +176,3 @@ logging.setLoggerClass(GbpLogger) LOGGER = getLogger("gbp") - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/notifications.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/notifications.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/notifications.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/notifications.py 2017-02-11 19:33:12.000000000 +0000 @@ -19,6 +19,7 @@ notify_module = None + def enable_notifications(): global notify_module @@ -37,7 +38,7 @@ def build_msg(cp, success): summary = "Gbp %s" % ["failed", "successful"][success] msg = ("Build of %s %s %s" % - (cp['Source'], cp['Version'], ["failed", "succeeded"][success])) + (cp['Source'], cp['Version'], ["failed", "succeeded"][success])) return summary, msg @@ -67,4 +68,3 @@ return [True, False][notify_opt.is_on()] return notify_opt.do(send_notification, summary, message) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/patch_series.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/patch_series.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/patch_series.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/patch_series.py 2017-02-11 19:33:12.000000000 +0000 @@ -163,9 +163,11 @@ """ A series of L{Patch}es as read from a quilt series file). """ + comment_re = re.compile('\s+#.*$') + level_re = re.compile('-p(?P[0-9]+)') @classmethod - def read_series_file(klass, seriesfile): + def read_series_file(cls, seriesfile): """Read a series file into L{Patch} objects""" patch_dir = os.path.dirname(seriesfile) @@ -177,18 +179,19 @@ except Exception as err: raise GbpError("Cannot open series file: %s" % err) - queue = klass._read_series(s, patch_dir) + queue = cls._read_series(s, patch_dir) s.close() return queue @classmethod - def _read_series(klass, series, patch_dir): + def _read_series(cls, series, patch_dir): """ Read patch series - >>> PatchSeries._read_series(['a/b', \ - 'a -p1', \ - 'a/b -p2'], '.') # doctest:+NORMALIZE_WHITESPACE + >>> PatchSeries._read_series(['a/b', + ... 'a -p1 # comment', + ... 'a/b -p2'], '.') + ... # doctest:+NORMALIZE_WHITESPACE [, , ] @@ -201,7 +204,6 @@ @param patch_dir: path prefix to prepend to each patch path @type patch_dir: string """ - queue = PatchSeries() for line in series: try: @@ -209,7 +211,7 @@ continue except IndexError: continue # ignore empty lines - queue.append(klass._parse_line(line, patch_dir)) + queue.append(cls._parse_line(line, patch_dir)) return queue @staticmethod @@ -227,8 +229,22 @@ topic = None return topic - @staticmethod - def _split_strip(line): + @classmethod + def _strip_comment(cls, line): + """ + Strip a comment from a series file line + + >>> PatchSeries._strip_comment("does/not matter") + 'does/not matter' + >>> PatchSeries._strip_comment("remove/the # comment # text") + 'remove/the' + >>> PatchSeries._strip_comment("leave/level/intact -p1 # comment # text") + 'leave/level/intact -p1' + """ + return re.sub(cls.comment_re, '', line) + + @classmethod + def _split_strip(cls, line): """ Separate the -p option from the patch name @@ -244,7 +260,7 @@ split = line.rsplit(None, 1) if len(split) > 1: - m = re.match('-p(?P[0-9]+)', split[1]) + m = cls.level_re.match(split[1]) if m: patch = split[0] strip = int(m.group('level')) @@ -252,7 +268,7 @@ return (patch, strip) @classmethod - def _parse_line(klass, line, patch_dir): + def _parse_line(cls, line, patch_dir): """ Parse a single line from a series file @@ -261,7 +277,7 @@ >>> PatchSeries._parse_line("a/b", '.') """ - line = line.rstrip() - topic = klass._get_topic(line) - (patch, split) = klass._split_strip(line) + line = cls._strip_comment(line.rstrip()) + topic = cls._get_topic(line) + (patch, split) = cls._split_strip(line) return Patch(os.path.join(patch_dir, patch), topic, split) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/pkg/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/pkg/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/pkg/__init__.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/pkg/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -27,23 +27,24 @@ from gbp.errors import GbpError # compression types, extra options and extensions -compressor_opts = { 'gzip' : [ '-n', 'gz' ], - 'bzip2' : [ '', 'bz2' ], - 'lzma' : [ '', 'lzma' ], - 'xz' : [ '', 'xz' ] } +compressor_opts = {'gzip': ['-n', 'gz'], + 'bzip2': ['', 'bz2'], + 'lzma': ['', 'lzma'], + 'xz': ['', 'xz']} # Map frequently used names of compression types to the internal ones: -compressor_aliases = { 'bz2' : 'bzip2', - 'gz' : 'gzip', } +compressor_aliases = {'bz2': 'bzip2', + 'gz': 'gzip', } # Supported archive formats -archive_formats = [ 'tar', 'zip' ] +archive_formats = ['tar', 'zip'] # Map combined file extensions to archive and compression format -archive_ext_aliases = { 'tgz' : ('tar', 'gzip'), - 'tbz2' : ('tar', 'bzip2'), - 'tlz' : ('tar', 'lzma'), - 'txz' : ('tar', 'xz')} +archive_ext_aliases = {'tgz': ('tar', 'gzip'), + 'tbz2': ('tar', 'bzip2'), + 'tlz': ('tar', 'lzma'), + 'txz': ('tar', 'xz')} + def parse_archive_filename(filename): """ @@ -178,14 +179,15 @@ version_chars = r'[a-zA-Z\d\.\~\-\:\+]' basename = parse_archive_filename(os.path.basename(filename))[0] - version_filters = map(lambda x: x % version_chars, - ( # Debian upstream tarball: package_'.orig.tar.gz' - r'^(?P[a-z\d\.\+\-]+)_(?P%s+)\.orig', - # Debian native: 'package_.tar.gz' - r'^(?P[a-z\d\.\+\-]+)_(?P%s+)', - # Upstream 'package-.tar.gz' - # or directory 'package-': - r'^(?P[a-zA-Z\d\.\+\-]+)(-)(?P[0-9]%s*)')) + version_filters = map( + lambda x: x % version_chars, + ( # Debian upstream tarball: package_'.orig.tar.gz' + r'^(?P[a-z\d\.\+\-]+)_(?P%s+)\.orig', + # Debian native: 'package_.tar.gz' + r'^(?P[a-z\d\.\+\-]+)_(?P%s+)', + # Upstream 'package-.tar.gz' + # or directory 'package-': + r'^(?P[a-zA-Z\d\.\+\-]+)(-)(?P[0-9]%s*)')) if extra_regex: version_filters = extra_regex + version_filters @@ -282,14 +284,14 @@ self._orig = True elif parts[-2] == 'tar': if (parts[-1] in compressor_opts or - parts[-1] in compressor_aliases): - self._orig = True + parts[-1] in compressor_aliases): + self._orig = True except IndexError: self._orig = False def is_orig(self): """ - @return: C{True} if sources are suitable as upstream source, + @return: C{True} if sources are suitable as orig tarball, C{False} otherwise @rtype: C{bool} """ @@ -307,11 +309,11 @@ def path(self): return self._path.rstrip('/') - def unpack(self, dir, filters=[]): + def unpack(self, dir, filters=None): """ Unpack packed upstream sources into a given directory - and determine the toplevel of the source tree filtering - out files specified by filters. + (filtering out files specified by filters) and determine the + toplevel of the source tree. """ if self.is_dir(): raise GbpError("Cannot unpack directory %s" % self.path) @@ -366,7 +368,7 @@ # unpackArchive already printed an error message raise GbpError - def pack(self, newarchive, filters=[]): + def pack(self, newarchive, filters=None): """ Recreate a new archive from the current one diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/pkg/pristinetar.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/pkg/pristinetar.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/pkg/pristinetar.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/pkg/pristinetar.py 2017-02-11 19:33:12.000000000 +0000 @@ -20,9 +20,10 @@ import gbp.log from gbp.command_wrappers import Command + class PristineTar(Command): """The pristine-tar branch in a git repository""" - cmd='/usr/bin/pristine-tar' + cmd = '/usr/bin/pristine-tar' branch = 'pristine-tar' def __init__(self, repo): @@ -63,7 +64,7 @@ @param archive: the name of the orig archive @type archive: C{str} """ - self.run_error = 'Pristine-tar couldn\'t checkout "%s": {stderr}' % os.path.basename(archive) + self.run_error = 'Pristine-tar couldn\'t checkout "%s": {stderr_or_reason}' % os.path.basename(archive) self.__call__(['checkout', archive]) def commit(self, archive, upstream): @@ -76,7 +77,12 @@ @param upstream: the upstream branch to diff against @type upstream: C{str} """ - self.run_error = ("Couldn't commit to '%s' with upstream '%s': {stderr}" % + self.run_error = ("Couldn't commit to '%s' with upstream '%s': {stderr_or_reason}" % (self.branch, upstream)) self.__call__(['commit', archive, upstream]) + def verify(self, archive): + """Verify an archive's I{archive} checksum using to the pristine tar branch""" + + self.run_error = 'Pristine-tar couldn\'t verify "%s": {stderr_or_reason}' % os.path.basename(archive) + self.__call__(['verify', archive]) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/changelog.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/changelog.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/changelog.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/changelog.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,261 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2014-2015 Intel Corporation +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# +"""An RPM Changelog""" + +import locale +import datetime +import re + +from functools import wraps + +import gbp.log + + +def c_locale(category): + def _decorator(f): + @wraps(f) + def wrapper(*args, **kwargs): + saved = locale.setlocale(category, None) + locale.setlocale(category, 'C') + ret = f(*args, **kwargs) + locale.setlocale(category, saved) + return ret + return wrapper + return _decorator + + +class ChangelogError(Exception): + """Problem parsing changelog""" + pass + + +class _ChangelogHeader(object): + """The header part of one changelog section""" + + def __init__(self, pkgpolicy, time=None, **kwargs): + self._pkgpolicy = pkgpolicy + self._data = {'time': time} + self._data.update(kwargs) + + def __contains__(self, key): + return key in self._data + + def __getitem__(self, key): + if key in self._data: + return self._data[key] + return None + + @c_locale(locale.LC_TIME) + def __str__(self): + keys = dict(self._data) + keys['time'] = self._data['time'].strftime( + self._pkgpolicy.Changelog.header_time_format) + try: + return self._pkgpolicy.Changelog.header_format % keys + '\n' + except KeyError as err: + raise ChangelogError("Unable to format changelog header, missing " + "property %s" % err) + + +class _ChangelogEntry(object): + """An entry (one 'change') in an RPM changelog""" + + def __init__(self, pkgpolicy, author, text): + """ + @param pkgpolicy: RPM packaging policy + @type pkgpolicy: L{RpmPkgPolicy} + @param author: author of the change + @type author: C{str} + @param text: message of the changelog entry + @type text: C{str} or C{list} of C{str} + """ + self._pkgpolicy = pkgpolicy + self.author = author + if isinstance(text, str): + self._text = text.splitlines() + else: + self._text = text + # Strip trailing empty lines + while text and not text[-1].strip(): + text.pop() + + def __str__(self): + # Currently no (re-)formatting, just raw text + string = "" + for line in self._text: + string += line + '\n' + return string + + +class _ChangelogSection(object): + """One section (set of changes) in an RPM changelog""" + + def __init__(self, pkgpolicy, *args, **kwargs): + self._pkgpolicy = pkgpolicy + self.header = _ChangelogHeader(pkgpolicy, *args, **kwargs) + self.entries = [] + self._trailer = '\n' + + def __str__(self): + text = str(self.header) + for entry in self.entries: + text += str(entry) + # Add "section separator" + text += self._trailer + return text + + def set_header(self, *args, **kwargs): + """Change the section header""" + self.header = _ChangelogHeader(self._pkgpolicy, *args, **kwargs) + + def append_entry(self, entry): + """Add a new entry to the end of the list of entries""" + self.entries.append(entry) + return entry + + +class Changelog(object): + """An RPM changelog""" + + def __init__(self, pkgpolicy): + self._pkgpolicy = pkgpolicy + self.sections = [] + + def __str__(self): + string = "" + for section in self.sections: + string += str(section) + return string + + def create_entry(self, *args, **kwargs): + """Create and return new entry object""" + return _ChangelogEntry(self._pkgpolicy, *args, **kwargs) + + def add_section(self, *args, **kwargs): + """Add new empty section""" + section = _ChangelogSection(self._pkgpolicy, *args, **kwargs) + self.sections.insert(0, section) + return section + + +class ChangelogParser(object): + """Parser for RPM changelogs""" + + def __init__(self, pkgpolicy): + self._pkgpolicy = pkgpolicy + self.section_match_re = pkgpolicy.Changelog.section_match_re + self.section_split_re = pkgpolicy.Changelog.section_split_re + self.header_split_re = pkgpolicy.Changelog.header_split_re + self.header_name_split_re = pkgpolicy.Changelog.header_name_split_re + self.body_name_re = pkgpolicy.Changelog.body_name_re + + def raw_parse_string(self, string): + """Parse changelog - only splits out raw changelog sections.""" + changelog = Changelog(self._pkgpolicy) + ch_section = "" + for line in string.splitlines(): + if re.match(self.section_match_re, line, re.M | re.S): + if ch_section: + changelog.sections.append(ch_section) + ch_section = line + '\n' + elif ch_section: + ch_section += line + '\n' + else: + raise ChangelogError("First line in changelog is invalid") + if ch_section: + changelog.sections.append(ch_section) + return changelog + + def raw_parse_file(self, changelog): + """Parse changelog file - only splits out raw changelog sections.""" + try: + with open(changelog) as ch_file: + return self.raw_parse_string(ch_file.read()) + except IOError as err: + raise ChangelogError("Unable to read changelog file: %s" % err) + + @c_locale(locale.LC_TIME) + def _parse_section_header(self, text): + """Parse one changelog section header""" + # Try to split out time stamp and "changelog name" + match = re.match(self.header_split_re, text, re.M) + if not match: + raise ChangelogError("Unable to parse changelog header: %s" % text) + try: + time = datetime.datetime.strptime(match.group('ch_time'), + "%a %b %d %Y") + except ValueError: + raise ChangelogError("Unable to parse changelog header: invalid " + "timestamp '%s'" % match.group('ch_time')) + # Parse "name" part which consists of name and/or email and an optional + # revision + name_text = match.group('ch_name') + match = re.match(self.header_name_split_re, name_text) + if not match: + raise ChangelogError("Unable to parse changelog header: invalid " + "name / revision '%s'" % name_text) + kwargs = match.groupdict() + return _ChangelogSection(self._pkgpolicy, time=time, **kwargs) + + def _create_entry(self, author, text): + """Create a new changelog entry""" + return _ChangelogEntry(self._pkgpolicy, author=author, text=text) + + def _parse_section_entries(self, text, default_author): + """Parse entries from a string and add them to a section""" + entries = [] + entry_text = [] + author = default_author + for line in text.splitlines(): + match = re.match(self.body_name_re, line) + if match: + if entry_text: + entries.append(self._create_entry(author, entry_text)) + author = match.group('name') + else: + if line.startswith("-"): + if entry_text: + entries.append(self._create_entry(author, entry_text)) + entry_text = [line] + else: + if not entry_text: + gbp.log.info("First changelog entry (%s) is garbled, " + "entries should start with a dash ('-')" % + line) + entry_text.append(line) + if entry_text: + entries.append(self._create_entry(author, entry_text)) + + return entries + + def parse_section(self, text): + """Parse one section""" + # Check that the first line(s) look like a changelog header + match = re.match(self.section_split_re, text, re.M | re.S) + if not match: + raise ChangelogError("Doesn't look like changelog header: %s..." % + text.splitlines()[0]) + # Parse header + section = self._parse_section_header(match.group('ch_header')) + header = section.header + # Parse entries + default_author = header['name'] if 'name' in header else header['email'] + for entry in self._parse_section_entries(match.group('ch_body'), + default_author): + section.append_entry(entry) + + return section diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/git.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/git.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/git.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/git.py 2017-02-11 19:33:12.000000000 +0000 @@ -15,14 +15,14 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, please see # -import re from gbp.format import format_str from gbp.errors import GbpError -from gbp.git import GitRepository, GitRepositoryError +from gbp.git import GitRepository, GitRepositoryError # noqa: F401 from gbp.pkg.pristinetar import PristineTar from gbp.rpm import compose_version_str + class RpmGitRepository(GitRepository): """A git repository that holds the source of an RPM package""" @@ -46,7 +46,7 @@ tag = self.version_to_tag(format, str_fields) except GbpError: return None - if self.has_tag(tag): # new tags are injective + if self.has_tag(tag): # new tags are injective # dereference to a commit object return self.rev_parse("%s^0" % tag) return None @@ -97,7 +97,7 @@ def has_pristine_tar_branch(self): """ - Wheter the repo has a I{pristine-tar} branch. + Whether the repo has a I{pristine-tar} branch. @return: C{True} if the repo has pristine-tar commits already, C{False} otherwise diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/__init__.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -40,6 +40,7 @@ """Spec file parsing error""" pass + class MacroExpandError(Exception): """Macro expansion in spec file failed""" pass @@ -70,8 +71,8 @@ @property def version(self): """Get the (downstream) version of the RPM package""" - version = dict(upstreamversion = self.rpmhdr[librpm.RPMTAG_VERSION], - release = self.rpmhdr[librpm.RPMTAG_RELEASE]) + version = dict(upstreamversion=self.rpmhdr[librpm.RPMTAG_VERSION], + release=self.rpmhdr[librpm.RPMTAG_RELEASE]) if self.rpmhdr[librpm.RPMTAG_EPOCH] is not None: version['epoch'] = str(self.rpmhdr[librpm.RPMTAG_EPOCH]) return version @@ -99,24 +100,24 @@ c = gbpc.RunAtCommand('rpm2cpio', [self.srpmfile, '|', 'cpio', '-id'], shell=True, capture_stderr=True) - c.run_error = "'%s' failed: {stderr}" % (" ".join([c.cmd] + c.args)) + c.run_error = "'%s' failed: {stderr_or_reason}" % (" ".join([c.cmd] + c.args)) c(dir=dest_dir) class SpecFile(object): """Class for parsing/modifying spec files""" tag_re = re.compile(r'^(?P[a-z]+)(?P[0-9]+)?\s*:\s*' - '(?P\S(.*\S)?)\s*$', flags=re.I) + '(?P\S(.*\S)?)\s*$', flags=re.I) directive_re = re.compile(r'^%(?P[a-z]+)(?P[0-9]+)?' - '(\s+(?P.*))?$', flags=re.I) + '(\s+(?P.*))?$', flags=re.I) gbptag_re = re.compile(r'^\s*#\s*gbp-(?P[a-z-]+)' - '(\s*:\s*(?P\S.*))?$', flags=re.I) + '(\s*:\s*(?P\S.*))?$', flags=re.I) # Here "sections" stand for all scripts, scriptlets and other directives, # but not macros section_identifiers = ('package', 'description', 'prep', 'build', 'install', - 'clean', 'check', 'pre', 'preun', 'post', 'postun', 'verifyscript', - 'files', 'changelog', 'triggerin', 'triggerpostin', 'triggerun', - 'triggerpostun') + 'clean', 'check', 'pre', 'preun', 'post', 'postun', 'verifyscript', + 'files', 'changelog', 'triggerin', 'triggerpostin', 'triggerun', + 'triggerpostun') def __init__(self, filename=None, filedata=None): @@ -146,15 +147,15 @@ # Use rpm-python to parse the spec file content self._filtertags = ("excludearch", "excludeos", "exclusivearch", - "exclusiveos","buildarch") + "exclusiveos", "buildarch") self._listtags = self._filtertags + ('source', 'patch', - 'requires', 'conflicts', 'recommends', - 'suggests', 'supplements', 'enhances', - 'provides', 'obsoletes', 'buildrequires', - 'buildconflicts', 'buildrecommends', - 'buildsuggests', 'buildsupplements', - 'buildenhances', 'collections', - 'nosource', 'nopatch') + 'requires', 'conflicts', 'recommends', + 'suggests', 'supplements', 'enhances', + 'provides', 'obsoletes', 'buildrequires', + 'buildconflicts', 'buildrecommends', + 'buildsuggests', 'buildsupplements', + 'buildenhances', 'collections', + 'nosource', 'nopatch') self._specinfo = self._parse_filtered_spec(self._filtertags) # Other initializations @@ -164,7 +165,7 @@ self.release = source_header[librpm.RPMTAG_RELEASE] # rpm-python returns epoch as 'long', convert that to string self.epoch = str(source_header[librpm.RPMTAG_EPOCH]) \ - if source_header[librpm.RPMTAG_EPOCH] != None else None + if source_header[librpm.RPMTAG_EPOCH] is not None else None self.packager = source_header[librpm.RPMTAG_PACKAGER] self._tags = {} self._special_directives = defaultdict(list) @@ -186,7 +187,7 @@ skip_tags = [tag.lower() for tag in skip_tags] with tempfile.NamedTemporaryFile(prefix='gbp') as filtered: filtered.writelines(str(line) for line in self._content - if str(line).split(":")[0].strip().lower() not in skip_tags) + if str(line).split(":")[0].strip().lower() not in skip_tags) filtered.flush() try: # Parse two times to circumvent a rpm-python problem where @@ -196,16 +197,16 @@ except ValueError as err: rpmlog = get_librpm_log() gbp.log.debug("librpm log:\n %s" % - "\n ".join(rpmlog)) + "\n ".join(rpmlog)) raise GbpError("RPM error while parsing %s: %s (%s)" % - (self.specfile, err, rpmlog[-1])) + (self.specfile, err, rpmlog[-1])) @property def version(self): """Get the (downstream) version""" - version = dict(upstreamversion = self.upstreamversion, - release = self.release) - if self.epoch != None: + version = dict(upstreamversion=self.upstreamversion, + release=self.release) + if self.epoch is not None: version['epoch'] = self.epoch return version @@ -320,12 +321,15 @@ def _patch_macro_opts(args): """Parse arguments of the '%patch' macro""" - patchparser = OptionParser() + patchparser = OptionParser( + prog="%s internal patch macro opts parser" % __name__, + usage="%prog for " + args) patchparser.add_option("-p", dest="strip") patchparser.add_option("-s", dest="silence") patchparser.add_option("-P", dest="patchnum") patchparser.add_option("-b", dest="backup") patchparser.add_option("-E", dest="removeempty") + patchparser.add_option("-F", dest="fuzz") arglist = args.split() return patchparser.parse_args(arglist)[0] @@ -333,7 +337,9 @@ def _setup_macro_opts(args): """Parse arguments of the '%setup' macro""" - setupparser = OptionParser() + setupparser = OptionParser( + prog="%s internal setup macro opts parser" % __name__, + usage="%prog for " + args) setupparser.add_option("-n", dest="name") setupparser.add_option("-c", dest="create_dir", action="store_true") setupparser.add_option("-D", dest="no_delete_dir", action="store_true") @@ -424,7 +430,7 @@ elif typ == 2 or typ == 10: # Patch tag without any number defined is treated by RPM as # having number (2^31-1), we use number -1 - if num >= pow(2,30): + if num >= pow(2, 30): num = -1 if num in patches: patches[num]['linevalue'] = name @@ -501,7 +507,7 @@ if key in ('patch', 'vcs'): if key in self._tags: insertafter = key - elif not insertafter in self._tags: + elif insertafter not in self._tags: insertafter = 'name' after_line = self._tags[insertafter]['lines'][-1]['line'] if value: @@ -754,8 +760,8 @@ try: prefix = self.macro_expand(opts.name) + '/' except MacroExpandError as err: - gbp.log.warn("Couldn't determine prefix from %%setup "\ - "macro (%s). Using filename base as a " \ + gbp.log.warn("Couldn't determine prefix from %%setup " + "macro (%s). Using filename base as a " "fallback" % err) prefix = orig['filename_base'] + '/' else: @@ -777,7 +783,7 @@ src['filename_base'], src['archive_fmt'], src['compression'] = \ parse_archive_filename(os.path.basename(filename)) if (src['filename_base'].startswith(self.name) and - src['archive_fmt']): + src['archive_fmt']): # Take the first archive that starts with pkg name orig = src break @@ -846,10 +852,10 @@ topdir = topdir.rstrip('/') + ('/') if topdir else '' try: file_list = [nam for (mod, typ, sha, nam) in - repo.list_tree(treeish, recursive, topdir) if typ == 'blob'] + repo.list_tree(treeish, recursive, topdir) if typ == 'blob'] except GitRepositoryError as err: raise NoSpecError("Cannot find spec file from treeish %s, Git error: %s" - % (treeish, err)) + % (treeish, err)) spec_path = guess_spec_fn(file_list, preferred_name) return spec_from_repo(repo, treeish, spec_path) @@ -927,6 +933,7 @@ return ret + def compose_version_str(evr): """ Compose a full version string from individual "version components", @@ -959,4 +966,23 @@ return None +def filter_version(evr, *keys): + """ + Remove entry from the version dict + + @param evr: dict of version components + @type evr: C{dict} of C{str} + @param keys: keys to remove + @type keys: C{str}s + @return: new version dict + @rtype: C{dict} of C{str} + + >>> filter_version({'epoch': 'foo', 'upstreamversion': 'bar', 'vendor': 'baz'}, 'vendor').keys() + ['epoch', 'upstreamversion'] + >>> filter_version({'epoch': 'foo', 'upstreamversion': 'bar', 'revision': 'baz'}, 'epoch', 'revision').keys() + ['upstreamversion'] + """ + return {k: evr[k] for k in evr if k not in keys} + + # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/lib_rpm.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/lib_rpm.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/lib_rpm.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/lib_rpm.py 2017-02-11 19:33:12.000000000 +0000 @@ -26,8 +26,8 @@ librpm = __import__(RpmPkgPolicy.python_rpmlib_module_name) except ImportError: gbp.log.warn("Failed to import '%s' as rpm python module, using host's " - "default rpm library instead" % - RpmPkgPolicy.python_rpmlib_module_name) + "default rpm library instead" % + RpmPkgPolicy.python_rpmlib_module_name) import rpm as librpm # Module initialization @@ -44,4 +44,3 @@ if truncate: _rpmlogfd.truncate(0) return log - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/linkedlist.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/linkedlist.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/linkedlist.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/linkedlist.py 2017-02-11 19:33:12.000000000 +0000 @@ -59,7 +59,6 @@ data = "" self._data = data - def delete(self): """Delete node""" if self.prev: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/policy.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/policy.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/rpm/policy.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/rpm/policy.py 2017-02-11 19:33:12.000000000 +0000 @@ -17,7 +17,10 @@ """Default packaging policy for RPM""" import re + from gbp.pkg import PkgPolicy, parse_archive_filename +from gbp.scripts.common.pq import parse_gbp_commands + class RpmPkgPolicy(PkgPolicy): """Packaging policy for RPM""" @@ -33,15 +36,15 @@ # Regexp for checking the validity of package name packagename_re = re.compile("^[%s][%s%s]+$" % - (alnum, alnum, name_whitelist_chars)) + (alnum, alnum, name_whitelist_chars)) packagename_msg = ("Package names must be at least two characters long, " "start with an alphanumeric and can only contain " "alphanumerics or characters in %s" % - list(name_whitelist_chars)) + list(name_whitelist_chars)) # Regexp for checking the validity of package (upstream) version upstreamversion_re = re.compile("^[0-9][%s%s]*$" % - (alnum, version_whitelist_chars)) + (alnum, version_whitelist_chars)) upstreamversion_msg = ("Upstream version numbers must start with a digit " "and can only containg alphanumerics or characters " "in %s" % list(version_whitelist_chars)) @@ -70,3 +73,128 @@ return True return False + class Changelog(object): + """Container for changelog related policy settings""" + + # Regexps for splitting/parsing the changelog section (of + # Tizen / Fedora style changelogs) + section_match_re = r'^\*' + section_split_re = r'^\*\s*(?P\S.*?)$\n(?P.*)' + header_split_re = r'(?P\S.*\s[0-9]{4})\s+(?P\S.*$)' + header_name_split_re = r'(?P[^<]*)\s+<(?P[^>]+)>((\s*-)?\s+(?P\S+))?$' + body_name_re = r'\[(?P.*)\]' + + # Changelog header format (when writing out changelog) + header_format = "* %(time)s %(name)s <%(email)s> %(revision)s" + header_time_format = "%a %b %d %Y" + header_rev_format = "%(version)s" + + class ChangelogEntryFormatter(object): + """Helper class for generating changelog entries from git commits""" + + # Maximum length for a changelog entry line + max_entry_line_length = 76 + # Bug tracking system related meta tags recognized from git commit msg + bts_meta_tags = ("Close", "Closes", "Fixes", "Fix") + # Regexp for matching bug tracking system ids (e.g. "bgo#123") + bug_id_re = r'[A-Za-z0-9#_\-]+' + + @classmethod + def _parse_bts_tags(cls, lines, meta_tags): + """ + Parse and filter out bug tracking system related meta tags from + commit message. + + @param lines: commit message + @type lines: C{list} of C{str} + @param meta_tags: meta tags to look for + @type meta_tags: C{tuple} of C{str} + @return: bts-ids per meta tag and the non-mathced lines + @rtype: (C{dict}, C{list} of C{str}) + """ + tags = {} + other_lines = [] + bts_re = re.compile(r'^(?P%s):\s*(?P.*)' % + ('|'.join(meta_tags)), re.I) + bug_id_re = re.compile(cls.bug_id_re) + for line in lines: + match = bts_re.match(line) + if match: + tag = match.group('tag') + ids_str = match.group('ids') + bug_ids = [bug_id.strip() for bug_id in + bug_id_re.findall(ids_str)] + if tag in tags: + tags[tag] += bug_ids + else: + tags[tag] = bug_ids + else: + other_lines.append(line) + return (tags, other_lines) + + @classmethod + def _extra_filter(cls, lines, ignore_re): + """ + Filter out specific lines from the commit message. + + @param lines: commit message + @type lines: C{list} of C{str} + @param ignore_re: regexp for matching ignored lines + @type ignore_re: C{str} + @return: filtered commit message + @rtype: C{list} of C{str} + """ + if ignore_re: + match = re.compile(ignore_re) + return [line for line in lines if not match.match(line)] + else: + return lines + + @classmethod + def compose(cls, commit_info, **kwargs): + """ + Generate a changelog entry from a git commit. + + @param commit_info: info about the commit + @type commit_info: C{commit_info} object from + L{gbp.git.repository.GitRepository.get_commit_info()}. + @param kwargs: additional arguments to the compose() method, + currently we recognize 'full', 'id_len' and 'ignore_re' + @type kwargs: C{dict} + @return: formatted changelog entry + @rtype: C{list} of C{str} + """ + # Parse and filter out gbp command meta-tags + cmds, body = parse_gbp_commands(commit_info, 'gbp-rpm-ch', + ('ignore', 'short', 'full'), ()) + body = body.splitlines() + if 'ignore' in cmds: + return None + + # Parse and filter out bts-related meta-tags + bts_tags, body = cls._parse_bts_tags(body, cls.bts_meta_tags) + + # Additional filtering + body = cls._extra_filter(body, kwargs['ignore_re']) + + # Generate changelog entry + subject = commit_info['subject'] + commitid = commit_info['id'] + if kwargs['id_len']: + text = ["- [%s] %s" % (commitid[0:kwargs['id_len']], subject)] + else: + text = ["- %s" % subject] + + # Add all non-filtered-out lines from commit message, unless 'short' + if (kwargs['full'] or 'full' in cmds) and 'short' not in cmds: + # Add all non-blank body lines. + text.extend([" " + line for line in body if line.strip()]) + + # Add bts tags and ids in the end + for tag, ids in bts_tags.iteritems(): + bts_msg = " (%s: %s)" % (tag, ', '.join(ids)) + if len(text[-1]) + len(bts_msg) >= cls.max_entry_line_length: + text.append(" ") + text[-1] += bts_msg + + return text diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/buildpackage.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/buildpackage.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/buildpackage.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/buildpackage.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,7 +1,6 @@ - # vim: set fileencoding=utf-8 : # -# (C) 2006-2016 Guido Günther +# (C) 2006-2017 Guido Günther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -18,9 +17,9 @@ # """Build a Debian package out of a Git repository""" -from six.moves import configparser import errno -import os, os.path +import os +import pipes import shutil import sys import time @@ -42,17 +41,20 @@ git_archive_submodules, git_archive_single, dump_tree, write_wc, drop_index) +from gbp.scripts.common import ExitCodes +from gbp.scripts.common.hook import Hook from gbp.pkg import compressor_opts, compressor_aliases, parse_archive_filename -#{ upstream tarball preparation -def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submodules, subtarball=None): + +# upstream tarball preparation +def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submodules, component=None): "create a compressed orig tarball in output_dir using git_archive" try: comp_opts = compressor_opts[comp_type][0] except KeyError: raise GbpError("Unsupported compression type '%s'" % comp_type) - output = os.path.join(output_dir, du.orig_file(cp, comp_type, subtarball=subtarball)) + output = os.path.join(output_dir, du.orig_file(cp, comp_type, component=component)) prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version']) try: @@ -89,8 +91,8 @@ options.tarball_dir) orig_files = [du.orig_file(cp, options.comp_type)] - if options.subtarballs: - orig_files += [du.orig_file(cp, options.comp_type, sub) for sub in options.subtarballs] + if options.components: + orig_files += [du.orig_file(cp, options.comp_type, c) for c in options.components] # look in tarball_dir first, if found force a symlink to it if options.tarball_dir: @@ -109,6 +111,7 @@ upstream_tree = git_archive_build_orig(repo, cp, output_dir, options) if options.pristine_tar_commit: pristine_tar_commit(repo, cp, options, output_dir, orig_files[0], upstream_tree) + pristine_tar_verify_orig(repo, cp, options, output_dir, orig_files) def pristine_tar_commit(repo, cp, options, output_dir, orig_file, upstream_tree): @@ -123,9 +126,8 @@ archive) repo.pristine_tar.commit(archive, upstream_tree) -#} -#{ Functions to handle export-dir +# Functions to handle export-dir def write_tree(repo, options): """ Write a tree of the index or working copy if necessary @@ -178,7 +180,7 @@ def move_old_export(target): """move a build tree away if it exists""" try: - os.mkdir(target) + os.makedirs(target) except OSError as e: if e.errno == errno.EEXIST: os.rename(target, "%s.obsolete.%s" % (target, time.time())) @@ -207,10 +209,10 @@ if os.path.exists(underlay_debian_dir) and os.path.exists(format_file): format = DebianSourceFormat.parse_file(format_file) if format.version in ['2.0', '3.0']: - gbp.log.info("Removing debian/ from unpacked upstream source at %s" % underlay_debian_dir) + gbp.log.info("Removing debian/ from unpacked upstream " + "source at %s" % underlay_debian_dir) shutil.rmtree(underlay_debian_dir) -#} def source_vfs(repo, options, tree): """Init source package info either from git or from working copy""" @@ -220,7 +222,7 @@ source = DebianSource(GitVfs(repo, tree)) else: source = DebianSource('.') - source.is_native() # check early if this works + source.is_native() # check early if this works except Exception as e: raise GbpError("Can't determine package type: %s" % e) return source @@ -228,19 +230,31 @@ def prepare_output_dir(dir): """Prepare the directory where the build result will be put""" - output_dir = dir - if not dir: - output_dir = '..' - output_dir = os.path.abspath(output_dir) + output_dir = os.path.abspath(dir or '..') try: - os.mkdir(output_dir) + os.makedirs(output_dir) except OSError as e: if e.errno != errno.EEXIST: raise GbpError("Cannot create output dir %s" % output_dir) return output_dir +def pristine_tar_prepare_orig_tree(repo, cp, options): + """Make sure the upstream tree exists + In case of component tarballs we need to recreate a tree for the + main tarball without the component subdirs. + """ + if options.components: + try: + upstream_tag = repo.version_to_tag(options.upstream_tag, cp.upstream_version) + tree_name = "%s^{tree}" % upstream_tag + repo.tree_drop_dirs(tree_name, options.components) + except GitRepositoryError: + raise GbpError("Couldn't find upstream tree '%s' to create " + "orig tarball via pristine-tar" % tree_name) + + def pristine_tar_build_orig(repo, cp, output_dir, options): """ Build orig tarball using pristine-tar @@ -252,27 +266,18 @@ gbp.log.warn('Pristine-tar branch "%s" not found' % repo.pristine_tar.branch) - # Make sure the upstream tree exists, it might not be there in - # case of subtarballs since we don't keep a ref to it - if options.subtarballs: - try: - upstream_tag = repo.version_to_tag(options.upstream_tag, cp.upstream_version) - tree_name = "%s^{tree}" % upstream_tag - repo.tree_drop_dirs(tree_name, options.subtarballs) - except GitRepositoryError: - raise GbpError("Couldn't find upstream tree '%s' to create orig tarball via pristine-tar" % tree_name) - + pristine_tar_prepare_orig_tree(repo, cp, options) try: repo.pristine_tar.checkout(cp.name, cp.upstream_version, options.comp_type, output_dir) - for subtarball in options.subtarballs: + for component in options.components: repo.pristine_tar.checkout(cp.name, cp.upstream_version, options.comp_type, output_dir, - subtarball=subtarball) + component=component) return True except CommandExecFailed: if options.pristine_tar_commit: @@ -284,6 +289,21 @@ return False +def pristine_tar_verify_orig(repo, cp, options, output_dir, orig_files): + """ + Verify orig tarballs using prstine tar + + @returns: C{True} if tarball was build, C{False} otherwise + """ + if not options.pristine_tar: + return True + + pristine_tar_prepare_orig_tree(repo, cp, options) + for f in orig_files: + repo.pristine_tar.verify(os.path.join(output_dir, f)) + return True + + def get_upstream_tree(repo, cp, options): """Determine the upstream tree from the given options""" if options.upstream_tree.upper() == 'TAG': @@ -319,28 +339,31 @@ gbp.log.info("Creating %s from '%s'" % (du.orig_file(cp, options.comp_type), upstream_tree)) - gbp.log.debug("Building upstream tarball with compression '%s -%s'" % - (options.comp_type, options.comp_level)) - main_tree = repo.tree_drop_dirs(upstream_tree, options.subtarballs) + comp_level = int(options.comp_level) if options.comp_level != '' else None + gbp.log.debug("Building upstream tarball with compression '%s'%s" % + (options.comp_type, + "' -%s'" % comp_level if comp_level is not None else '')) + main_tree = repo.tree_drop_dirs(upstream_tree, options.components) if options.components else upstream_tree if not git_archive(repo, cp, output_dir, main_tree, options.comp_type, - options.comp_level, + comp_level, options.with_submodules): raise GbpError("Cannot create upstream tarball at '%s'" % output_dir) - for subtarball in options.subtarballs: - subtree = repo.tree_get_dir(upstream_tree, subtarball) + for component in options.components: + subtree = repo.tree_get_dir(upstream_tree, component) if not subtree: - raise GbpError("No tree for '%s' found in '%s' to create subtarball from" % (subtarball, upstream_tree)) - gbp.log.info("Creating subtarball '%s' from '%s'" % (du.orig_file(cp, - options.comp_type, - subtarball=subtarball), - subtree)) + raise GbpError("No tree for '%s' found in '%s' to create additional tarball from" + % (component, upstream_tree)) + gbp.log.info("Creating additional tarball '%s' from '%s'" + % (du.orig_file(cp, options.comp_type, component=component), + subtree)) if not git_archive(repo, cp, output_dir, subtree, options.comp_type, - options.comp_level, + comp_level, options.with_submodules, - subtarball=subtarball): - raise GbpError("Cannot create upstream component tarball %s at '%s'" % (subtarball, output_dir)) + component=component): + raise GbpError("Cannot create additional tarball %s at '%s'" + % (component, output_dir)) return upstream_tree @@ -410,7 +433,7 @@ vendor = du.get_vendor().lower() suite = parts[1] if vendor == parts[0]: - dist = '' if suite == 'sid' else suite + dist = '' if suite in ['sid', 'master'] else suite else: dist = '%s_%s' % (parts[0], suite) elif len(parts) == 1 and native and branch in ['master', 'sid']: @@ -442,7 +465,8 @@ options.cleaner = '/bin/true' dist = get_pbuilder_dist(options, repo, native) - pbd_env['GBP_PBUILDER_DIST'] = pbd_env['DIST'] = pr_dist = dist + pbd_env['GBP_PBUILDER_DIST'] = pbd_env['DIST'] = dist + pr_dist = dist or 'sid' if options.pbuilder_arch: arch = options.pbuilder_arch pbd_env['GBP_PBUILDER_ARCH'] = pbd_env['ARCH'] = arch @@ -487,32 +511,32 @@ return os.getenv('ARCH', None) or du.get_arch() -def md(a, b): - "Merge two dictionaires a and b" - c = a.copy() - c.update(b) - return c - - def build_parser(name, prefix=None): try: parser = GbpOptionParserDebian(command=os.path.basename(name), prefix=prefix) - except configparser.ParsingError as err: + except GbpError as err: gbp.log.err(err) return None - tag_group = GbpOptionGroup(parser, "tag options", "options related to git tag creation") - branch_group = GbpOptionGroup(parser, "branch options", "branch layout options") - cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke external commands and hooks") - orig_group = GbpOptionGroup(parser, "orig tarball options", "options related to the creation of the orig tarball") - export_group = GbpOptionGroup(parser, "export build-tree options", "alternative build tree related options") - parser.add_option_group(tag_group) - parser.add_option_group(orig_group) - parser.add_option_group(branch_group) - parser.add_option_group(cmd_group) - parser.add_option_group(export_group) + tag_group = GbpOptionGroup(parser, + "tag options", + "options related to git tag creation") + orig_group = GbpOptionGroup(parser, + "orig tarball options", + "options related to the creation of the orig tarball") + branch_group = GbpOptionGroup(parser, + "branch options", + "branch layout options") + cmd_group = GbpOptionGroup(parser, + "external command options", + "how and when to invoke external commands and hooks") + export_group = GbpOptionGroup(parser, + "export build-tree options", + "alternative build tree related options") + for group in [tag_group, orig_group, branch_group, cmd_group, export_group]: + parser.add_option_group(group) - parser.add_boolean_config_file_option(option_name = "ignore-new", dest="ignore_new") + parser.add_boolean_config_file_option(option_name="ignore-new", dest="ignore_new") parser.add_option("--git-verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") parser.add_config_file_option(option_name="color", dest="color", type='tristate') @@ -520,11 +544,11 @@ dest="color_scheme") parser.add_config_file_option(option_name="notify", dest="notify", type='tristate') tag_group.add_option("--git-tag", action="store_true", dest="tag", default=False, - help="create a tag after a successful build") + help="create a tag after a successful build") tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only", default=False, - help="don't build, only tag and run the posttag hook") + help="don't build, only tag and run the posttag hook") tag_group.add_option("--git-retag", action="store_true", dest="retag", default=False, - help="don't fail if the tag already exists") + help="don't fail if the tag already exists") tag_group.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags") tag_group.add_config_file_option(option_name="keyid", dest="keyid") tag_group.add_config_file_option(option_name="debian-tag", dest="debian_tag") @@ -535,44 +559,53 @@ orig_group.add_boolean_config_file_option(option_name="pristine-tar-commit", dest="pristine_tar_commit") orig_group.add_config_file_option(option_name="force-create", dest="force_create", - help="force creation of orig tarball", action="store_true") + help="force creation of orig tarball", action="store_true") orig_group.add_config_file_option(option_name="no-create-orig", dest="no_create_orig", - help="don't create orig tarball", action="store_true") + help="don't create orig tarball", action="store_true") orig_group.add_config_file_option(option_name="tarball-dir", dest="tarball_dir", type="path", - help="location to look for external tarballs") + help="location to look for external tarballs") orig_group.add_config_file_option(option_name="compression", dest="comp_type", - help="Compression type, default is '%(compression)s'") + help="Compression type, default is '%(compression)s'") orig_group.add_config_file_option(option_name="compression-level", dest="comp_level", - help="Compression level, default is '%(compression-level)s'") - orig_group.add_option("--git-subtarball", action="append", metavar='SUBTARBALL', - dest="subtarballs", help="subtarsball to generate, can be given multiple times", default=[]) + help="Compression level, default is '%(compression-level)s'") + orig_group.add_config_file_option("component", action="append", metavar='COMPONENT', + dest="components") branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch") - branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch") - branch_group.add_boolean_config_file_option(option_name = "submodules", dest="with_submodules") + branch_group.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch") + branch_group.add_boolean_config_file_option(option_name="submodules", dest="with_submodules") cmd_group.add_config_file_option(option_name="builder", dest="builder", - help="command to build the Debian package, default is '%(builder)s'") + help="command to build the Debian package, " + "default is '%(builder)s'") cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner", - help="command to clean the working copy, default is '%(cleaner)s'") + help="command to clean the working copy, " + "default is '%(cleaner)s'") cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild", - help="hook to run before a build, default is '%(prebuild)s'") + help="hook to run before a build, " + "default is '%(prebuild)s'") cmd_group.add_config_file_option(option_name="postexport", dest="postexport", - help="hook to run after exporting the source tree, default is '%(postexport)s'") + help="hook to run after exporting the source tree, " + "default is '%(postexport)s'") cmd_group.add_config_file_option(option_name="postbuild", dest="postbuild", - help="hook run after a successful build, default is '%(postbuild)s'") + help="hook run after a successful build, " + "default is '%(postbuild)s'") cmd_group.add_config_file_option(option_name="posttag", dest="posttag", - help="hook run after a successful tag operation, default is '%(posttag)s'") + help="hook run after a successful tag operation, " + "default is '%(posttag)s'") cmd_group.add_boolean_config_file_option(option_name="pbuilder", dest="use_pbuilder") cmd_group.add_boolean_config_file_option(option_name="qemubuilder", dest="use_qemubuilder") cmd_group.add_config_file_option(option_name="dist", dest="pbuilder_dist") cmd_group.add_config_file_option(option_name="arch", dest="pbuilder_arch") - cmd_group.add_boolean_config_file_option(option_name = "pbuilder-autoconf", dest="pbuilder_autoconf") + cmd_group.add_boolean_config_file_option(option_name="pbuilder-autoconf", + dest="pbuilder_autoconf") cmd_group.add_config_file_option(option_name="pbuilder-options", dest="pbuilder_options") cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks") export_group.add_config_file_option(option_name="export-dir", dest="export_dir", type="path", - help="before building the package export the source into EXPORT_DIR, default is '%(export-dir)s'") + help="before building the package export the source into EXPORT_DIR, " + "default is '%(export-dir)s'") export_group.add_config_file_option("export", dest="export", - help="export treeish object TREEISH, default is '%(export)s'", metavar="TREEISH") + help="export treeish object TREEISH, " + "default is '%(export)s'", metavar="TREEISH") export_group.add_boolean_config_file_option(option_name="purge", dest="purge") export_group.add_option("--git-dont-purge", action="store_true", dest="dont_purge", default=False, help="deprecated, use --git-no-purge instead") @@ -581,11 +614,11 @@ def parse_args(argv, prefix): - args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == 0 ] - dpkg_args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == -1 ] + args = [arg for arg in argv[1:] if arg.find('--%s' % prefix) == 0] + dpkg_args = [arg for arg in argv[1:] if arg.find('--%s' % prefix) == -1] # We handle these although they don't have a --git- prefix - for arg in [ "--help", "-h", "--version" ]: + for arg in ["--help", "-h", "--version"]: if arg in dpkg_args: args.append(arg) @@ -599,7 +632,8 @@ disable_hooks(options) if options.retag: if not options.tag and not options.tag_only: - gbp.log.err("'--%sretag' needs either '--%stag' or '--%stag-only'" % (prefix, prefix, prefix)) + gbp.log.err("'--%sretag' needs either '--%stag' or '--%stag-only'" + % (prefix, prefix, prefix)) return None, None, None if options.overlay and not options.export_dir: @@ -608,25 +642,16 @@ # --git-dont-purge is deprecated: if options.dont_purge: - gbp.log.warning("--git-dont-purge is depreceted, use --git-no-purge instead") + gbp.log.warn("--git-dont-purge is depreceted, use --git-no-purge instead") options.purge = False - if options.subtarballs and options.pristine_tar_commit: - gbp.log.warning("Subtarballs specified, pristine-tar-commit not yet supported - disabling it.") + if options.components and options.pristine_tar_commit: + gbp.log.warn("Components specified, pristine-tar-commit not yet supported - disabling it.") options.pristine_tar_commit = False return options, args, dpkg_args -class Hook(RunAtCommand): - "A hook run during the build" - def __init__(self, name, *args, **kwargs): - if 'shell' not in kwargs: - kwargs['shell'] = True - RunAtCommand.__init__(self, *args, **kwargs) - self.run_error = '%s-hook %s' % (name, self.run_error) - - def main(argv): retval = 0 prefix = "git-" @@ -637,15 +662,13 @@ options, gbp_args, dpkg_args = parse_args(argv, prefix) if not options: - return 1 + return ExitCodes.parse_error try: repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) return 1 - else: - repo_dir = os.path.abspath(os.path.curdir) try: Command(options.cleaner, shell=True)() @@ -700,9 +723,9 @@ # Run postexport hook if options.postexport: Hook('Postexport', options.postexport, - extra_env=md(hook_env, - {'GBP_GIT_DIR': repo.git_dir, - 'GBP_TMP_DIR': tmp_dir}) + extra_env=Hook.md(hook_env, + {'GBP_GIT_DIR': repo.git_dir, + 'GBP_TMP_DIR': tmp_dir}) )(dir=tmp_dir) major = (source.changelog.debian_version if source.is_native() @@ -716,23 +739,23 @@ if not source.is_native() and options.postexport: prepare_upstream_tarball(repo, source.changelog, options, tarball_dir, output_dir) - - if options.export_dir: build_dir = export_dir else: - build_dir = repo_dir + build_dir = repo.path if options.prebuild: Hook('Prebuild', options.prebuild, - extra_env=md(hook_env, - {'GBP_GIT_DIR': repo.git_dir, - 'GBP_BUILD_DIR': build_dir}) + extra_env=Hook.md(hook_env, + {'GBP_GIT_DIR': repo.git_dir, + 'GBP_BUILD_DIR': build_dir}) )(dir=build_dir) # Finally build the package: - RunAtCommand(options.builder, dpkg_args, shell=True, - extra_env=md(build_env, - {'GBP_BUILD_DIR': build_dir}) + RunAtCommand(options.builder, + [pipes.quote(arg) for arg in dpkg_args], + shell=True, + extra_env=Hook.md(build_env, + {'GBP_BUILD_DIR': build_dir}) )(dir=build_dir) if options.postbuild: changes = os.path.abspath("%s/../%s_%s_%s.changes" % @@ -742,9 +765,9 @@ changes_file_suffix(dpkg_args))) gbp.log.debug("Looking for changes file %s" % changes) Hook('Postbuild', options.postbuild, - extra_env=md(hook_env, - {'GBP_CHANGES_FILE': changes, - 'GBP_BUILD_DIR': build_dir}) + extra_env=Hook.md(hook_env, + {'GBP_CHANGES_FILE': changes, + 'GBP_BUILD_DIR': build_dir}) )() if options.tag or options.tag_only: tag = repo.version_to_tag(options.debian_tag, source.changelog.version) @@ -762,11 +785,14 @@ if options.posttag: sha = repo.rev_parse("%s^{}" % tag) Hook('Posttag', options.posttag, - extra_env=md(hook_env, - {'GBP_TAG': tag, - 'GBP_BRANCH': branch or '(no branch)', - 'GBP_SHA1': sha}) + extra_env=Hook.md(hook_env, + {'GBP_TAG': tag, + 'GBP_BRANCH': branch or '(no branch)', + 'GBP_SHA1': sha}) )() + except KeyboardInterrupt: + retval = 1 + gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except (GbpError, GitRepositoryError) as err: @@ -778,7 +804,7 @@ source = None retval = 1 finally: - drop_index() + drop_index(repo) if not options.tag_only: if options.export_dir and options.purge and not retval: @@ -793,6 +819,7 @@ return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/buildpackage_rpm.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/buildpackage_rpm.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/buildpackage_rpm.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/buildpackage_rpm.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006-2011,2015 Guido Guenther +# (C) 2006-2011,2015-2017 Guido Günther # (C) 2012-2015 Intel Corporation # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ # """Build an RPM package out of a Git repository""" -from six.moves import configparser import os +import pipes import shutil import sys @@ -34,6 +34,7 @@ from gbp.rpm.git import GitRepositoryError, RpmGitRepository from gbp.rpm.policy import RpmPkgPolicy from gbp.tmpfile import init_tmpdir, del_tmpdir, tempfile +from gbp.scripts.common import ExitCodes from gbp.scripts.common.buildpackage import (index_name, wc_name, git_archive_submodules, git_archive_single, dump_tree, @@ -78,8 +79,8 @@ git_archive_single(treeish, output, prefix, spec.orig_src['compression'], comp_level, comp_opts, spec.orig_src['archive_fmt']) - except (GitRepositoryError, CommandExecFailed): - gbp.log.err("Error generating submodules' archives") + except (GitRepositoryError, CommandExecFailed) as e: + gbp.log.err("Error generating submodules' archives: %s" % e) return False return True @@ -185,23 +186,6 @@ return branch -def get_vcs_info(repo, treeish): - """Get the info for spec vcs tag""" - info = {} - try: - info['tagname'] = repo.describe(treeish, longfmt=True, always=True, - abbrev=40) - info['commit'] = repo.rev_parse('%s^0' % treeish) - info['commitish'] = repo.rev_parse('%s' % treeish) - except GitRepositoryError: - # If tree is not commit-ish, expect it to be from current HEAD - info['tagname'] = repo.describe('HEAD', longfmt=True, always=True, - abbrev=40) + '-dirty' - info['commit'] = repo.rev_parse('HEAD') + '-dirty' - info['commitish'] = info['commit'] - return info - - def git_archive_build_orig(repo, spec, output_dir, options): """ Build orig tarball using git-archive @@ -223,11 +207,13 @@ gbp.log.info("%s does not exist, creating from '%s'" % (spec.orig_src['filename'], upstream_tree)) if spec.orig_src['compression']: + comp_level = int(options.comp_level) if options.comp_level != '' else None + comp_level_msg = "' -%s'" % comp_level if comp_level is not None else '' gbp.log.debug("Building upstream source archive with compression " "'%s -%s'" % (spec.orig_src['compression'], - options.comp_level)) + comp_level_msg)) if not git_archive(repo, spec, output_dir, upstream_tree, - orig_prefix, options.comp_level, + orig_prefix, comp_level, options.with_submodules): raise GbpError("Cannot create upstream tarball at '%s'" % output_dir) @@ -246,7 +232,7 @@ remote, branch = remote_branch.split('/', 1) if branch == options.upstream_branch: gbp.log.debug("Found upstream branch '%s' from remote '%s'" % - (remote, branch)) + (remote, branch)) return False return True @@ -259,9 +245,9 @@ if len(builder_args) == 0: builder_args.append('-ba') builder_args.extend([ - '--define "_topdir %s"' % os.path.abspath(options.export_dir), - '--define "_specdir %%_topdir/%s"' % options.export_specdir, - '--define "_sourcedir %%_topdir/%s"' % options.export_sourcedir]) + '--define', "_topdir %s" % os.path.abspath(options.export_dir), + '--define', "_specdir %%_topdir/%s" % options.export_specdir, + '--define', "_sourcedir %%_topdir/%s" % options.export_sourcedir]) def packaging_tag_data(repo, commit, name, version, options): @@ -317,20 +303,20 @@ try: parser = GbpOptionParserRpm(command=os.path.basename(name), prefix=prefix) - except configparser.ParsingError as err: + except GbpError as err: gbp.log.err(err) return None tag_group = GbpOptionGroup(parser, "tag options", - "options related to git tag creation") + "options related to git tag creation") branch_group = GbpOptionGroup(parser, "branch options", - "branch layout options") + "branch layout options") cmd_group = GbpOptionGroup(parser, "external command options", - "how and when to invoke external commands and hooks") + "how and when to invoke external commands and hooks") orig_group = GbpOptionGroup(parser, "orig tarball options", - "options related to the creation of the orig tarball") + "options related to the creation of the orig tarball") export_group = GbpOptionGroup(parser, "export build-tree options", - "alternative build tree related options") + "alternative build tree related options") parser.add_option_group(tag_group) parser.add_option_group(orig_group) parser.add_option_group(branch_group) @@ -338,83 +324,83 @@ parser.add_option_group(export_group) parser.add_boolean_config_file_option(option_name="ignore-new", - dest="ignore_new") + dest="ignore_new") parser.add_option("--git-verbose", action="store_true", dest="verbose", - default=False, help="verbose command execution") + default=False, help="verbose command execution") parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir") parser.add_config_file_option(option_name="color", dest="color", - type='tristate') + type='tristate') parser.add_config_file_option(option_name="color-scheme", - dest="color_scheme") + dest="color_scheme") parser.add_config_file_option(option_name="notify", dest="notify", - type='tristate') + type='tristate') parser.add_config_file_option(option_name="vendor", action="store", - dest="vendor") + dest="vendor") parser.add_config_file_option(option_name="native", dest="native", - type='tristate') + type='tristate') tag_group.add_option("--git-tag", action="store_true", dest="tag", - default=False, - help="create a tag after a successful build") + default=False, + help="create a tag after a successful build") tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only", - default=False, - help="don't build, only tag and run the posttag hook") + default=False, + help="don't build, only tag and run the posttag hook") tag_group.add_option("--git-retag", action="store_true", dest="retag", - default=False, help="don't fail if the tag already exists") + default=False, help="don't fail if the tag already exists") tag_group.add_boolean_config_file_option(option_name="sign-tags", - dest="sign_tags") + dest="sign_tags") tag_group.add_config_file_option(option_name="keyid", dest="keyid") tag_group.add_config_file_option(option_name="packaging-tag", - dest="packaging_tag") + dest="packaging_tag") tag_group.add_config_file_option(option_name="packaging-tag-msg", - dest="packaging_tag_msg") + dest="packaging_tag_msg") tag_group.add_config_file_option(option_name="upstream-tag", - dest="upstream_tag") + dest="upstream_tag") orig_group.add_config_file_option(option_name="upstream-tree", - dest="upstream_tree") + dest="upstream_tree") orig_group.add_boolean_config_file_option(option_name="pristine-tar", - dest="pristine_tar") + dest="pristine_tar") orig_group.add_boolean_config_file_option(option_name="pristine-tar-commit", - dest="pristine_tar_commit") + dest="pristine_tar_commit") orig_group.add_config_file_option(option_name="force-create", - dest="force_create", action="store_true", - help="force creation of upstream source tarball") + dest="force_create", action="store_true", + help="force creation of upstream source tarball") orig_group.add_config_file_option(option_name="no-create-orig", - dest="no_create_orig", action="store_true", - help="don't create upstream source tarball") + dest="no_create_orig", action="store_true", + help="don't create upstream source tarball") orig_group.add_config_file_option(option_name="tarball-dir", - dest="tarball_dir", type="path", - help="location to look for external tarballs") + dest="tarball_dir", type="path", + help="location to look for external tarballs") orig_group.add_config_file_option(option_name="compression-level", - dest="comp_level", - help="Compression level, default is " - "'%(compression-level)s'") + dest="comp_level", + help="Compression level, default is " + "'%(compression-level)s'") branch_group.add_config_file_option(option_name="upstream-branch", - dest="upstream_branch") + dest="upstream_branch") branch_group.add_config_file_option(option_name="packaging-branch", - dest="packaging_branch") - branch_group.add_boolean_config_file_option(option_name = "ignore-branch", - dest="ignore_branch") - branch_group.add_boolean_config_file_option(option_name = "submodules", - dest="with_submodules") + dest="packaging_branch") + branch_group.add_boolean_config_file_option(option_name="ignore-branch", + dest="ignore_branch") + branch_group.add_boolean_config_file_option(option_name="submodules", + dest="with_submodules") cmd_group.add_config_file_option(option_name="builder", dest="builder", - help="command to build the package, default is " - "'%(builder)s'") + help="command to build the package, default is " + "'%(builder)s'") cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner", - help="command to clean the working copy, default is " - "'%(cleaner)s'") + help="command to clean the working copy, default is " + "'%(cleaner)s'") cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild", - help="command to run before a build, default is " - "'%(prebuild)s'") + help="command to run before a build, default is " + "'%(prebuild)s'") cmd_group.add_config_file_option(option_name="postexport", - dest="postexport", - help="command to run after exporting the source tree, " - "default is '%(postexport)s'") + dest="postexport", + help="command to run after exporting the source tree, " + "default is '%(postexport)s'") cmd_group.add_config_file_option(option_name="postbuild", dest="postbuild", - help="hook run after a successful build, default is " - "'%(postbuild)s'") + help="hook run after a successful build, default is " + "'%(postbuild)s'") cmd_group.add_config_file_option(option_name="posttag", dest="posttag", - help="hook run after a successful tag operation, default " - "is '%(posttag)s'") + help="hook run after a successful tag operation, default " + "is '%(posttag)s'") cmd_group.add_boolean_config_file_option(option_name="mock", dest="use_mock") cmd_group.add_config_file_option(option_name="dist", dest="mock_dist") cmd_group.add_config_file_option(option_name="arch", dest="mock_arch") @@ -422,24 +408,24 @@ cmd_group.add_config_file_option(option_name="mock-options", dest="mock_options") cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks") export_group.add_option("--git-no-build", action="store_true", - dest="no_build", - help="Don't run builder or the associated hooks") + dest="no_build", + help="Don't run builder or the associated hooks") export_group.add_config_file_option(option_name="export-dir", - dest="export_dir", type="path", - help="Build topdir, also export the sources under " - "EXPORT_DIR, default is '%(export-dir)s'") + dest="export_dir", type="path", + help="Build topdir, also export the sources under " + "EXPORT_DIR, default is '%(export-dir)s'") export_group.add_config_file_option(option_name="export-specdir", - dest="export_specdir", type="path") + dest="export_specdir", type="path") export_group.add_config_file_option(option_name="export-sourcedir", - dest="export_sourcedir", type="path") + dest="export_sourcedir", type="path") export_group.add_config_file_option("export", dest="export", - metavar="TREEISH", - help="export treeish object TREEISH, default is " - "'%(export)s'") + metavar="TREEISH", + help="export treeish object TREEISH, default is " + "'%(export)s'") export_group.add_config_file_option(option_name="packaging-dir", - dest="packaging_dir") + dest="packaging_dir") export_group.add_config_file_option(option_name="spec-file", - dest="spec_file") + dest="spec_file") return parser @@ -479,7 +465,7 @@ options, gbp_args, builder_args = parse_args(argv, prefix) if not options: - return 1 + return ExitCodes.parse_error try: repo = RpmGitRepository(os.path.curdir) @@ -562,14 +548,16 @@ # Just build source archive from the exported tree gbp.log.info("Creating (native) source archive %s from '%s'" % (spec.orig_src['filename'], tree)) + comp_level = int(options.comp_level) if options.comp_level != '' else None if spec.orig_src['compression']: + comp_level_msg = "' -%s'" % comp_level if comp_level is not None else '' gbp.log.debug("Building source archive with " - "compression '%s -%s'" % + "compression '%s%s'" % (spec.orig_src['compression'], - options.comp_level)) + comp_level_msg)) orig_prefix = spec.orig_src['prefix'] if not git_archive(repo, spec, source_dir, tree, - orig_prefix, options.comp_level, + orig_prefix, comp_level, options.with_submodules): raise GbpError("Cannot create source tarball at '%s'" % source_dir) @@ -597,7 +585,9 @@ spec.specfile)) else: builder_args.append(spec.specfile) - RunAtCommand(options.builder, builder_args, shell=True, + RunAtCommand(options.builder, + [pipes.quote(arg) for arg in builder_args], + shell=True, extra_env={'GBP_BUILD_DIR': export_dir} )(dir=export_dir) if options.postbuild: @@ -613,16 +603,15 @@ gbp.log.info("Tagging %s" % rpm.compose_version_str(spec.version)) tag = create_packaging_tag(repo, tree, spec.name, spec.version, options) - vcs_info = get_vcs_info(repo, tag) if options.posttag: sha = repo.rev_parse("%s^{}" % tag) Command(options.posttag, shell=True, extra_env={'GBP_TAG': tag, 'GBP_BRANCH': branch, 'GBP_SHA1': sha})() - else: - vcs_info = get_vcs_info(repo, tree) - + except KeyboardInterrupt: + retval = 1 + gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except GitRepositoryError as err: @@ -637,7 +626,7 @@ gbp.log.err(err) retval = 1 finally: - drop_index() + drop_index(repo) del_tmpdir() if not options.tag_only: @@ -652,5 +641,6 @@ return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/clone.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/clone.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/clone.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/clone.py 2017-02-11 19:33:12.000000000 +0000 @@ -19,13 +19,15 @@ # """Clone a Git repository and set it up for gbp""" -from six.moves import configparser import sys -import os, os.path +import os from gbp.config import (GbpOptionParser, GbpOptionGroup) from gbp.deb.git import DebianGitRepository from gbp.git import (GitRepository, GitRepositoryError) from gbp.errors import GbpError +from gbp.scripts.common import ExitCodes +from gbp.scripts.common import repo_setup +from gbp.scripts.common.hook import Hook import gbp.log @@ -33,12 +35,14 @@ try: parser = GbpOptionParser(command=os.path.basename(name), prefix='', usage='%prog [options] repository - clone a remote repository') - except configparser.ParsingError as err: + except GbpError as err: gbp.log.err(err) return None branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options") + cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke hooks") parser.add_option_group(branch_group) + parser.add_option_group(cmd_group) branch_group.add_option("--all", action="store_true", dest="all", default=False, help="track all branches, not only debian and upstream") @@ -49,16 +53,24 @@ help="git history depth (for creating shallow clones)") branch_group.add_option("--reference", action="store", dest="reference", default=None, help="git reference repository (use local copies where possible)") + cmd_group.add_config_file_option(option_name="postclone", dest="postclone", + help="hook to run after cloning the source tree, " + "default is '%(postclone)s'") + cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") parser.add_config_file_option(option_name="color", dest="color", type='tristate') parser.add_config_file_option(option_name="color-scheme", dest="color_scheme") + parser.add_config_file_option(option_name="repo-user", dest="repo_user", + choices=['DEBIAN', 'GIT']) + parser.add_config_file_option(option_name="repo-email", dest="repo_email", + choices=['DEBIAN', 'GIT']) return parser -def parse_args (argv): +def parse_args(argv): parser = build_parser(argv[0]) if not parser: return None, None @@ -73,7 +85,7 @@ (options, args) = parse_args(argv) if not options: - return 1 + return ExitCodes.parse_error if len(args) < 2: gbp.log.err("Need a repository to clone.") @@ -90,12 +102,14 @@ pass try: + gbp.log.info("Cloning from '%s'%s" % (source, " into '%s'" % clone_to if not auto_name else '')) repo = DebianGitRepository.clone(clone_to, source, options.depth, - auto_name=auto_name,reference=options.reference) + auto_name=auto_name, reference=options.reference) os.chdir(repo.path) # Reparse the config files of the cloned repository so we pick up the - # branch information from there: + # branch information from there but don't overwrite hooks: + postclone = options.postclone (options, args) = parse_args(argv) # Track all branches: @@ -103,22 +117,32 @@ remotes = repo.get_remote_branches() for remote in remotes: local = remote.replace("origin/", "", 1) - if not repo.has_branch(local) and \ - local != "HEAD": - repo.create_branch(local, remote) - else: # only track gbp's default branches - branches = [ options.debian_branch, options.upstream_branch ] + if (not repo.has_branch(local) and + local != "HEAD"): + repo.create_branch(local, remote) + else: # only track gbp's default branches + branches = [options.debian_branch, options.upstream_branch] if options.pristine_tar: - branches += [ repo.pristine_tar_branch ] + branches += [repo.pristine_tar_branch] gbp.log.debug('Will track branches: %s' % branches) for branch in branches: remote = 'origin/%s' % branch - if repo.has_branch(remote, remote=True) and \ - not repo.has_branch(branch): - repo.create_branch(branch, remote) + if (repo.has_branch(remote, remote=True) and + not repo.has_branch(branch)): + repo.create_branch(branch, remote) repo.set_branch(options.debian_branch) + repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo) + + if postclone: + Hook('Postclone', options.postclone, + extra_env={'GBP_GIT_DIR': repo.git_dir}, + )() + + except KeyboardInterrupt: + retval = 1 + gbp.log.err("Interrupted. Aborting.") except GitRepositoryError as err: gbp.log.err("Git command failed: %s" % err) retval = 1 @@ -129,6 +153,7 @@ return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/buildpackage.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/buildpackage.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/buildpackage.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/buildpackage.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006-2011 Guido Guenther +# (C) 2006-2011, 2016 Guido Guenther # (C) 2012 Intel Corporation # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,11 +18,13 @@ # """Common functionality for Debian and RPM buildpackage scripts""" -import os, os.path +import os +import os.path import pipes import tempfile import shutil from gbp.command_wrappers import (CatenateTarArchive, CatenateZipArchive) +from gbp.git import GitRepositoryError from gbp.errors import GbpError import gbp.log @@ -30,8 +32,6 @@ index_name = "INDEX" # when we want to reference the working copy in treeish context we call it: wc_name = "WC" -# index file name used to export working copy -wc_index = ".git/gbp_index" def sanitize_prefix(prefix): @@ -85,8 +85,12 @@ if comp_type: # Redirect through stdout directly to the correct output file in # order to avoid determining the output filename of the compressor - ret = os.system("%s --stdout -%s %s %s > %s" % - (comp_type, comp_level, comp_opts, main_archive, + try: + comp_level_opt = '-%d' % comp_level if comp_level is not None else '' + except TypeError: + raise GbpError("Invalid compression level '%s'" % comp_level) + ret = os.system("%s --stdout %s %s %s > %s" % + (comp_type, comp_level_opt, comp_opts, main_archive, output)) if ret: raise GbpError("Error creating %s: %d" % (output, ret)) @@ -105,14 +109,18 @@ prefix = sanitize_prefix(prefix) pipe = pipes.Template() pipe.prepend("git archive --format=%s --prefix=%s %s" % (format, prefix, treeish), '.-') + try: + comp_level_opt = '-%d' % comp_level if comp_level is not None else '' + except TypeError: + raise GbpError("Invalid compression level '%s'" % comp_level) if comp_type: - pipe.append('%s -c -%s %s' % (comp_type, comp_level, comp_opts), '--') + pipe.append('%s -c %s %s' % (comp_type, comp_level_opt, comp_opts), '--') ret = pipe.copy('', output) if ret: raise GbpError("Error creating %s: %d" % (output, ret)) -#{ Functions to handle export-dir +# Functions to handle export-dir def dump_tree(repo, export_dir, treeish, with_submodules, recursive=True): "dump a tree to output_dir" output_dir = os.path.dirname(export_dir) @@ -147,11 +155,11 @@ ret = pipe.copy('', '') os.chdir(top) if ret: - raise GbpError("Error in dump_tree archive pipe in submodule %s" % subdir) + raise GbpError("Error in dump_tree archive pipe in submodule %s" % subdir) except OSError as err: gbp.log.err("Error dumping tree to %s: %s" % (output_dir, err[0])) return False - except GbpError as err: + except (GitRepositoryError, GbpError) as err: gbp.log.err(err) return False except Exception as e: @@ -162,14 +170,21 @@ return True +def wc_index(repo): + """Get path of the temporary index file used for exporting working copy""" + return os.path.join(repo.git_dir, "gbp_index") + + def write_wc(repo, force=True): """write out the current working copy as a treeish object""" - repo.add_files(repo.path, force=force, index_file=wc_index) - tree = repo.write_tree(index_file=wc_index) + index_file = wc_index(repo) + repo.add_files(repo.path, force=force, index_file=index_file) + tree = repo.write_tree(index_file=index_file) return tree -def drop_index(): +def drop_index(repo): """drop our custom index""" - if os.path.exists(wc_index): - os.unlink(wc_index) + index_file = wc_index(repo) + if os.path.exists(index_file): + os.unlink(index_file) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/hook.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/hook.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/hook.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/hook.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,33 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2016 Guido Günther +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# +"""Common code for runniing hooks""" + +from gbp.command_wrappers import RunAtCommand + + +class Hook(RunAtCommand): + "A hook run by one of the scripts" + def __init__(self, name, cmd, extra_env): + RunAtCommand.__init__(self, cmd, shell=True, extra_env=extra_env) + self.run_error = '%s-hook %s' % (name, self.run_error) + + @staticmethod + def md(a, b): + "Merge two dictionaires a and b into a new one" + c = a.copy() + c.update(b) + return c diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/import_orig.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/import_orig.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/import_orig.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/import_orig.py 2017-02-11 19:33:12.000000000 +0000 @@ -23,7 +23,6 @@ import gbp.command_wrappers as gbpc import gbp.log -from gbp.pkg import UpstreamSource from gbp.errors import GbpError from gbp.deb.upstreamsource import DebianUpstreamSource @@ -31,10 +30,11 @@ # line editing and history capabilities. However, if readline is not # available, raw_input will still work. try: - import readline + import readline # noqa: F401 except ImportError: pass + def orig_needs_repack(upstream_source, options): """ Determine if the upstream sources needs to be repacked @@ -42,9 +42,9 @@ We repack if 1. we want to filter out files and use pristine tar since we want to make a filtered tarball available to pristine-tar - 2. when we don't have a suitable upstream tarball (e.g. zip archive or unpacked dir) + 2. we don't have a suitable upstream tarball (e.g. zip archive or unpacked dir) and want to use filters - 3. when we don't have a suitable upstream tarball (e.g. zip archive or unpacked dir) + 3. we don't have a suitable upstream tarball (e.g. zip archive or unpacked dir) and want to use pristine-tar """ if ((options.pristine_tar and options.filter_pristine_tar and len(options.filters) > 0)): @@ -80,7 +80,7 @@ """ while True: sourcepackage = raw_input("What will be the source package name? [%s] " % default) - if not sourcepackage: # No input, use the default. + if not sourcepackage: # No input, use the default. sourcepackage = default # Valid package name, return it. if name_validator_func(sourcepackage): @@ -99,7 +99,7 @@ """ while True: version = raw_input("What is the upstream version? [%s] " % default) - if not version: # No input, use the default. + if not version: # No input, use the default. version = default # Valid version, return it. if ver_validator_func(version): @@ -116,13 +116,13 @@ # Repacked orig tarball needs a different name since there's already # one with that name name = os.path.join( - os.path.dirname(source.path), - os.path.basename(source.path).replace(".tar", ".gbp.tar")) + os.path.dirname(source.path), + os.path.basename(source.path).replace(".tar", ".gbp.tar")) else: - # Repacked sources or other archives get canonical name + # non tarballs (zips, unpacked dirs) get the canonical name name = os.path.join( - os.path.dirname(source.path), - "%s_%s.orig.tar.bz2" % (name, version)) + os.path.dirname(source.path), + "%s_%s.orig.tar.bz2" % (name, version)) return name @@ -130,9 +130,9 @@ """Repack the source tree""" name = repacked_tarball_name(source, name, version) repacked = source.pack(name, filters) - if source.is_orig(): # the tarball was filtered on unpack + if source.is_orig(): # Orig already was a tarball so it was filtered on unpack repacked.unpacked = source.unpacked - else: # otherwise unpack the generated tarball get a filtered tree + else: # otherwise unpack the generated tarball again to get a filtered tree if tmpdir: cleanup_tmp_tree(tmpdir) tmpdir = tempfile.mkdtemp(dir='../') @@ -149,7 +149,7 @@ @rtype: DebianUpstreamSource @raises GbpError: on all errors """ - CHUNK_SIZE=4096 + CHUNK_SIZE = 4096 try: import requests @@ -167,12 +167,13 @@ try: with contextlib.closing(requests.get(url, verify=True, stream=True)) as r: - with contextlib.closing(open(target, 'w', CHUNK_SIZE)) as target_fd: + r.raise_for_status() + with open(target, 'w', CHUNK_SIZE) as target_fd: for d in r.iter_content(CHUNK_SIZE): target_fd.write(d) except Exception as e: - raise GbpError("Failed to download %s: %s" % (url, e)) if os.path.exists(target): os.unlink(target) + raise GbpError("Failed to download %s: %s" % (url, e)) return DebianUpstreamSource(target) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/__init__.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -15,3 +15,26 @@ # along with this program; if not, please see # """Parts shared between the deb and rpm commands""" + +import re + + +class ExitCodes(object): + ok = 0, + failed = 1 # All other errors + no_value = 2 # Value does not exist (gbp config only) + parse_error = 3 # Failed to parse configuration file + + +def is_download(args): + """ + >>> is_download(["http://foo.example.com"]) + True + >>> is_download([]) + False + >>> is_download(["foo-1.1.orig.tar.gz"]) + False + """ + if args and re.match("https?://", args[0]): + return True + return False diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/pq.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/pq.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/pq.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/pq.py 2017-02-11 19:33:12.000000000 +0000 @@ -176,6 +176,7 @@ DEFAULT_PATCH_NUM_PREFIX_FORMAT = "%04d-" + def format_patch(outdir, repo, commit_info, series, numbered=True, path_exclude_regex=None, topic='', name=None, renumber=False, patch_num_prefix_format=DEFAULT_PATCH_NUM_PREFIX_FORMAT): @@ -188,10 +189,10 @@ try: num_prefix = str(patch_num_prefix_format) % (len(series) + 1) \ - if numbered else '' + if numbered else '' except Exception: - gbp.log.warn("Bad format format string '%s', " \ - "falling back to default '%s'" % \ + gbp.log.warn("Bad format format string '%s', " + "falling back to default '%s'" % (str(patch_num_prefix_format), DEFAULT_PATCH_NUM_PREFIX_FORMAT)) num_prefix = DEFAULT_PATCH_NUM_PREFIX_FORMAT % (len(series) + 1) @@ -200,7 +201,7 @@ if renumber: # Remove any existing numeric prefix if the patch # should be renumbered - name = re.sub('^\d+[-_]*', '', name) + name = re.sub('^\d+[-_]*', '', name) else: # Otherwise, clear proposed prefix num_prefix = '' @@ -214,9 +215,8 @@ filepath = os.path.join(outdir, filename) # Make sure that we don't overwrite existing patches in the series if filepath in series: - presuffix = '-%d' % \ - len([p for p in series \ - if p.startswith(os.path.splitext(filepath)[0])]) + presuffix = '-%d' % len([p for p in series + if p.startswith(os.path.splitext(filepath)[0])]) filename = num_prefix + base + presuffix + suffix filepath = os.path.join(outdir, filename) @@ -227,7 +227,7 @@ patch = None if paths: diff = repo.diff('%s^!' % commit_info['id'], paths=paths, stat=80, - summary=True, text=True) + summary=True, text=True, abbrev=7) patch = write_patch_file(filepath, commit_info, diff) if patch: series.append(patch) @@ -252,7 +252,7 @@ paths = patch_path_filter(file_status, path_exclude_regex) if paths: diff = repo.diff(start, end, paths=paths, stat=80, summary=True, - text=True) + text=True, abbrev=7) return write_patch_file(filename, info, diff) return None @@ -316,7 +316,11 @@ else: gbp.log.warn("Patch '%s' has no authorship information" % patch_fn) - repo.apply_patch(patch.path, strip=patch.strip) + try: + repo.apply_patch(patch.path, strip=patch.strip) + except GitRepositoryError: + gbp.log.warn("Patch %s failed to apply, retrying with whitespace fixup" % patch_fn) + repo.apply_patch(patch.path, strip=patch.strip, fix_ws=True) tree = repo.write_tree() msg = "%s\n\n%s" % (patch.subject, patch.long_desc) if topic: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/repo_setup.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/repo_setup.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/common/repo_setup.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/common/repo_setup.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,30 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2006-2011, 2016 Guido Guenther +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# +# +"""Common repository setup functionality.""" + +import os + + +def set_user_name_and_email(repo_user, repo_email, repo): + if repo_user == 'DEBIAN': + if os.getenv('DEBFULLNAME'): + repo.set_user_name(os.getenv('DEBFULLNAME')) + + if repo_email == 'DEBIAN': + if os.getenv('DEBEMAIL'): + repo.set_user_email(os.getenv('DEBEMAIL')) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/config.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/config.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/config.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/config.py 2017-02-11 19:33:12.000000000 +0000 @@ -17,11 +17,12 @@ # """Query and display config file values""" -from six.moves import configparser import sys -import os, os.path +import os from gbp.config import GbpOptionParser +from gbp.errors import GbpError from gbp.scripts.supercommand import import_command +from gbp.scripts.common import ExitCodes import gbp.log @@ -29,7 +30,7 @@ try: parser = GbpOptionParser(command=os.path.basename(name), prefix='', usage='%prog [options] command[.optionname] - display configuration settings') - except configparser.ParsingError as err: + except GbpError as err: gbp.log.err(err) return None @@ -108,22 +109,25 @@ return print_all_options(parser, printer) -def value_printer(value): - if (value): - print(value) +def value_printer(output): + print(output) def main(argv): retval = 1 (options, args) = parse_args(argv) + + if options is None: + return ExitCodes.parse_error + gbp.log.setup(options.color, options.verbose, options.color_scheme) if not args: - gbp.log.error("No command given") + gbp.log.err("No command given") return 2 elif len(args) != 2: - gbp.log.error("Can only take a command or command.optionname, check --help") + gbp.log.err("Can only take a command or command.optionname, check --help") return 2 else: query = args[1] @@ -131,6 +135,7 @@ retval = print_cmd_values(query, value_printer) return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/create_remote_repo.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/create_remote_repo.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/create_remote_repo.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/create_remote_repo.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2010, 2012, 2015 Guido Günther +# (C) 2010,2012,2015,2016 Guido Günther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -20,15 +20,14 @@ from __future__ import print_function -from six.moves import configparser import sys -import os, os.path +import os from six.moves import urllib import subprocess -import tty, termios +import tty +import termios import re - -import six +from six.moves import configparser from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.command_wrappers import (CommandExecFailed, GitCommand) @@ -36,8 +35,11 @@ from gbp.errors import GbpError from gbp.git import GitRepositoryError from gbp.deb.git import DebianGitRepository +from gbp.scripts.common import ExitCodes + import gbp.log + def print_config(remote, branches): """ Print out the git config to push to the newly created repo. @@ -68,45 +70,11 @@ remote = %s merge = refs/heads/%s""" % (branch, remote['name'], branch)) -def sort_dict(d): - """Return a sorted list of (key, value) tuples""" - s = [] - for key in sorted(six.iterkeys(d)): - s.append((key, d[key])) - return s -def parse_url(remote_url, name, pkg, template_dir=None): +def parse_url(remote_url, name, pkg, template_dir=None, bare=True): """ Sanity check our remote URL - >>> sort_dict(parse_url("ssh://host/path/%(pkg)s", "origin", "package")) - [('base', ''), ('dir', '/path/package'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', None), ('scheme', 'ssh'), ('template-dir', None), ('url', 'ssh://host/path/package')] - - >>> sort_dict(parse_url("ssh://host:22/path/repo.git", "origin", "package")) - [('base', ''), ('dir', '/path/repo.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('template-dir', None), ('url', 'ssh://host:22/path/repo.git')] - - >>> sort_dict(parse_url("ssh://host:22/~/path/%(pkg)s.git", "origin", "package")) - [('base', '~/'), ('dir', 'path/package.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('template-dir', None), ('url', 'ssh://host:22/~/path/package.git')] - - >>> sort_dict(parse_url("ssh://host:22/~user/path/%(pkg)s.git", "origin", "package", "/doesnot/exist")) - [('base', '~user/'), ('dir', 'path/package.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('template-dir', '/doesnot/exist'), ('url', 'ssh://host:22/~user/path/package.git')] - - >>> parse_url("git://host/repo.git", "origin", "package") - Traceback (most recent call last): - ... - GbpError: URL must use ssh protocol. - >>> parse_url("ssh://host/path/repo", "origin", "package") - Traceback (most recent call last): - ... - GbpError: URL needs to contain either a repository name or '%(pkg)s' - >>> parse_url("ssh://host:asdf/path/%(pkg)s.git", "origin", "package") - Traceback (most recent call last): - ... - GbpError: URL contains invalid port. - >>> parse_url("ssh://host/~us er/path/%(pkg)s.git", "origin", "package") - Traceback (most recent call last): - ... - GbpError: URL contains invalid ~username expansion. """ frags = urllib.parse.urlparse(remote_url) if frags.scheme in ['ssh', 'git+ssh', '']: @@ -114,7 +82,7 @@ else: raise GbpError("URL must use ssh protocol.") - if not '%(pkg)s' in remote_url and not remote_url.endswith(".git"): + if '%(pkg)s' not in remote_url and not remote_url.endswith(".git"): raise GbpError("URL needs to contain either a repository name or '%(pkg)s'") if ":" in frags.netloc: @@ -135,45 +103,50 @@ base = "" path = frags.path - remote = { 'pkg' : pkg, - 'url' : remote_url % { 'pkg': pkg }, - 'dir' : path % { 'pkg': pkg }, - 'base': base, - 'host': host, - 'port': port, - 'name': name, - 'scheme': scheme, - 'template-dir': template_dir} + remote = {'pkg': pkg, + 'url': remote_url % {'pkg': pkg}, + 'dir': path % {'pkg': pkg}, + 'base': base, + 'host': host, + 'port': port, + 'name': name, + 'scheme': scheme, + 'template-dir': template_dir, + 'bare': bare} return remote def build_remote_script(remote, branch): """ Create the script that will be run on the remote side - >>> build_remote_script({'base': 'base', 'dir': 'dir', 'pkg': 'pkg', 'template-dir': None}, 'branch') - '\\nset -e\\numask 002\\nif [ -d base"dir" ]; then\\n echo "Repository at "basedir" already exists - giving up."\\n exit 1\\nfi\\nmkdir -p base"dir"\\ncd base"dir"\\ngit init --bare --shared\\necho "pkg packaging" > description\\necho "ref: refs/heads/branch" > HEAD\\n' - >>> build_remote_script({'base': 'base', 'dir': 'dir', 'pkg': 'pkg', 'template-dir': '/doesnot/exist'}, 'branch') - '\\nset -e\\numask 002\\nif [ -d base"dir" ]; then\\n echo "Repository at "basedir" already exists - giving up."\\n exit 1\\nfi\\nmkdir -p base"dir"\\ncd base"dir"\\ngit init --bare --shared --template=/doesnot/exist\\necho "pkg packaging" > description\\necho "ref: refs/heads/branch" > HEAD\\n' """ args = remote args['branch'] = branch - args['git-init-args'] = '--bare --shared' + args['git-init-args'] = '--shared' + if args['bare']: + args['git-init-args'] += ' --bare' + args['checkout_cmd'] = '' + args['git_dir'] = '.' + else: + args['checkout_cmd'] = 'git checkout -f' + args['git_dir'] = '.git' if args['template-dir']: args['git-init-args'] += (' --template=%s' - % args['template-dir']) - remote_script_pattern = ['', - 'set -e', - 'umask 002', - 'if [ -d %(base)s"%(dir)s" ]; then', - ' echo "Repository at \"%(base)s%(dir)s\" already exists - giving up."', - ' exit 1', - 'fi', - 'mkdir -p %(base)s"%(dir)s"', - 'cd %(base)s"%(dir)s"', - 'git init %(git-init-args)s', - 'echo "%(pkg)s packaging" > description', - 'echo "ref: refs/heads/%(branch)s" > HEAD', - '' ] + % args['template-dir']) + remote_script_pattern = \ + ['', + 'set -e', + 'umask 002', + 'if [ -d %(base)s"%(dir)s" ]; then', + ' echo "Repository at \"%(base)s%(dir)s\" already exists - giving up."', + ' exit 1', + 'fi', + 'mkdir -p %(base)s"%(dir)s"', + 'cd %(base)s"%(dir)s"', + 'git init %(git-init-args)s', + 'echo "%(pkg)s packaging" > %(git_dir)s/description', + 'echo "ref: refs/heads/%(branch)s" > %(git_dir)s/HEAD', + ''] remote_script = '\n'.join(remote_script_pattern) % args return remote_script @@ -212,7 +185,7 @@ if old_settings: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) - if ch in ( 'y', 'Y' ): + if ch in ('y', 'Y'): return True else: return False @@ -231,13 +204,20 @@ gitPush([remote['url'], '--tags']) +def usage_msg(): + return """%prog [options] - create a remote git repository +Actions: + create create the repository. This is the default when no action is + given. + list list available configuration templates for remote repositories""" + + def build_parser(name, sections=[]): try: parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='', - usage='%prog [options] - ' - 'create a remote repository', + usage=usage_msg(), sections=sections) - except configparser.ParsingError as err: + except (GbpError, configparser.NoSectionError) as err: gbp.log.err(err) return None @@ -255,6 +235,8 @@ dest="pristine_tar") branch_group.add_boolean_config_file_option(option_name="track", dest='track') + branch_group.add_boolean_config_file_option(option_name="bare", + dest='bare') parser.add_option("-v", "--verbose", action="store_true", dest="verbose", @@ -276,46 +258,34 @@ return parser -def parse_args(argv, sections=[]): +def parse_args(argv): """ Parse the command line arguments and config files. @param argv: the command line arguments @type argv: C{list} of C{str} - @param sections: additional sections to add to the config file parser - besides the command name - @type sections: C{list} of C{str} """ - - # We simpley handle the template section as an additional config file + sections = [] + # We handle the template section as an additional config file # section to parse, this makes e.g. --help work as expected: for arg in argv: if arg.startswith('--remote-config='): - sections = ['remote-config %s' % arg.split('=',1)[1]] + sections = ['remote-config %s' % arg.split('=', 1)[1]] break - else: - sections = [] parser = build_parser(argv[0], sections) if not parser: - return None, None + return None, None, None - return parser.parse_args(argv) + return list(parser.parse_args(argv)) + [parser.config_file_sections] -def main(argv): +def do_create(options): retval = 0 changelog = 'debian/changelog' cmd = [] try: - options, args = parse_args(argv) - except Exception as e: - print("%s" % e, file=sys.stderr) - return 1 - - gbp.log.setup(options.color, options.verbose, options.color_scheme) - try: repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) @@ -324,12 +294,12 @@ try: branches = [] - for branch in [ options.debian_branch, options.upstream_branch ]: + for branch in [options.debian_branch, options.upstream_branch]: if repo.has_branch(branch): - branches += [ branch ] + branches += [branch] if repo.has_pristine_tar_branch() and options.pristine_tar: - branches += [ repo.pristine_tar_branch ] + branches += [repo.pristine_tar_branch] try: cp = ChangeLog(filename=changelog) @@ -345,7 +315,8 @@ remote = parse_url(options.remote_url, options.name, pkg, - options.template_dir) + options.template_dir, + options.bare) if repo.has_remote_repo(options.name): raise GbpError("You already have a remote name '%s' defined for this repository." % options.name) @@ -374,17 +345,63 @@ else: gbp.log.info("You can now add:") print_config(remote, branches) - gbp.log.info("to your .git/config to 'gbp-pull' and 'git push' in the future.") - + gbp.log.info("to your .git/config to 'gbp pull' and 'git push' in the future.") + except KeyboardInterrupt: + retval = 1 + gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except (GbpError, GitRepositoryError) as err: if str(err): gbp.log.err(err) retval = 1 + return retval + + +def get_config_names(sections): + config_names = [] + for section in sections: + if section.startswith("remote-config "): + config_names.append(section.split(' ', 1)[1]) + return config_names + + +def do_list(sections): + names = get_config_names(sections) + if names: + gbp.log.info("Available remote config templates:") + for n in names: + print(" %s" % n) + else: + gbp.log.info("No remot config templates found.") + return 0 + +def main(argv): + retval = 1 + + options, args, sections = parse_args(argv) + if not options: + return ExitCodes.parse_error + + gbp.log.setup(options.color, options.verbose, options.color_scheme) + + if len(args) == 1: + args.append('create') # the default + elif len(args) > 2: + gbp.log.err("Only one action allowed") + return 1 + + action = args[1] + if action == 'create': + retval = do_create(options) + elif action == 'list': + retval = do_list(sections) + else: + gbp.log.err("Unknown action '%s'" % action) return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/dch.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/dch.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/dch.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/dch.py 2017-02-11 19:33:12.000000000 +0000 @@ -19,7 +19,6 @@ from __future__ import print_function -from six.moves import configparser import os.path import re import sys @@ -33,6 +32,7 @@ from gbp.deb.source import DebianSource, DebianSourceError from gbp.deb.git import GitRepositoryError, DebianGitRepository from gbp.deb.changelog import ChangeLog, NoChangeLogError +from gbp.scripts.common import ExitCodes user_customizations = {} snapshot_re = re.compile("\s*\*\* SNAPSHOT build @(?P[a-z0-9]+)\s+\*\*") @@ -61,11 +61,15 @@ author = email = None if use_git_config: - try: author = repo.get_config('user.name') - except KeyError: pass + try: + author = repo.get_config('user.name') + except KeyError: + pass - try: email = repo.get_config('user.email') - except KeyError: pass + try: + email = repo.get_config('user.email') + except KeyError: + pass return author, email @@ -81,7 +85,7 @@ author, email = get_author_email(repo, use_git_author) used_options = ['distribution', 'urgency'] opts = [] - mainttrailer_opts = [ '--nomainttrailer', '--mainttrailer', '-t' ] + mainttrailer_opts = ['--nomainttrailer', '--mainttrailer', '-t'] # This must not be done for snapshots or snapshots changelog entries # will not be concatenated @@ -94,13 +98,12 @@ else: gbp.log.debug("Snapshot enabled: do not fixup options in header") - if use_git_author: - for opt in mainttrailer_opts: - if opt in dch_options: - break - else: - opts.append(mainttrailer_opts[0]) - ChangeLog.spawn_dch(msg='', author=author, email=email, dch_options=dch_options+opts) + for opt in mainttrailer_opts: + if opt in dch_options: + break + else: + opts.append(mainttrailer_opts[0]) + ChangeLog.spawn_dch(msg='', author=author, email=email, dch_options=dch_options + opts) def snapshot_version(version): @@ -118,12 +121,12 @@ """ try: (release, suffix) = version.rsplit('~', 1) - (snapshot, commit) = suffix.split('.', 1) + (snapshot, commit) = suffix.split('.', 1) if not commit.startswith('gbp'): raise ValueError else: snapshot = int(snapshot) - except ValueError: # not a snapshot release + except ValueError: # not a snapshot release release = version snapshot = 0 return release, snapshot @@ -143,13 +146,13 @@ cr = open(changelog, 'r') print("%(Source)s (%(MangledVersion)s) " - "%(Distribution)s; urgency=%(urgency)s\n" % cp, file=cw) + "%(Distribution)s; urgency=%(urgency)s\n" % cp, file=cw) - cr.readline() # skip version and empty line + cr.readline() # skip version and empty line cr.readline() line = cr.readline() if snapshot_re.match(line): - cr.readline() # consume the empty line after the snapshot header + cr.readline() # consume the empty line after the snapshot header line = '' if snapshot: @@ -191,7 +194,8 @@ cp['MangledVersion'] = "%s~%s" % (release, suffix) mangle_changelog(changelog, cp, commit) - return snapshot, commit + return snapshot, commit, cp['MangledVersion'] + def parse_commit(repo, commitid, opts, last_commit=False): """Parse a commit and return message, author, and author email""" @@ -286,10 +290,10 @@ elif options.release: states.append("release") - if options.spawn_editor in states: - return "sensible-editor" - else: + if options.spawn_editor == 'never' or options.spawn_editor not in states: return None + else: + return "sensible-editor" def changelog_commit_msg(options, version): @@ -300,7 +304,7 @@ try: parser = GbpOptionParserDebian(command=os.path.basename(name), usage='%prog [options] paths') - except configparser.ParsingError as err: + except GbpError as err: gbp.log.err(err) return None @@ -320,15 +324,17 @@ parser.add_option_group(naming_group) parser.add_option_group(custom_group) - parser.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch") + parser.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch") naming_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") naming_group.add_config_file_option(option_name="debian-branch", dest="debian_branch") naming_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag") naming_group.add_config_file_option(option_name="debian-tag", dest="debian_tag") naming_group.add_config_file_option(option_name="snapshot-number", dest="snapshot_number", - help="expression to determine the next snapshot number, default is '%(snapshot-number)s'") + help="expression to determine the next snapshot number, " + "default is '%(snapshot-number)s'") parser.add_config_file_option(option_name="git-log", dest="git_log", - help="options to pass to git-log, default is '%(git-log)s'") + help="options to pass to git-log, " + "default is '%(git-log)s'") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") parser.add_config_file_option(option_name="color", dest="color", type='tristate') @@ -336,42 +342,49 @@ dest="color_scheme") range_group.add_option("-s", "--since", dest="since", help="commit to start from (e.g. HEAD^^^, debian/0.4.3)") range_group.add_option("-a", "--auto", action="store_true", dest="auto", default=False, - help="autocomplete changelog from last snapshot or tag") + help="autocomplete changelog from last snapshot or tag") version_group.add_option("-R", "--release", action="store_true", dest="release", default=False, - help="mark as release") + help="mark as release") version_group.add_option("-S", "--snapshot", action="store_true", dest="snapshot", default=False, - help="mark as snapshot build") + help="mark as snapshot build") version_group.add_option("-D", "--distribution", dest="distribution", help="Set distribution") version_group.add_option("--force-distribution", action="store_true", dest="force_distribution", default=False, - help="Force the provided distribution to be used, even if it doesn't match the list of known distributions") + help="Force the provided distribution to be used, " + "even if it doesn't match the list of known distributions") version_group.add_option("-N", "--new-version", dest="new_version", - help="use this as base for the new version number") - version_group.add_option("-U", "--urgency", dest="urgency", help="Set urgency level") + help="use this as base for the new version number") + version_group.add_config_file_option("urgency", dest="urgency") version_group.add_option("--bpo", dest="bpo", action="store_true", default=False, - help="Increment the Debian release number for an upload to backports, and add a backport upload changelog comment.") + help="Increment the Debian release number for an upload to backports, " + "and add a backport upload changelog comment.") version_group.add_option("--nmu", dest="nmu", action="store_true", default=False, - help="Increment the Debian release number for a non-maintainer upload") + help="Increment the Debian release number for a non-maintainer upload") version_group.add_option("--qa", dest="qa", action="store_true", default=False, - help="Increment the Debian release number for a Debian QA Team upload, and add a QA upload changelog comment.") + help="Increment the Debian release number for a Debian QA Team upload, " + "and add a QA upload changelog comment.") version_group.add_option("--team", dest="team", action="store_true", default=False, - help="Increment the Debian release number for a Debian Team upload, and add a Team upload changelog comment.") + help="Increment the Debian release number for a Debian Team upload, " + "and add a Team upload changelog comment.") version_group.add_option("--security", dest="security", action="store_true", default=False, - help="Increment the Debian release number for a security upload and add a security upload changelog comment.") + help="Increment the Debian release number for a security upload and " + "add a security upload changelog comment.") version_group.add_boolean_config_file_option(option_name="git-author", dest="use_git_author") commit_group.add_boolean_config_file_option(option_name="meta", dest="meta") commit_group.add_config_file_option(option_name="meta-closes", dest="meta_closes") commit_group.add_config_file_option(option_name="meta-closes-bugnum", dest="meta_closes_bugnum") commit_group.add_boolean_config_file_option(option_name="full", dest="full") commit_group.add_config_file_option(option_name="id-length", dest="idlen", - help="include N digits of the commit id in the changelog entry, default is '%(id-length)s'", - type="int", metavar="N") + help="include N digits of the commit id in the changelog entry, " + "default is '%(id-length)s'", + type="int", metavar="N") commit_group.add_config_file_option(option_name="ignore-regex", dest="ignore_regex", - help="Ignore commit lines matching regex, default is '%(ignore-regex)s'") + help="Ignore commit lines matching regex, " + "default is '%(ignore-regex)s'") commit_group.add_boolean_config_file_option(option_name="multimaint", dest="multimaint") commit_group.add_boolean_config_file_option(option_name="multimaint-merge", dest="multimaint_merge") commit_group.add_config_file_option(option_name="spawn-editor", dest="spawn_editor") parser.add_config_file_option(option_name="commit-msg", - dest="commit_msg") + dest="commit_msg") parser.add_option("-c", "--commit", action="store_true", dest="commit", default=False, help="commit changelog file after generating") @@ -381,15 +394,13 @@ custom_group.add_config_file_option(option_name="customizations", dest="customization_file", help=help_msg) - - return parser def parse_args(argv): parser = build_parser(argv[0]) if not parser: - return None, None + return [None] * 4 (options, args) = parser.parse_args(argv[1:]) gbp.log.setup(options.color, options.verbose, options.color_scheme) @@ -397,6 +408,7 @@ editor_cmd = process_editor_option(options) return options, args, dch_options, editor_cmd + def main(argv): ret = 0 changelog = 'debian/changelog' @@ -405,12 +417,16 @@ version_change = {} branch = None - options, args, dch_options, editor_cmd = parse_args(argv) + if not options: + return ExitCodes.parse_error + try: + old_cwd = os.path.abspath(os.path.curdir) try: - repo = DebianGitRepository('.') + repo = DebianGitRepository('.', toplevel=False) + os.chdir(repo.path) except GitRepositoryError: raise GbpError("%s is not a git repository" % (os.path.abspath('.'))) @@ -440,7 +456,7 @@ msg = "Starting from first commit" gbp.log.info(msg) found_snapshot_banner = has_snapshot_banner(cp) - else: # Fallback: continue from last tag + else: # Fallback: continue from last tag since = repo.find_version(options.debian_tag, cp['Version']) if not since: raise GbpError("Version %s not found" % cp['Version']) @@ -451,9 +467,10 @@ options=options.git_log.split(" ")) commits.reverse() + add_section = False # add a new changelog section if: if (options.new_version or options.bpo or options.nmu or options.qa or - options.team or options.security): + options.team or options.security): if options.bpo: version_change['increment'] = '--bpo' elif options.nmu: @@ -468,14 +485,13 @@ version_change['version'] = options.new_version # the user wants to force a new version add_section = True - elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_banner and commits: - # the last version was a release and we have pending commits - add_section = True - elif options.snapshot and not found_snapshot_banner: - # the user want to switch to snapshot mode - add_section = True - else: - add_section = False + elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_banner: + if commits: + # the last version was a release and we have pending commits + add_section = True + if options.snapshot: + # the user want to switch to snapshot mode + add_section = True if add_section and not version_change and not source.is_native(): # Get version from upstream if none provided @@ -488,7 +504,7 @@ for c in commits: i += 1 parsed = parse_commit(repo, c, options, - last_commit = i == len(commits)) + last_commit=(i == len(commits))) commit_msg, (commit_author, commit_email) = parsed if not commit_msg: # Some commits can be ignored @@ -507,7 +523,6 @@ else: cp.add_entry(commit_msg, commit_author, commit_email, dch_options) - # Show a message if there were no commits (not even ignored # commits). if not commits: @@ -527,8 +542,8 @@ do_release(changelog, repo, cp, use_git_author=options.use_git_author, dch_options=dch_options) elif options.snapshot: - (snap, version) = do_snapshot(changelog, repo, options.snapshot_number) - gbp.log.info("Changelog has been prepared for snapshot #%d at %s" % (snap, version)) + (snap, commit, version) = do_snapshot(changelog, repo, options.snapshot_number) + gbp.log.info("Changelog %s (snapshot #%d) prepared up to %s" % (version, snap, commit[:7])) if editor_cmd: gbpc.Command(editor_cmd, ["debian/changelog"])() @@ -541,8 +556,10 @@ # Commit the changes to the changelog file msg = changelog_commit_msg(options, version) repo.commit_files([changelog], msg) - gbp.log.info("Changelog has been committed for version %s" % version) - + gbp.log.info("Changelog committed for version %s" % version) + except KeyboardInterrupt: + ret = 1 + gbp.log.err("Interrupted. Aborting.") except (gbpc.CommandExecFailed, GbpError, GitRepositoryError, @@ -551,8 +568,11 @@ if str(err): gbp.log.err(err) ret = 1 + finally: + os.chdir(old_cwd) return ret + if __name__ == "__main__": sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/import_dsc.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/import_dsc.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/import_dsc.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/import_dsc.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006, 2007, 2011, 2012, 2015 Guido Guenther +# (C) 2006, 2007, 2011, 2012, 2015, 2016 Guido Guenther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -16,7 +16,6 @@ # """Import a Debian source package into a Git repository""" -from six.moves import configparser import sys import re import os @@ -27,35 +26,26 @@ import time import gbp.command_wrappers as gbpc from gbp.deb.dscfile import DscFile -from gbp.deb.upstreamsource import DebianUpstreamSource +from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball from gbp.deb.git import (DebianGitRepository, GitRepositoryError) from gbp.deb.changelog import ChangeLog from gbp.git import rfc822_date_to_git from gbp.git.modifier import GitModifier +from gbp.git.vfs import GitVfs from gbp.config import (GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg) from gbp.errors import GbpError +from gbp.scripts.common import ExitCodes +from gbp.scripts.common import repo_setup import gbp.log + class SkipImport(Exception): pass -def generate_pristine_tarballs(repo, src, upstream_tree): - subdirs = src.additional_tarballs.keys() - main_tree = repo.tree_drop_dirs(upstream_tree, subdirs) - - for dir, tarball in src.additional_tarballs.items(): - subtree = repo.tree_get_dir(upstream_tree, dir) - if not subtree: - raise GbpError("No tree for '%s' found in '%s' to create pristine tar commit from" % (dir, upstream_tree)) - gbp.log.debug("Creating pristine tar commit '%s' from '%s'" % (dir, subtree)) - repo.pristine_tar.commit(tarball, subtree) - repo.pristine_tar.commit(src.tgz, main_tree) - - def download_source(pkg, dirs, unauth): - opts = [ '--download-only' ] + opts = ['--download-only'] if unauth: opts.append('--allow-unauthenticated') @@ -70,15 +60,23 @@ gbp.log.info("Downloading '%s' using '%s'..." % (pkg, cmd)) gbpc.RunAtCommand(cmd, opts, shell=False)(dir=dirs['download']) - dsc = glob.glob(os.path.join(dirs['download'], '*.dsc'))[0] + try: + dsc = glob.glob(os.path.join(dirs['download'], '*.dsc'))[0] + except IndexError: + raise GbpError("Did not find a dsc file at %s/" % dirs['download']) return dsc def apply_patch(diff): "Apply patch to a source tree" + patch_opts = ['-N', '-p1', '-F0', '-u', '-t', + '-Vnever', '-g0', '-z.gbp.orig', + '--quiet'] + pipe = pipes.Template() - pipe.prepend('gunzip -c %s' % diff, '.-') - pipe.append('patch -p1 --quiet', '-.') + pipe.prepend('gunzip -c %s' % diff, '.-') + pipe.append('patch %s' % ' '.join(patch_opts), '-.') + try: ret = pipe.copy('', '') if ret: @@ -144,7 +142,8 @@ return parents -def apply_debian_patch(repo, unpack_dir, src, options, tag): + +def apply_debian_patch(repo, unpack_dir, src, options, tag, is_empty): """apply the debian patch and tag appropriately""" try: os.chdir(unpack_dir) @@ -165,10 +164,16 @@ author = get_author_from_changelog(unpack_dir) committer = get_committer_from_author(author, options) + + changes = get_changes(unpack_dir, + repo, + is_empty, + options.debian_branch) + commit_msg = "Import Debian changes %s\n%s" % (src.version, changes) commit = repo.commit_dir(unpack_dir, - "Imported Debian patch %s" % src.version, - branch = options.debian_branch, - other_parents = parents, + commit_msg, + branch=options.debian_branch, + other_parents=parents, author=author, committer=committer) if not options.skip_debian_tag: @@ -187,13 +192,15 @@ def print_dsc(dsc): if dsc.native: - gbp.log.debug("Debian Native Package %s") + gbp.log.debug("Debian Native Package") gbp.log.debug("Version: %s" % dsc.upstream_version) gbp.log.debug("Debian tarball: %s" % dsc.tgz) else: gbp.log.debug("Upstream version: %s" % dsc.upstream_version) gbp.log.debug("Debian version: %s" % dsc.debian_version) gbp.log.debug("Upstream tarball: %s" % dsc.tgz) + if dsc.additional_tarballs: + gbp.log.debug("Additional tarballs: %s" % ", ".join(dsc.additional_tarballs.values())) if dsc.diff: gbp.log.debug("Debian patch: %s" % dsc.diff) if dsc.deb_tgz: @@ -220,19 +227,18 @@ def build_parser(name): try: parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='', - usage='%prog [options] /path/to/package.dsc') - except configparser.ParsingError as err: + usage='%prog [options] /path/to/package.dsc [target]') + except GbpError as err: gbp.log.err(err) return None import_group = GbpOptionGroup(parser, "import options", - "pristine-tar and filtering") + "pristine-tar and filtering") tag_group = GbpOptionGroup(parser, "tag options", - "options related to git tag creation") + "options related to git tag creation") branch_group = GbpOptionGroup(parser, "version and branch naming options", - "version number and branch layout options") - - for group in [import_group, branch_group, tag_group ]: + "version number and branch layout options") + for group in [import_group, branch_group, tag_group]: parser.add_option_group(group) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, @@ -240,41 +246,45 @@ parser.add_config_file_option(option_name="color", dest="color", type='tristate') parser.add_config_file_option(option_name="color-scheme", dest="color_scheme") - parser.add_option("--download", action="store_true", dest="download", default=False, - help="download source package") branch_group.add_config_file_option(option_name="debian-branch", - dest="debian_branch") + dest="debian_branch") branch_group.add_config_file_option(option_name="upstream-branch", - dest="upstream_branch") + dest="upstream_branch") branch_group.add_boolean_config_file_option(option_name="create-missing-branches", - dest="create_missing_branches") + dest="create_missing_branches") tag_group.add_boolean_config_file_option(option_name="sign-tags", - dest="sign_tags") + dest="sign_tags") tag_group.add_config_file_option(option_name="keyid", - dest="keyid") + dest="keyid") tag_group.add_config_file_option(option_name="debian-tag", - dest="debian_tag") + dest="debian_tag") tag_group.add_config_file_option(option_name="upstream-tag", - dest="upstream_tag") - tag_group.add_option("--skip-debian-tag",dest="skip_debian_tag", + dest="upstream_tag") + tag_group.add_option("--skip-debian-tag", dest="skip_debian_tag", action="store_true", default=False, help="Don't add a tag after importing the Debian patch") - import_group.add_config_file_option(option_name="filter", - dest="filters", action="append") + dest="filters", action="append") import_group.add_boolean_config_file_option(option_name="pristine-tar", - dest="pristine_tar") + dest="pristine_tar") import_group.add_option("--allow-same-version", action="store_true", - dest="allow_same_version", default=False, - help="allow to import already imported version") + dest="allow_same_version", default=False, + help="allow to import already imported version") import_group.add_boolean_config_file_option(option_name="author-is-committer", - dest="author_committer") + dest="author_committer") import_group.add_boolean_config_file_option(option_name="author-date-is-committer-date", - dest="author_committer_date") + dest="author_committer_date") import_group.add_boolean_config_file_option(option_name="allow-unauthenticated", - dest="allow_unauthenticated") + dest="allow_unauthenticated") + + parser.add_config_file_option(option_name="repo-user", dest="repo_user", + choices=['DEBIAN', 'GIT']) + parser.add_config_file_option(option_name="repo-email", dest="repo_email", + choices=['DEBIAN', 'GIT']) + parser.add_option("--download", dest='download', action="store_true", + default=False, help="Ignored. Accepted for compatibility.") return parser @@ -285,134 +295,196 @@ (options, args) = parser.parse_args(argv[1:]) gbp.log.setup(options.color, options.verbose, options.color_scheme) + + if options.download: + gbp.log.warn("Passing --download explicitly is deprecated.") + return options, args +def is_download(pkg): + """ + >>> is_download("http://foo.example.com/apackage.dsc") + (True, 'http://foo.example.com/apackage.dsc') + >>> is_download("apt://apackage/sid") + (True, 'apackage/sid') + >>> is_download("apt_1.0_amd64.dsc") + (False, 'apt_1.0_amd64.dsc') + >>> is_download("file:///foo/apackage.dsc") + (False, '/foo/apackage.dsc') + """ + if pkg.startswith('file://'): + return (False, pkg[len('file://'):]) + elif pkg.startswith('apt://'): + return (True, pkg[len('apt://'):]) + elif re.match("[a-z]{1,5}://", pkg): + return (True, pkg) + return (False, pkg) + + +def parse_all(argv): + options, args = parse_args(argv) + if not options: + return None, None, None + + if len(args) == 1: + pkg = args[0] + target = None + elif len(args) == 2: + pkg = args[0] + target = args[1] + else: + gbp.log.err("Need to give exactly one package to import. Try --help.") + return None, None, None + + download, pkg = is_download(pkg) + # honor options.download until removed + options.download = download or options.download + return options, pkg, target + + +def get_changes(dir, repo, is_empty, debian_branch): + if is_empty: + version = "0~" + else: + vfs = GitVfs(repo, debian_branch) + try: + with vfs.open('debian/changelog') as f: + version = ChangeLog(contents=f.read()).version + except IOError: + version = "0~" # Use full history if debian branch has no changelog + cl = ChangeLog(filename=os.path.join(dir, 'debian/changelog')) + return cl.get_changes(version) + + def main(argv): dirs = dict(top=os.path.abspath(os.curdir)) needs_repo = False ret = 0 skipped = False - options, args = parse_args(argv) + options, pkg, target = parse_all(argv) if not options: - return 1 + return ExitCodes.parse_error try: - if len(args) != 1: - gbp.log.err("Need to give exactly one package to import. Try --help.") - raise GbpError + try: + repo = DebianGitRepository('.') + is_empty = repo.is_empty() + + (clean, out) = repo.is_clean() + if not clean and not is_empty: + gbp.log.err("Repository has uncommitted changes, commit these first: ") + raise GbpError(out) + except GitRepositoryError: + # no repo found, create one + needs_repo = True + is_empty = True + + if options.download: + dsc = download_source(pkg, + dirs=dirs, + unauth=options.allow_unauthenticated) else: - try: - repo = DebianGitRepository('.') - is_empty = repo.is_empty() - - (clean, out) = repo.is_clean() - if not clean and not is_empty: - gbp.log.err("Repository has uncommitted changes, commit these first: ") - raise GbpError(out) - except GitRepositoryError: - # no repo found, create one - needs_repo = True - is_empty = True - - pkg = args[0] - if options.download: - dsc = download_source(pkg, - dirs=dirs, - unauth=options.allow_unauthenticated) + dsc = pkg + + src = DscFile.parse(dsc) + if src.pkgformat not in ['1.0', '3.0']: + raise GbpError("Importing %s source format not yet supported." % src.pkgformat) + if options.verbose: + print_dsc(src) + + if needs_repo: + target = target or src.pkg + if os.path.exists(target): + raise GbpError("Directory '%s' already exists. If you want to import into it, " + "please change into this directory otherwise move it away first." + % target) + gbp.log.info("No git repository found, creating one.") + repo = DebianGitRepository.create(target) + os.chdir(repo.path) + repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo) + + if repo.bare: + disable_pristine_tar(options, "Bare repository") + + dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..')) + upstream = DebianUpstreamSource(src.tgz) + upstream.unpack(dirs['tmp'], options.filters) + for (component, tarball) in src.additional_tarballs.items(): + gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball)) + unpack_component_tarball(upstream.unpacked, component, tarball, options.filters) + + format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native] + tag = repo.version_to_tag(format[0], src.upstream_version) + msg = "%s version %s" % (format[1], src.upstream_version) + + if repo.find_version(options.debian_tag, src.version): + gbp.log.warn("Version %s already imported." % src.version) + if options.allow_same_version: + gbp.log.info("Moving tag of version '%s' since import forced" % src.version) + move_tag_stamp(repo, options.debian_tag, src.version) else: - dsc = pkg + raise SkipImport - src = DscFile.parse(dsc) - if src.pkgformat not in [ '1.0', '3.0' ]: - raise GbpError("Importing %s source format not yet supported." % src.pkgformat) - if options.verbose: - print_dsc(src) - - if needs_repo: - if os.path.exists(src.pkg): - raise GbpError("Directory '%s' already exists. If you want to import into it, " - "please change into this directory otherwise move it away first." - % src.pkg) - gbp.log.info("No git repository found, creating one.") - repo = DebianGitRepository.create(src.pkg) - os.chdir(repo.path) - - if repo.bare: - disable_pristine_tar(options, "Bare repository") - - dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..')) - upstream = DebianUpstreamSource(src.tgz) - upstream.unpack(dirs['tmp'], options.filters) - for tarball in src.additional_tarballs.values(): - gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball)) - subtarball = DebianUpstreamSource(tarball) - subtarball.unpack(upstream.unpacked, options.filters) - - format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native] - tag = repo.version_to_tag(format[0], src.upstream_version) - msg = "%s version %s" % (format[1], src.upstream_version) - - if repo.find_version(options.debian_tag, src.version): - gbp.log.warn("Version %s already imported." % src.version) - if options.allow_same_version: - gbp.log.info("Moving tag of version '%s' since import forced" % src.version) - move_tag_stamp(repo, options.debian_tag, src.version) - else: - raise SkipImport + if not repo.find_version(format[0], src.upstream_version): + gbp.log.info("Tag %s not found, importing %s tarball" % (tag, format[1])) + if is_empty: + branch = None + else: + branch = [options.upstream_branch, + options.debian_branch][src.native] + if not repo.has_branch(branch): + if options.create_missing_branches: + gbp.log.info("Creating missing branch '%s'" % branch) + repo.create_branch(branch) + else: + gbp.log.err(no_upstream_branch_msg % branch + + "\nAlso check the --create-missing-branches option.") + raise GbpError + + if src.native: + author = get_author_from_changelog(upstream.unpacked) + committer = get_committer_from_author(author, options) + commit_msg = "Import %s\n%s" % (msg, get_changes(upstream.unpacked, + repo, + is_empty, + options.debian_branch)) + else: + author = committer = {} + commit_msg = "Import %s" % msg - if not repo.find_version(format[0], src.upstream_version): - gbp.log.info("Tag %s not found, importing %s tarball" % (tag, format[1])) - if is_empty: - branch = None - else: - branch = [options.upstream_branch, - options.debian_branch][src.native] - if not repo.has_branch(branch): - if options.create_missing_branches: - gbp.log.info("Creating missing branch '%s'" % branch) - repo.create_branch(branch) - else: - gbp.log.err(no_upstream_branch_msg % branch + - "\nAlso check the --create-missing-branches option.") - raise GbpError - - if src.native: - author = get_author_from_changelog(upstream.unpacked) - committer = get_committer_from_author(author, options) - else: - author = committer = {} - - commit = repo.commit_dir(upstream.unpacked, - "Imported %s" % msg, - branch, - author=author, - committer=committer) - - if not (src.native and options.skip_debian_tag): - repo.create_tag(name=tag, - msg=msg, - commit=commit, - sign=options.sign_tags, - keyid=options.keyid) - if not src.native: - if is_empty: - repo.create_branch(options.upstream_branch, commit) - if options.pristine_tar: - generate_pristine_tarballs(repo, src, options.upstream_branch) - if (not repo.has_branch(options.debian_branch) - and (is_empty or options.create_missing_branches)): - repo.create_branch(options.debian_branch, commit) + commit = repo.commit_dir(upstream.unpacked, + commit_msg, + branch, + author=author, + committer=committer) + + if not (src.native and options.skip_debian_tag): + repo.create_tag(name=tag, + msg=msg, + commit=commit, + sign=options.sign_tags, + keyid=options.keyid) if not src.native: - if src.diff or src.deb_tgz: - apply_debian_patch(repo, upstream.unpacked, src, options, - tag) - else: - gbp.log.warn("Didn't find a diff to apply.") - if repo.get_branch() == options.debian_branch or is_empty: - # Update HEAD if we modified the checked out branch - repo.force_head(options.debian_branch, hard=True) + if is_empty: + repo.create_branch(options.upstream_branch, commit) + if options.pristine_tar: + repo.create_pristinetar_commits(options.upstream_branch, + src.tgz, + src.additional_tarballs.items()) + if (not repo.has_branch(options.debian_branch) and + (is_empty or options.create_missing_branches)): + repo.create_branch(options.debian_branch, commit) + if not src.native: + if src.diff or src.deb_tgz: + apply_debian_patch(repo, upstream.unpacked, src, options, + tag, is_empty) + else: + gbp.log.warn("Didn't find a diff to apply.") + if repo.get_branch() == options.debian_branch or is_empty: + # Update HEAD if we modified the checked out branch + repo.force_head(options.debian_branch, hard=True) except KeyboardInterrupt: ret = 1 gbp.log.err("Interrupted. Aborting.") @@ -430,14 +502,15 @@ finally: os.chdir(dirs['top']) - for d in [ 'tmp', 'download' ]: + for d in ['tmp', 'download']: if d in dirs: gbpc.RemoveTree(dirs[d])() if not ret and not skipped: - gbp.log.info("Version '%s' imported under '%s'" % (src.version, src.pkg)) + gbp.log.info("Version '%s' imported under '%s'" % (src.version, repo.path)) return ret + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/import_dscs.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/import_dscs.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/import_dscs.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/import_dscs.py 2017-02-11 19:33:12.000000000 +0000 @@ -29,6 +29,7 @@ from gbp.config import GbpOptionParser import gbp.log + class DscCompareVersions(DpkgCompareVersions): def __init__(self): DpkgCompareVersions.__init__(self) @@ -46,13 +47,13 @@ def fetch_snapshots(pkg, downloaddir): - "Fetch snapshots using debsnap von snapshots.debian.org" + "Fetch snapshots using debsnap from snapshots.debian.org" dscs = None gbp.log.info("Downloading snapshots of '%s' to '%s'..." % (pkg, downloaddir)) - debsnap = gbpc.Command("debsnap", [ '--force', '--destdir=%s' % - (downloaddir), pkg]) + debsnap = gbpc.Command("debsnap", ['--force', '--destdir=%s' % + (downloaddir), pkg]) try: debsnap() except gbpc.CommandExecFailed: @@ -68,6 +69,7 @@ return [os.path.join(downloaddir, dsc) for dsc in dscs] + def set_gbp_conf_files(): """ Filter out all gbp.conf files that are local to the git repository and set @@ -78,13 +80,14 @@ os.environ['GBP_CONF_FILES'] = gbp_conf_files gbp.log.debug("Setting GBP_CONF_FILES to '%s'" % gbp_conf_files) + def print_help(): print("""Usage: gbp import-dscs [options] [gbp-import-dsc options] /path/to/dsc1 [/path/to/dsc2] ... gbp import-dscs --debsnap [options] [gbp-import-dsc options] package Options: - --debsnap: use debsnap command to download packages + --debsnap: use debsnap command to download packages --ignore-repo-config ignore gbp.conf in git repo """) @@ -129,7 +132,7 @@ if use_debsnap: dirs['tmp'] = os.path.abspath(tempfile.mkdtemp()) - dscs = [ DscFile.parse(f) for f in fetch_snapshots(pkg, dirs['tmp']) ] + dscs = [DscFile.parse(f) for f in fetch_snapshots(pkg, dirs['tmp'])] dscs.sort(cmp=dsc_cmp) importer = GitImportDsc(import_args) @@ -154,7 +157,9 @@ for dsc in dscs[1:]: if importer.importdsc(dsc): raise GbpError("Failed to import '%s'" % dscs[0].dscfile) - + except KeyboardInterrupt: + ret = 1 + gbp.log.err("Interrupted. Aborting.") except (GbpError, gbpc.CommandExecFailed, GitRepositoryError) as err: if str(err): gbp.log.err(err) @@ -168,6 +173,7 @@ gbp.log.info('Everything imported under %s' % dirs['pkg']) return ret + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/import_orig.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/import_orig.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/import_orig.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/import_orig.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006, 2007, 2009, 2011, 2015 Guido Guenther +# (C) 2006, 2007, 2009, 2011, 2015, 2016 Guido Guenther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -17,23 +17,156 @@ # """Import a new upstream version into a Git repository""" -from six.moves import configparser import os +import shutil import sys import tempfile +import time import gbp.command_wrappers as gbpc from gbp.deb import (DebianPkgPolicy, parse_changelog_repo) -from gbp.deb.upstreamsource import DebianUpstreamSource +from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball from gbp.deb.uscan import (Uscan, UscanError) from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.deb.git import (GitRepositoryError, DebianGitRepository) from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg from gbp.errors import GbpError +from gbp.pkg import parse_archive_filename from gbp.format import format_str import gbp.log +from gbp.scripts.common import ExitCodes, is_download from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree, ask_package_name, ask_package_version, repack_source, is_link_target, download_orig) +from gbp.scripts.common.hook import Hook + + +class RollbackError(GitRepositoryError): + """ + An error raised if the actual rollback failed + """ + def __init__(self, errors): + self.msg = "Automatic rollback failed" + super(RollbackError, self).__init__(self.msg) + self.errors = errors + + def __str__(self): + return "%s %s" % (self.msg, self.errors) + + +class ImportOrigDebianGitRepository(DebianGitRepository): + """ + Like a DebianGitRepository but can also perform rollbacks and knows + about some of the inner workings upstream vcs_tag, … + """ + def __init__(self, *args, **kwargs): + self.rollbacks = [] + self.rollback_errors = [] + DebianGitRepository.__init__(self, *args, **kwargs) + + def has_rollbacks(self): + return len(self.rollbacks) > 0 + + def vcs_tag_parent(self, vcs_tag_format, version): + """If linking to the upstream VCS get the commit id""" + if vcs_tag_format: + return [self.rev_parse("%s^{}" % self.version_to_tag(vcs_tag_format, version))], + else: + return None + + def rrr(self, refname, action, reftype): + """ + Remember ref for rollback + + @param refname: ref to roll back + @param action: the rollback action (delete, reset, ...) + @param reftype: the reference type (tag, branch, ...) + """ + sha = None + + if action == 'reset': + try: + sha = self.rev_parse(refname) + except GitRepositoryError as err: + gbp.log.warn("Failed to rev-parse %s: %s" % (refname, err)) + elif action == 'delete': + pass + elif action == 'abortmerge': + pass + else: + raise GbpError("Unknown action %s for %s %s" % (action, reftype, refname)) + self.rollbacks.append((refname, reftype, action, sha)) + + def rrr_branch(self, branchname, action='reset-or-delete'): + if action == 'reset-or-delete': + if self.has_branch(branchname): + return self.rrr(branchname, 'reset', 'branch') + else: + return self.rrr(branchname, 'delete', 'branch') + else: + return self.rrr(branchname, action, 'branch') + + def rrr_tag(self, tagname, action='delete'): + return self.rrr(tagname, action, 'tag') + + def rrr_merge(self, commit, action='abortmerge'): + return self.rrr(commit, action, 'commit') + + def rollback(self): + """ + Perform a complete rollback + + Try to roll back as much as possible and remember what failed. + """ + for (name, reftype, action, sha) in self.rollbacks: + try: + if action == 'delete': + gbp.log.info('Rolling back %s %s by deleting it' % (reftype, name)) + if reftype == 'tag': + self.delete_tag(name) + elif reftype == 'branch': + self.delete_branch(name) + else: + raise GitRepositoryError("Don't know how to delete %s %s" % (reftype, name)) + elif action == 'reset' and reftype == 'branch': + gbp.log.info('Rolling back branch %s by resetting it to %s' % (name, sha)) + self.update_ref("refs/heads/%s" % name, sha, msg="gbp import-orig: failure rollback of %s" % name) + elif action == 'abortmerge': + gbp.log.info('Rolling back failed merge of %s' % name) + self.abort_merge() + else: + raise GitRepositoryError("Don't know how to %s %s %s" % (action, reftype, name)) + except GitRepositoryError as e: + self.rollback_errors.append((name, reftype, action, sha, e)) + if self.rollback_errors: + raise RollbackError(self.rollback_errors) + + # Wrapped methods for rollbacks + def create_tag(self, *args, **kwargs): + name = kwargs['name'] + ret = super(ImportOrigDebianGitRepository, self).create_tag(*args, **kwargs) + self.rrr_tag(name) + return ret + + def commit_dir(self, *args, **kwargs): + import_branch = kwargs['branch'] + self.rrr_branch(import_branch) + return super(ImportOrigDebianGitRepository, self).commit_dir(*args, **kwargs) + + def create_branch(self, *args, **kwargs): + branch = kwargs['branch'] + ret = super(ImportOrigDebianGitRepository, self).create_branch(*args, **kwargs) + self.rrr_branch(branch, 'delete') + return ret + + def merge(self, *args, **kwargs): + commit = args[0] if args else kwargs['commit'] + try: + return super(ImportOrigDebianGitRepository, self).merge(*args, **kwargs) + except GitRepositoryError: + # Only cleanup in the error case to undo working copy + # changes. Resetting the refs handles the other cases. + self.rrr_merge(commit) + raise def prepare_pristine_tar(archive, pkg, version): @@ -58,7 +191,7 @@ return None ext = os.path.splitext(archive)[1] - if ext in ['.tgz', '.tbz2', '.tlz', '.txz' ]: + if ext in ['.tgz', '.tbz2', '.tlz', '.txz']: ext = ".%s" % ext[2:] link = "../%s_%s.orig.tar%s" % (pkg, version, ext) @@ -66,6 +199,10 @@ if os.path.basename(archive) != os.path.basename(link): try: if not is_link_target(archive, link): + if os.path.exists(link): + backup = "%s.%d" % (link, time.time()) + gbp.log.info("%s already exists, moving to %s" % (link, backup)) + shutil.move(link, backup) os.symlink(os.path.abspath(archive), link) linked = True except OSError as err: @@ -124,12 +261,12 @@ def find_source(use_uscan, args): - """Find the tarball to import - either via uscan or via command line argument + """Find the main tarball to import - either via uscan or via command line argument @return: upstream source filename or None if nothing to import @rtype: string @raise GbpError: raised on all detected errors - >>> find_source(False, ['too', 'much']) + >>> find_source(False, ['too', 'many']) Traceback (most recent call last): ... GbpError: More than one archive specified. Try --help. @@ -164,13 +301,12 @@ else: gbp.log.info("package is up to date, nothing to do.") return None - if len(args) > 1: # source specified + if len(args) > 1: # source specified raise GbpError("More than one archive specified. Try --help.") elif len(args) == 0: raise GbpError("No archive to import specified. Try --help.") else: - archive = DebianUpstreamSource(args[0]) - return archive + return DebianUpstreamSource(args[0]) def debian_branch_merge(repo, tag, version, options): @@ -188,9 +324,16 @@ cp = ChangeLog(filename='debian/changelog') if cp.has_epoch(): epoch = '%s:' % cp.epoch - info = {'version': "%s%s-1" % (epoch, version)} - env = {'GBP_BRANCH': options.debian_branch} - gbpc.Command(format_str(options.postimport, info), extra_env=env, shell=True)() + debian_version = "%s%s-1" % (epoch, version) + info = {'version': debian_version} + env = {'GBP_BRANCH': options.debian_branch, + 'GBP_TAG': tag, + 'GBP_UPSTREAM_VERSION': version, + 'GBP_DEBIAN_VERSION': debian_version, + } + Hook('Postimport', + format_str(options.postimport, info), + extra_env=env)() def debian_branch_merge_by_replace(repo, tag, version, options): @@ -218,21 +361,42 @@ repo.force_head(commit, hard=True) +def get_component_tarballs(name, version, tarball, components): + """ + Figure out the paths to the component tarballs based on the main + tarball. + """ + tarballs = [] + for component in components: + (_, _, comp_type) = parse_archive_filename(tarball) + cname = DebianPkgPolicy.build_tarball_name(name, + version, + comp_type, + os.path.dirname(tarball), + component) + tarballs.append((component, cname)) + if not os.path.exists(cname): + raise GbpError("Can not find component tarball %s" % cname) + return tarballs + + def debian_branch_merge_by_merge(repo, tag, version, options): gbp.log.info("Merging to '%s'" % options.debian_branch) + branch = repo.get_branch() + repo.set_branch(options.debian_branch) try: repo.merge(tag) except GitRepositoryError: - raise GbpError("Merge failed, please resolve.") - repo.set_branch(options.debian_branch) + raise GbpError("Automatic merge failed.") + repo.set_branch(branch) def set_bare_repo_options(options): """Modify options for import into a bare repository""" if options.pristine_tar or options.merge: gbp.log.info("Bare repository: setting %s%s options" - % (["", " '--no-pristine-tar'"][options.pristine_tar], - ["", " '--no-merge'"][options.merge])) + % (["", " '--no-pristine-tar'"][options.pristine_tar], + ["", " '--no-merge'"][options.merge])) options.pristine_tar = False options.merge = False @@ -241,52 +405,56 @@ try: parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='', usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan') - except configparser.ParsingError as err: + except GbpError as err: gbp.log.err(err) return None import_group = GbpOptionGroup(parser, "import options", - "pristine-tar and filtering") + "pristine-tar and filtering") tag_group = GbpOptionGroup(parser, "tag options", - "options related to git tag creation") + "options related to git tag creation") branch_group = GbpOptionGroup(parser, "version and branch naming options", - "version number and branch layout options") - cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke external commands and hooks") - - for group in [import_group, branch_group, tag_group, cmd_group ]: + "version number and branch layout options") + cmd_group = GbpOptionGroup(parser, "external command options", + "how and when to invoke external commands and hooks") + for group in [import_group, branch_group, tag_group, cmd_group]: parser.add_option_group(group) branch_group.add_option("-u", "--upstream-version", dest="version", - help="Upstream Version") + help="Upstream Version") branch_group.add_config_file_option(option_name="debian-branch", - dest="debian_branch") + dest="debian_branch") branch_group.add_config_file_option(option_name="upstream-branch", - dest="upstream_branch") + dest="upstream_branch") branch_group.add_config_file_option(option_name="upstream-vcs-tag", dest="vcs_tag", - help="Upstream VCS tag add to the merge commit") + help="Upstream VCS tag add to the merge commit") branch_group.add_boolean_config_file_option(option_name="merge", dest="merge") branch_group.add_config_file_option(option_name="merge-mode", dest="merge_mode") tag_group.add_boolean_config_file_option(option_name="sign-tags", - dest="sign_tags") + dest="sign_tags") tag_group.add_config_file_option(option_name="keyid", - dest="keyid") + dest="keyid") tag_group.add_config_file_option(option_name="upstream-tag", - dest="upstream_tag") + dest="upstream_tag") import_group.add_config_file_option(option_name="filter", - dest="filters", action="append") + dest="filters", action="append") import_group.add_boolean_config_file_option(option_name="pristine-tar", - dest="pristine_tar") + dest="pristine_tar") import_group.add_boolean_config_file_option(option_name="filter-pristine-tar", - dest="filter_pristine_tar") + dest="filter_pristine_tar") import_group.add_config_file_option(option_name="import-msg", - dest="import_msg") + dest="import_msg") import_group.add_boolean_config_file_option(option_name="symlink-orig", dest="symlink_orig") + import_group.add_config_file_option("component", action="append", metavar='COMPONENT', + dest="components") cmd_group.add_config_file_option(option_name="postimport", dest="postimport") parser.add_boolean_config_file_option(option_name="interactive", dest='interactive') + parser.add_boolean_config_file_option(option_name="rollback", + dest="rollback") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") parser.add_config_file_option(option_name="color", dest="color", type='tristate') @@ -299,22 +467,13 @@ parser.add_option("--uscan", dest='uscan', action="store_true", default=False, help="use uscan(1) to download the new tarball.") parser.add_option("--download", dest='download', action="store_true", - default=False, help="Download from URL via http(s).") + default=False, help="Ignored. Accepted for compatibility.") return parser def parse_args(argv): """Parse the command line arguments @return: options and arguments - - # Silence error output - >>> _gbp_log_error_bak = gbp.log.error - >>> gbp.log.error = lambda x: None - >>> parse_args(['arg0', '--download', '--uscan']) - (None, None) - >>> parse_args(['arg0', '--download', 'first', 'second']) - (None, None) - >>> gbp.log.error = _gbp_log_error_bak """ parser = build_parser(argv[0]) @@ -327,14 +486,10 @@ if options.no_dch: gbp.log.warn("'--no-dch' passed. This is now the default, please remove this option.") - if options.uscan and options.download: - gbp.log.error("Either uscan or --download can be used, not both.") - return None, None - - if options.download and len(args) != 1: - gbp.log.error("Need exactly one URL to download not %s" % args) - return None, None + if options.download: + gbp.log.warn("Passing --download explicitly is deprecated.") + options.download = is_download(args) return options, args @@ -343,20 +498,19 @@ tmpdir = '' pristine_orig = None linked = False + repo = None (options, args) = parse_args(argv) if not options: - return 1 + return ExitCodes.parse_error try: try: - repo = DebianGitRepository('.') + repo = ImportOrigDebianGitRepository('.') except GitRepositoryError: raise GbpError("%s is not a git repository" % (os.path.abspath('.'))) - # an empty repo has now branches: - initial_branch = repo.get_branch() - is_empty = False if initial_branch else True + is_empty = repo.is_empty() if not repo.has_branch(options.upstream_branch) and not is_empty: raise GbpError(no_upstream_branch_msg % options.upstream_branch) @@ -366,15 +520,21 @@ gbp.log.err("Repository has uncommitted changes, commit these first: ") raise GbpError(out) - # Download the source + # Download the main tarball if options.download: source = download_orig(args[0]) else: source = find_source(options.uscan, args) if not source: - return ret + return ExitCodes.failed + # The main tarball (sourcepackage, version) = detect_name_and_version(repo, source, options) + # Additionl tarballs we expect to exist + component_tarballs = get_component_tarballs(sourcepackage, + version, + source.path, + options.components) tag = repo.version_to_tag(options.upstream_tag, version) if repo.has_tag(tag): @@ -383,14 +543,18 @@ if repo.bare: set_bare_repo_options(options) - if not source.is_dir(): + if not source.is_dir(): # Unpack main tarball tmpdir = tempfile.mkdtemp(dir='../') source.unpack(tmpdir, options.filters) gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked)) if orig_needs_repack(source, options): gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked)) - (source, tmpdir) = repack_source(source, sourcepackage, version, tmpdir, options.filters) + (source, tmpdir) = repack_source(source, sourcepackage, version, tmpdir, options.filters) + + if not source.is_dir(): # Unpack component tarballs + for (component, tarball) in component_tarballs: + unpack_component_tarball(source.unpacked, component, tarball, options.filters) (pristine_orig, linked) = prepare_pristine_tar(source.path, sourcepackage, @@ -404,32 +568,30 @@ pass try: - upstream_branch = [ options.upstream_branch, 'master' ][is_empty] + import_branch = options.upstream_branch filter_msg = ["", " (filtering out %s)" % options.filters][len(options.filters) > 0] gbp.log.info("Importing '%s' to branch '%s'%s..." % (source.path, - upstream_branch, + import_branch, filter_msg)) gbp.log.info("Source package is %s" % sourcepackage) gbp.log.info("Upstream version is %s" % version) - import_branch = [ options.upstream_branch, None ][is_empty] msg = upstream_import_commit_msg(options, version) - if options.vcs_tag: - parents = [repo.rev_parse("%s^{}" % repo.version_to_tag(options.vcs_tag, version))] - else: - parents = None - commit = repo.commit_dir(source.unpacked, msg=msg, branch=import_branch, - other_parents=parents, + other_parents=repo.vcs_tag_parent(options.vcs_tag, version), + create_missing_branch=is_empty, ) if options.pristine_tar: if pristine_orig: - repo.pristine_tar.commit(pristine_orig, upstream_branch) + repo.rrr_branch('pristine-tar') + repo.create_pristinetar_commits(import_branch, + pristine_orig, + component_tarballs) else: gbp.log.warn("'%s' not an archive, skipping pristine-tar" % source.path) @@ -438,19 +600,19 @@ commit=commit, sign=options.sign_tags, keyid=options.keyid) + if is_empty: - repo.create_branch(options.upstream_branch, rev=commit) - repo.force_head(options.upstream_branch, hard=True) - if options.debian_branch != 'master': - repo.rename_branch('master', options.debian_branch) + repo.create_branch(branch=options.debian_branch, rev=commit) + repo.force_head(options.debian_branch, hard=True) elif options.merge: + repo.rrr_branch(options.debian_branch) debian_branch_merge(repo, tag, version, options) # Update working copy and index if we've possibly updated the # checked out branch current_branch = repo.get_branch() - if current_branch in [ options.upstream_branch, - repo.pristine_tar_branch]: + if current_branch in [options.upstream_branch, + repo.pristine_tar_branch]: repo.force_head(current_branch, hard=True) except (gbpc.CommandExecFailed, GitRepositoryError) as err: msg = str(err) or 'Unknown error, please report a bug' @@ -459,6 +621,16 @@ if str(err): gbp.log.err(err) ret = 1 + if repo and repo.has_rollbacks() and options.rollback: + gbp.log.err("Error detected, Will roll back changes.") + try: + repo.rollback() + # Make sure the very last line as an error message + gbp.log.err("Rolled back changes after import error.") + except Exception as e: + gbp.log.err("%s" % e) + gbp.log.err("Clean up manually and please report a bug: %s" % + repo.rollback_errors) if pristine_orig and linked and not options.symlink_orig: os.unlink(pristine_orig) @@ -470,6 +642,7 @@ gbp.log.info("Successfully imported version %s of %s" % (version, source.path)) return ret + if __name__ == "__main__": sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/import_srpm.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/import_srpm.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/import_srpm.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/import_srpm.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006,2007,2011 Guido Guenther +# (C) 2006,2007,2011,2016 Guido Guenther # (C) 2012 Intel Corporation # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ # """Import an RPM source package into a Git repository""" -from six.moves import configparser import sys import re import os @@ -31,12 +30,14 @@ import gbp.command_wrappers as gbpc from gbp.tmpfile import init_tmpdir, del_tmpdir, tempfile from gbp.rpm import (parse_srpm, guess_spec, SpecFile, NoSpecError, - RpmUpstreamSource, compose_version_str) + RpmUpstreamSource, compose_version_str, filter_version) from gbp.rpm.git import (RpmGitRepository, GitRepositoryError) from gbp.git.modifier import GitModifier from gbp.config import (GbpOptionParserRpm, GbpOptionGroup, - no_upstream_branch_msg) + no_upstream_branch_msg) from gbp.errors import GbpError +from gbp.scripts.common import ExitCodes, is_download +from gbp.scripts.common import repo_setup import gbp.log from gbp.pkg import parse_archive_filename @@ -45,6 +46,7 @@ You need to reate it or use --packaging-branch to specify it. """ + class SkipImport(Exception): """Nothing imported""" pass @@ -64,6 +66,7 @@ raise GbpError("Download failed: %s" % err.reason) return local_fn + def download_source(pkg): """Download package from a remote location""" if re.match(r'[a-z]{1,5}://', pkg): @@ -122,70 +125,76 @@ parser = GbpOptionParserRpm(command=os.path.basename(name), prefix='', usage='%prog [options] /path/to/package' - '.src.rpm') - except configparser.ParsingError as err: + '.src.rpm [target]') + except GbpError as err: gbp.log.err(err) return None import_group = GbpOptionGroup(parser, "import options", - "pristine-tar and filtering") + "pristine-tar and filtering") tag_group = GbpOptionGroup(parser, "tag options", - "options related to git tag creation") + "options related to git tag creation") branch_group = GbpOptionGroup(parser, "version and branch naming options", - "version number and branch layout options") + "version number and branch layout options") - for group in [import_group, branch_group, tag_group ]: + for group in [import_group, branch_group, tag_group]: parser.add_option_group(group) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") parser.add_config_file_option(option_name="color", dest="color", - type='tristate') + type='tristate') parser.add_config_file_option(option_name="color-scheme", dest="color_scheme") parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir") parser.add_config_file_option(option_name="vendor", action="store", - dest="vendor") + dest="vendor") parser.add_option("--download", action="store_true", dest="download", default=False, help="download source package") branch_group.add_config_file_option(option_name="packaging-branch", - dest="packaging_branch") + dest="packaging_branch") branch_group.add_config_file_option(option_name="upstream-branch", - dest="upstream_branch") + dest="upstream_branch") branch_group.add_boolean_config_file_option( - option_name="create-missing-branches", - dest="create_missing_branches") + option_name="create-missing-branches", + dest="create_missing_branches") branch_group.add_option("--orphan-packaging", action="store_true", - dest="orphan_packaging", default=False, - help="The packaging branch doesn't base on upstream") + dest="orphan_packaging", default=False, + help="The packaging branch doesn't base on upstream") branch_group.add_option("--native", action="store_true", - dest="native", default=False, - help="This is a dist native package, no separate " - "upstream branch") + dest="native", default=False, + help="This is a dist native package, no separate " + "upstream branch") tag_group.add_boolean_config_file_option(option_name="sign-tags", - dest="sign_tags") + dest="sign_tags") tag_group.add_config_file_option(option_name="keyid", - dest="keyid") + dest="keyid") tag_group.add_config_file_option(option_name="packaging-tag", - dest="packaging_tag") + dest="packaging_tag") tag_group.add_config_file_option(option_name="upstream-tag", - dest="upstream_tag") + dest="upstream_tag") import_group.add_config_file_option(option_name="filter", - dest="filters", action="append") + dest="filters", action="append") import_group.add_boolean_config_file_option(option_name="pristine-tar", - dest="pristine_tar") + dest="pristine_tar") import_group.add_option("--allow-same-version", action="store_true", - dest="allow_same_version", default=False, - help="allow to import already imported version") + dest="allow_same_version", default=False, + help="allow to import already imported version") import_group.add_boolean_config_file_option( - option_name="author-is-committer", - dest="author_is_committer") + option_name="author-is-committer", + dest="author_is_committer") import_group.add_config_file_option(option_name="packaging-dir", - dest="packaging_dir") + dest="packaging_dir") + + parser.add_config_file_option(option_name="repo-user", dest="repo_user", + choices=['DEBIAN', 'GIT']) + parser.add_config_file_option(option_name="repo-email", dest="repo_email", + choices=['DEBIAN', 'GIT']) return parser + def parse_args(argv): """Parse commandline arguments""" parser = build_parser(argv[0]) @@ -194,6 +203,11 @@ (options, args) = parser.parse_args(argv[1:]) gbp.log.setup(options.color, options.verbose, options.color_scheme) + + if options.download: + gbp.log.warn("Passing --download explicitly is deprecated.") + + options.download = is_download(args) return options, args @@ -205,8 +219,16 @@ skipped = False options, args = parse_args(argv) + if not options: + return ExitCodes.parse_error - if len(args) != 1: + if len(args) == 1: + srpm = args[0] + target = None + elif len(args) == 2: + srpm = args[0] + target = args[1] + else: gbp.log.err("Need to give exactly one package to import. Try --help.") return 1 try: @@ -215,7 +237,6 @@ gbp.log.err(err) return 1 try: - srpm = args[0] if options.download: srpm = download_source(srpm) @@ -240,7 +261,7 @@ dirs['src'] = os.path.abspath(srpm) spec = guess_spec(srpm, True, preferred_spec) else: - gbp.log.debug("Trying to import an srpm from '%s' with spec "\ + gbp.log.debug("Trying to import an srpm from '%s' with spec " "file '%s'" % (os.path.dirname(srpm), srpm)) dirs['src'] = os.path.abspath(os.path.dirname(srpm)) spec = SpecFile(srpm) @@ -259,8 +280,10 @@ except GitRepositoryError: gbp.log.info("No git repository found, creating one.") is_empty = True - repo = RpmGitRepository.create(spec.name) + target = target or spec.name + repo = RpmGitRepository.create(target) os.chdir(repo.path) + repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo) if repo.bare: set_bare_repo_options(options) @@ -281,8 +304,8 @@ files = os.listdir(dirs['src']) else: # Need to copy files to the packaging directory given by caller - files = [os.path.basename(patch.path) \ - for patch in spec.patchseries(unapplied=True, ignored=True)] + files = [os.path.basename(patch.path) + for patch in spec.patchseries(unapplied=True, ignored=True)] for filename in spec.sources().values(): files.append(os.path.basename(filename)) files.append(os.path.join(spec.specdir, spec.specfile)) @@ -306,10 +329,18 @@ else: sources = None - src_tag_format = options.packaging_tag if options.native \ - else options.upstream_tag tag_str_fields = dict(spec.version, vendor=options.vendor.lower()) - src_tag = repo.version_to_tag(src_tag_format, tag_str_fields) + if options.native: + src_tag_format = options.packaging_tag + src_tag = repo.version_to_tag(src_tag_format, tag_str_fields) + upstream_tag = src_tag + upstream_str_fields = tag_str_fields + else: + src_tag_format = options.upstream_tag + src_tag = repo.version_to_tag(src_tag_format, tag_str_fields) + upstream_str_fields = filter_version(tag_str_fields, 'release', 'epoch') + upstream_tag = repo.version_to_tag(src_tag_format, upstream_str_fields) + ver_str = compose_version_str(spec.version) if repo.find_version(options.packaging_tag, tag_str_fields): @@ -339,7 +370,7 @@ # Import sources if sources: - src_commit = repo.find_version(src_tag_format, tag_str_fields) + src_commit = repo.find_version(src_tag_format, upstream_str_fields) if not src_commit: gbp.log.info("Tag %s not found, importing sources" % src_tag) @@ -351,17 +382,17 @@ branch) else: gbp.log.err(no_upstream_branch_msg % branch + "\n" - "Also check the --create-missing-branches option.") + "Also check the --create-missing-branches option.") raise GbpError src_vendor = "Native" if options.native else "Upstream" msg = "%s version %s" % (src_vendor, spec.upstreamversion) src_commit = repo.commit_dir(sources.unpacked, - "Imported %s" % msg, - branch, - author=author, - committer=committer, - create_missing_branch=options.create_missing_branches) - repo.create_tag(name=src_tag, + "Import %s" % msg, + branch, + author=author, + committer=committer, + create_missing_branch=options.create_missing_branches) + repo.create_tag(name=src_tag if options.native else upstream_tag, msg=msg, commit=src_commit, sign=options.sign_tags, @@ -372,7 +403,7 @@ archive_fmt = parse_archive_filename(orig_tarball)[1] if archive_fmt == 'tar': repo.pristine_tar.commit(orig_tarball, - 'refs/heads/%s' % + 'refs/heads/%s' % options.upstream_branch) else: gbp.log.warn('Ignoring pristine-tar, %s archives ' @@ -399,11 +430,11 @@ if options.orphan_packaging or not sources: commit = repo.commit_dir(dirs['packaging_base'], - "Imported %s" % msg, - branch, - author=author, - committer=committer, - create_missing_branch=options.create_missing_branches) + "Import %s" % msg, + branch, + author=author, + committer=committer, + create_missing_branch=options.create_missing_branches) else: # Copy packaging files to the unpacked sources dir try: @@ -417,12 +448,12 @@ shutil.copy2(os.path.join(dirs['packaging'], fname), pkgsubdir) commit = repo.commit_dir(sources.unpacked, - "Imported %s" % msg, - branch, - other_parents=[src_commit], - author=author, - committer=committer, - create_missing_branch=options.create_missing_branches) + "Import %s" % msg, + branch, + other_parents=[src_commit], + author=author, + committer=committer, + create_missing_branch=options.create_missing_branches) # Import patches on top of the source tree # (only for non-native packages with non-orphan packaging) force_to_branch_head(repo, options.packaging_branch) @@ -458,9 +489,10 @@ del_tmpdir() if not ret and not skipped: - gbp.log.info("Version '%s' imported under '%s'" % (ver_str, spec.name)) + gbp.log.info("Version '%s' imported under '%s'" % (ver_str, repo.path)) return ret + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/pq.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/pq.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/pq.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/pq.py 2017-02-11 19:33:12.000000000 +0000 @@ -17,7 +17,6 @@ # """Manage Debian patches on a patch queue branch""" -from six.moves import configparser import errno import os import shutil @@ -25,20 +24,23 @@ import tempfile import re from gbp.config import GbpOptionParserDebian -from gbp.git import (GitRepositoryError, GitRepository) +from gbp.deb.source import DebianSource +from gbp.deb.git import DebianGitRepository +from gbp.git import GitRepositoryError from gbp.command_wrappers import (GitCommand, CommandExecFailed) from gbp.errors import GbpError import gbp.log from gbp.patch_series import (PatchSeries, Patch) from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base, - parse_gbp_commands, format_patch, - switch_to_pq_branch, apply_single_patch, - apply_and_commit_patch, switch_pq, - drop_pq, get_maintainer_from_control) + parse_gbp_commands, format_patch, + switch_to_pq_branch, apply_single_patch, + apply_and_commit_patch, switch_pq, + drop_pq, get_maintainer_from_control) +from gbp.scripts.common import ExitCodes from gbp.dch import extract_bts_cmds PATCH_DIR = "debian/patches/" -SERIES_FILE = os.path.join(PATCH_DIR,"series") +SERIES_FILE = os.path.join(PATCH_DIR, "series") def parse_old_style_topic(commit_info): @@ -145,7 +147,7 @@ return msg -def commit_patches(repo, branch, patches, options): +def commit_patches(repo, branch, patches, options, patch_dir): """ Commit chanages exported from patch queue """ @@ -155,24 +157,46 @@ vfs = gbp.git.vfs.GitVfs(repo, branch) try: - oldseries = vfs.open('debian/patches/series') - oldpatches = [ p.strip() for p in oldseries.readlines() ] - oldseries.close() + with vfs.open('debian/patches/series') as oldseries: + oldpatches = [p.strip() for p in oldseries.readlines()] except IOError: # No series file yet oldpatches = [] - newpatches = [ p[len(PATCH_DIR):] for p in patches ] + newpatches = [p[len(patch_dir):] for p in patches] # FIXME: handle case were only the contents of the patches changed added, removed = compare_series(oldpatches, newpatches) msg = format_series_diff(added, removed, options) - repo.add_files(PATCH_DIR) - repo.commit_staged(msg=msg) + + if not repo.is_clean(paths='debian/patches')[0]: + repo.add_files(PATCH_DIR, force=True) + repo.commit_staged(msg=msg) return added, removed +def find_upstream_commit(repo, branch, upstream_tag): + """ + Find commit corresponding upstream version based on changelog + """ + vfs = gbp.git.vfs.GitVfs(repo, branch) + cl = DebianSource(vfs).changelog + upstream_commit = repo.find_version(upstream_tag, cl.upstream_version) + if not upstream_commit: + raise GbpError("Couldn't find upstream version %s" % + cl.upstream_version) + return upstream_commit + + +def pq_on_upstream_tag(pq_from): + """Return True if the patch queue is based on the uptream tag, + False if its based on the debian packaging branch""" + return True if pq_from.upper() == 'TAG' else False + + def export_patches(repo, branch, options): """Export patches from the pq branch into a patch series""" + patch_dir = os.path.join(repo.path, PATCH_DIR) + series_file = os.path.join(repo.path, SERIES_FILE) if is_pq_branch(branch): base = pq_branch_base(branch) gbp.log.info("On '%s', switching to '%s'" % (branch, base)) @@ -181,21 +205,26 @@ pq_branch = pq_branch_name(branch) try: - shutil.rmtree(PATCH_DIR) + shutil.rmtree(patch_dir) except OSError as e: if e.errno != errno.ENOENT: raise GbpError("Failed to remove patch dir: %s" % e.strerror) else: - gbp.log.debug("%s does not exist." % PATCH_DIR) + gbp.log.debug("%s does not exist." % patch_dir) + + if pq_on_upstream_tag(options.pq_from): + base = find_upstream_commit(repo, branch, options.upstream_tag) + else: + base = branch - patches = generate_patches(repo, branch, pq_branch, PATCH_DIR, options) + patches = generate_patches(repo, base, pq_branch, patch_dir, options) if patches: - with open(SERIES_FILE, 'w') as seriesfd: + with open(series_file, 'w') as seriesfd: for patch in patches: - seriesfd.write(os.path.relpath(patch, PATCH_DIR) + '\n') + seriesfd.write(os.path.relpath(patch, patch_dir) + '\n') if options.commit: - added, removed = commit_patches(repo, branch, patches, options) + added, removed = commit_patches(repo, branch, patches, options, patch_dir) if added: what = 'patches' if len(added) > 1 else 'patch' gbp.log.info("Added %s %s to patch series" % (what, ', '.join(added))) @@ -203,7 +232,7 @@ what = 'patches' if len(removed) > 1 else 'patch' gbp.log.info("Removed %s %s from patch series" % (what, ', '.join(removed))) else: - GitCommand('status')(['--', PATCH_DIR]) + GitCommand('status', cwd=repo.path)(['--', PATCH_DIR]) else: gbp.log.info("No patches on '%s' - nothing to do." % pq_branch) @@ -211,7 +240,7 @@ drop_pq(repo, branch) -def safe_patches(series): +def safe_patches(series, repo): """ Safe the current patches in a temporary directory below .git/ @@ -224,7 +253,7 @@ src = os.path.dirname(series) name = os.path.basename(series) - tmpdir = tempfile.mkdtemp(dir='.git/', prefix='gbp-pq') + tmpdir = tempfile.mkdtemp(dir=repo.git_dir, prefix='gbp-pq') patches = os.path.join(tmpdir, 'patches') series = os.path.join(patches, name) @@ -234,19 +263,25 @@ return (tmpdir, series) -def import_quilt_patches(repo, branch, series, tries, force): +def import_quilt_patches(repo, branch, series, tries, force, pq_from, + upstream_tag): """ apply a series of quilt patches in the series file 'series' to branch the patch-queue branch for 'branch' @param repo: git repository to work on - @param branch: branch to base pqtch queue on - @param series; series file to read patches from + @param branch: branch to base patch queue on + @param series: series file to read patches from @param tries: try that many times to apply the patches going back one commit in the branches history after each failure. @param force: import the patch series even if the branch already exists + @param pq_from: what to use as the starting point for the pq branch. + DEBIAN indicates the current branch, TAG indicates that + the corresponding upstream tag should be used. + @param upstream_tag: upstream tag template to use """ tmpdir = None + series = os.path.join(repo.path, series) if is_pq_branch(branch): if force: @@ -267,11 +302,16 @@ % pq_branch) maintainer = get_maintainer_from_control(repo) - commits = repo.get_commits(num=tries, first_parent=True) + if pq_on_upstream_tag(pq_from): + commits = [find_upstream_commit(repo, branch, upstream_tag)] + else: # pq_from == 'DEBIAN' + commits = repo.get_commits(num=tries, first_parent=True) # If we go back in history we have to safe our pq so we always try to apply # the latest one - if len(commits) > 1: - tmpdir, series = safe_patches(series) + # If we are using the upstream_tag, we always need a copy of the patches + if len(commits) > 1 or pq_on_upstream_tag(pq_from): + if os.path.exists(series): + tmpdir, series = safe_patches(series, repo) queue = PatchSeries.read_series_file(series) @@ -300,7 +340,7 @@ else: # All patches applied successfully break - i-=1 + i -= 1 else: raise GbpError("Couldn't apply patches") @@ -308,31 +348,44 @@ gbp.log.debug("Remove temporary patch safe '%s'" % tmpdir) shutil.rmtree(tmpdir) + return len(queue) + + +def rebase_pq(repo, branch, pq_from, upstream_tag): -def rebase_pq(repo, branch): if is_pq_branch(branch): base = pq_branch_base(branch) else: switch_to_pq_branch(repo, branch) base = branch - GitCommand("rebase")([base]) + + if pq_on_upstream_tag(pq_from): + _from = find_upstream_commit(repo, base, upstream_tag) + else: + _from = base + + GitCommand("rebase", cwd=repo.path)([_from]) + + +def usage_msg(): + return """%prog [options] action - maintain patches on a patch queue branch +Actions: + export export the patch queue associated to the current branch + into a quilt patch series in debian/patches/ and update the + series file. + import create a patch queue branch from quilt patches in debian/patches. + rebase switch to patch queue branch associated to the current + branch and rebase against current branch. + drop drop (delete) the patch queue associated to the current branch. + apply apply a patch + switch switch to patch-queue branch and vice versa""" def build_parser(name): try: parser = GbpOptionParserDebian(command=os.path.basename(name), - usage="%prog [options] action - maintain patches on a patch queue branch\n" - "Actions:\n" - " export export the patch queue associated to the current branch\n" - " into a quilt patch series in debian/patches/ and update the\n" - " series file.\n" - " import create a patch queue branch from quilt patches in debian/patches.\n" - " rebase switch to patch queue branch associated to the current\n" - " branch and rebase against current branch.\n" - " drop drop (delete) the patch queue associated to the current branch.\n" - " apply apply a patch\n" - " switch switch to patch-queue branch and vice versa") - except configparser.ParsingError as err: + usage=usage_msg()) + except GbpError as err: gbp.log.err(err) return None @@ -352,6 +405,8 @@ dest="color_scheme") parser.add_config_file_option(option_name="meta-closes", dest="meta_closes") parser.add_config_file_option(option_name="meta-closes-bugnum", dest="meta_closes_bugnum") + parser.add_config_file_option(option_name="pq-from", dest="pq_from", choices=['DEBIAN', 'TAG']) + parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag") return parser @@ -367,7 +422,7 @@ (options, args) = parse_args(argv) if not options: - return 1 + return ExitCodes.parse_error gbp.log.setup(options.color, options.verbose, options.color_scheme) @@ -390,7 +445,7 @@ return 1 try: - repo = GitRepository(os.path.curdir) + repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: gbp.log.err("%s is not a git repository" % (os.path.abspath('.'))) return 1 @@ -402,20 +457,25 @@ elif action == "import": series = SERIES_FILE tries = options.time_machine if (options.time_machine > 0) else 1 - import_quilt_patches(repo, current, series, tries, options.force) + num = import_quilt_patches(repo, current, series, tries, + options.force, options.pq_from, + options.upstream_tag) current = repo.get_branch() - gbp.log.info("Patches listed in '%s' imported on '%s'" % - (series, current)) + gbp.log.info("%d patches listed in '%s' imported on '%s'" % + (num, series, current)) elif action == "drop": drop_pq(repo, current) elif action == "rebase": - rebase_pq(repo, current) + rebase_pq(repo, current, options.pq_from, options.upstream_tag) elif action == "apply": patch = Patch(patchfile) maintainer = get_maintainer_from_control(repo) apply_single_patch(repo, current, patch, maintainer, options.topic) elif action == "switch": switch_pq(repo, current) + except KeyboardInterrupt: + retval = 1 + gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except (GbpError, GitRepositoryError) as err: @@ -425,5 +485,6 @@ return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/pq_rpm.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/pq_rpm.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/pq_rpm.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/pq_rpm.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2011 Guido Günther +# (C) 2011,2016 Guido Günther # (C) 2012-2014 Intel Corporation # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,7 +18,6 @@ # """manage patches in a patch queue""" -from six.moves import configparser import bz2 import errno import gzip @@ -37,10 +36,13 @@ from gbp.pkg import parse_archive_filename from gbp.rpm import (SpecFile, NoSpecError, guess_spec, guess_spec_repo, spec_from_repo) +from gbp.scripts.common import ExitCodes from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base, - parse_gbp_commands, format_patch, format_diff, - switch_to_pq_branch, apply_single_patch, apply_and_commit_patch, - drop_pq, switch_pq) + parse_gbp_commands, format_patch, format_diff, + switch_to_pq_branch, apply_single_patch, + apply_and_commit_patch, + drop_pq, switch_pq) + from gbp.scripts.common.buildpackage import dump_tree @@ -54,6 +56,7 @@ merge_base = None return merge_base == parent_sha1 + def generate_patches(repo, start, end, outdir, options): """ Generate patch files from git @@ -99,7 +102,7 @@ 'gbp-rpm', ('ignore'), ('if', 'ifarch')) - if not 'ignore' in cmds: + if 'ignore' not in cmds: patch_fn = format_patch(outdir, repo, info, patches, options.patch_numbers) if patch_fn: @@ -115,7 +118,7 @@ if patch_fn: patches.append(patch_fn) - return patches, commands + return [os.path.relpath(p) for p in patches], commands def rm_patch_files(spec): @@ -222,7 +225,7 @@ if len(queue) > 0: gbp.log.debug("Safeing patches '%s' in '%s'" % - (os.path.dirname(queue[0].path), tmpdir)) + (os.path.dirname(queue[0].path), tmpdir)) for patch in queue: base, _archive_fmt, comp = parse_archive_filename(patch.path) uncompressors = {'gzip': gzip.open, 'bzip2': bz2.BZ2File} @@ -295,7 +298,7 @@ repo.create_branch(pq_branch, upstream_commit, force=True) except GitRepositoryError as err: raise GbpError("Cannot create patch-queue branch '%s': %s" % - (pq_branch, err)) + (pq_branch, err)) # Put patches in a safe place if spec_treeish: @@ -314,7 +317,7 @@ if not queue: return gbp.log.info("Trying to apply patches from branch '%s' onto '%s'" % - (base, upstream_commit)) + (base, upstream_commit)) for patch in queue: gbp.log.debug("Applying %s" % patch.path) apply_and_commit_patch(repo, patch, packager) @@ -323,8 +326,8 @@ repo.delete_branch(pq_branch) raise GbpError('Import failed: %s' % err) - gbp.log.info("Patches listed in '%s' imported on '%s'" % (spec.specfile, - pq_branch)) + gbp.log.info("%d patches listed in '%s' imported on '%s'" % (len(queue), spec.specfile, + pq_branch)) def rebase_pq(repo, options): @@ -342,13 +345,9 @@ GitCommand("rebase")([upstream_commit]) -def build_parser(name): - """Construct command line parser""" - try: - parser = GbpOptionParserRpm(command=os.path.basename(name), - prefix='', usage= -"""%prog [options] action - maintain patches on a patch queue branch -tions: +def usage_msg(): + return """%prog [options] action - maintain patches on a patch queue branch +Ations: export Export the patch queue / devel branch associated to the current branch into a patch series in and update the spec file import Create a patch queue / devel branch from spec file @@ -358,29 +357,36 @@ drop Drop (delete) the patch queue /devel branch associated to the current branch. apply Apply a patch -switch Switch to patch-queue branch and vice versa.""") +switch Switch to patch-queue branch and vice versa.""" + - except configparser.ParsingError as err: - gbp.log.err('Invalid config file: %s' % err) +def build_parser(name): + """Construct command line parser""" + try: + parser = GbpOptionParserRpm(command=os.path.basename(name), + prefix='', usage=usage_msg()) + + except GbpError as err: + gbp.log.err(err) return None parser.add_boolean_config_file_option(option_name="patch-numbers", - dest="patch_numbers") + dest="patch_numbers") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", - default=False, help="Verbose command execution") + default=False, help="Verbose command execution") parser.add_option("--force", dest="force", action="store_true", - default=False, - help="In case of import even import if the branch already exists") + default=False, + help="In case of import even import if the branch already exists") parser.add_config_file_option(option_name="color", dest="color", - type='tristate') + type='tristate') parser.add_config_file_option(option_name="color-scheme", - dest="color_scheme") + dest="color_scheme") parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir") parser.add_config_file_option(option_name="upstream-tag", - dest="upstream_tag") + dest="upstream_tag") parser.add_config_file_option(option_name="spec-file", dest="spec_file") parser.add_config_file_option(option_name="packaging-dir", - dest="packaging_dir") + dest="packaging_dir") return parser @@ -398,7 +404,7 @@ (options, args) = parse_args(argv) if not options: - return 1 + return ExitCodes.parse_error gbp.log.setup(options.color, options.verbose, options.color_scheme) @@ -443,6 +449,9 @@ apply_single_patch(repo, current, patch, fallback_author=None) elif action == "switch": switch_pq(repo, current) + except KeyboardInterrupt: + retval = 1 + gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except GitRepositoryError as err: @@ -457,6 +466,6 @@ return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/pull.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/pull.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/pull.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/pull.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2009,2013 Guido Guenther +# (C) 2009,2013,2017 Guido Guenther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -19,7 +19,6 @@ # """Pull remote changes and fast forward debian, upstream and pristine-tar branch""" -from six.moves import configparser import sys import os import os.path @@ -28,10 +27,11 @@ from gbp.errors import GbpError from gbp.git import GitRepositoryError from gbp.deb.git import DebianGitRepository +from gbp.scripts.common import ExitCodes import gbp.log -def fast_forward_branch(branch, repo, options): +def fast_forward_branch(rem_repo, branch, repo, options): """ update branch to its remote branch, fail on non fast forward updates unless --force is given @@ -40,7 +40,11 @@ """ update = False - remote = repo.get_merge_branch(branch) + if rem_repo: + remote = 'refs/remotes/%s/%s' % (rem_repo, branch) + else: + remote = repo.get_merge_branch(branch) + if not remote: gbp.log.warn("No branch tracking '%s' found - skipping." % branch) return False @@ -74,8 +78,8 @@ def build_parser(name): try: parser = GbpOptionParser(command=os.path.basename(name), prefix='', - usage='%prog [options] - safely update a repository from remote') - except configparser.ParsingError as err: + usage='%prog [options] [repo] - safely update a repository from remote') + except GbpError as err: gbp.log.err(err) return None @@ -103,19 +107,30 @@ parser = build_parser(argv[0]) if not parser: return None, None - return parser.parse_args(argv) + options, args = parser.parse_args(argv) + if len(args) > 2: + parser.print_help(file=sys.stderr) + return None, None + return options, args def main(argv): retval = 0 current = None + rem_repo = None (options, args) = parse_args(argv) if not options: - return 1 + return ExitCodes.parse_error gbp.log.setup(options.color, options.verbose, options.color_scheme) + if len(args) == 2: + rem_repo = args[1] + gbp.log.info("Fetching from '%s'" % rem_repo) + else: + gbp.log.info("Fetching from default remote for each branch") + try: repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: @@ -147,10 +162,10 @@ gbp.log.err(out) raise GbpError - repo.fetch(depth=options.depth) - repo.fetch(depth=options.depth, tags=True) + repo.fetch(rem_repo, depth=options.depth) + repo.fetch(rem_repo, depth=options.depth, tags=True) for branch in branches: - if not fast_forward_branch(branch, repo, options): + if not fast_forward_branch(rem_repo, branch, repo, options): retval = 2 if options.redo_pq: @@ -159,6 +174,9 @@ Command("gbp-pq")(["import"]) repo.set_branch(current) + except KeyboardInterrupt: + retval = 1 + gbp.log.err("Interrupted. Aborting.") except CommandExecFailed: retval = 1 except (GbpError, GitRepositoryError) as err: @@ -168,6 +186,7 @@ return retval + if __name__ == '__main__': sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/rpm_ch.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/rpm_ch.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/rpm_ch.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/rpm_ch.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,454 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2007, 2008, 2009, 2010, 2013 Guido Guenther +# (C) 2014-2015 Intel Corporation +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# +# +"""Generate RPM changelog entries from git commit messages""" + +from datetime import datetime +import os.path +import pwd +import re +import sys +import socket + +import gbp.command_wrappers as gbpc +import gbp.log +from gbp.config import GbpOptionParserRpm, GbpOptionGroup +from gbp.errors import GbpError +from gbp.rpm import (guess_spec, NoSpecError, SpecFile, split_version_str, + compose_version_str) +from gbp.rpm.changelog import Changelog, ChangelogParser, ChangelogError +from gbp.rpm.git import GitRepositoryError, RpmGitRepository +from gbp.rpm.policy import RpmPkgPolicy +from gbp.scripts.common import ExitCodes +from gbp.tmpfile import init_tmpdir, del_tmpdir + + +ChangelogEntryFormatter = RpmPkgPolicy.ChangelogEntryFormatter + + +class ChangelogFile(object): + """Container for changelog file, whether it be a standalone changelog + or a spec file""" + + def __init__(self, file_path): + parser = ChangelogParser(RpmPkgPolicy) + + if os.path.splitext(file_path)[1] == '.spec': + gbp.log.debug("Using spec file '%s' as changelog" % file_path) + self._file = SpecFile(file_path) + self.changelog = parser.raw_parse_string(self._file.get_changelog()) + else: + self._file = os.path.abspath(file_path) + if not os.path.exists(file_path): + gbp.log.info("Changelog '%s' not found, creating new " + "changelog file" % file_path) + self.changelog = Changelog(RpmPkgPolicy) + else: + gbp.log.debug("Using changelog file '%s'" % file_path) + self.changelog = parser.raw_parse_file(self._file) + + # Parse topmost section and try to determine the start commit + if self.changelog.sections: + self.changelog.sections[0] = parser.parse_section( + self.changelog.sections[0]) + + def write(self): + """Write changelog file to disk""" + if isinstance(self._file, SpecFile): + self._file.set_changelog(str(self.changelog)) + self._file.write_spec_file() + else: + with open(self._file, 'w') as fobj: + fobj.write(str(self.changelog)) + + @property + def path(self): + """File path""" + if isinstance(self._file, SpecFile): + return self._file.specpath + else: + return self._file + + +def load_customizations(customization_file): + """Load user defined customizations file""" + # Load customization file + if not customization_file: + return + customizations = {} + try: + execfile(customization_file, customizations, customizations) + except Exception as err: + raise GbpError("Failed to load customization file: %s" % err) + + # Set customization classes / functions + global ChangelogEntryFormatter + if 'ChangelogEntryFormatter' in customizations: + ChangelogEntryFormatter = customizations.get('ChangelogEntryFormatter') + + +def determine_editor(options): + """Determine text editor""" + + # Check if we need to spawn an editor + states = ['always'] + if options.release: + states.append('release') + if options.spawn_editor not in states: + return None + + # Determine the correct editor + if options.editor_cmd: + return options.editor_cmd + elif 'EDITOR' in os.environ: + return os.environ['EDITOR'] + else: + return 'vi' + + +def check_branch(repo, options): + """Check the current git branch""" + try: + branch = repo.get_branch() + except GitRepositoryError: + branch = None + if options.packaging_branch != branch and not options.ignore_branch: + gbp.log.err("You are not on branch '%s' but on '%s'" % + (options.packaging_branch, branch)) + raise GbpError("Use --ignore-branch to ignore or " + "--packaging-branch to set the branch name.") + + +def parse_spec_file(repo, options): + """Find and parse spec file""" + if options.spec_file: + spec_path = os.path.join(repo.path, options.spec_file) + spec = SpecFile(spec_path) + else: + spec = guess_spec(os.path.join(repo.path, options.packaging_dir), + True, os.path.basename(repo.path) + '.spec') + options.packaging_dir = spec.specdir + return spec + + +def parse_changelog_file(repo, spec, options): + """Find and parse changelog file""" + changes_file_name = os.path.splitext(spec.specfile)[0] + '.changes' + changes_file_path = os.path.join(options.packaging_dir, changes_file_name) + + # Determine changelog file path + if options.changelog_file == "SPEC": + changelog_path = spec.specpath + elif options.changelog_file == "CHANGES": + changelog_path = changes_file_path + elif options.changelog_file == 'auto': + if os.path.exists(changes_file_path): + changelog_path = changes_file_path + else: + changelog_path = spec.specpath + else: + changelog_path = os.path.join(repo.path, options.changelog_file) + + return ChangelogFile(changelog_path) + + +def guess_commit(section, repo, options): + """Guess the last commit documented in a changelog header""" + + if not section: + return None + header = section.header + + # Try to parse the fields from the header revision + rev_re = '^%s$' % re.sub(r'%\((\S+?)\)s', r'(?P<\1>\S+)', + options.changelog_revision) + match = re.match(rev_re, header['revision'], re.I) + fields = match.groupdict() if match else {} + + # First, try to find tag-name, if present + if 'tagname' in fields: + gbp.log.debug("Trying to find tagname %s" % fields['tagname']) + try: + return repo.rev_parse("%s^0" % fields['tagname']) + except GitRepositoryError: + gbp.log.warn("Changelog points to tagname '%s' which is not found " + "in the git repository" % fields['tagname']) + + # Next, try to find packaging tag matching the version + tag_str_fields = {'vendor': options.vendor} + if 'version' in fields: + gbp.log.debug("Trying to find packaging tag for version '%s'" % + fields['version']) + full_version = fields['version'] + tag_str_fields.update(split_version_str(full_version)) + elif 'upstreamversion' in fields: + gbp.log.debug("Trying to find packaging tag for version '%s'" % + fields['upstreamversion']) + tag_str_fields['upstreamversion'] = fields['upstreamversion'] + if 'release' in fields: + tag_str_fields['release'] = fields['release'] + commit = repo.find_version(options.packaging_tag, + tag_str_fields) + if commit: + return commit + else: + gbp.log.info("Couldn't find packaging tag for version %s" % + header['revision']) + + # As a last resort we look at the timestamp + timestamp = header['time'].isoformat() + last = repo.get_commits(num=1, options="--until='%s'" % timestamp) + if last: + gbp.log.info("Using commit (%s) before the last changelog timestamp " + "(%s)" % (last, timestamp)) + return last[0] + return None + + +def get_start_commit(changelog, repo, options): + """Get the start commit from which to generate new entries""" + if options.since: + since = options.since + else: + if changelog.sections: + since = guess_commit(changelog.sections[0], repo, options) + else: + since = None + if not since: + raise GbpError("Couldn't determine starting point from " + "changelog, please use the '--since' option") + gbp.log.info("Continuing from commit '%s'" % since) + return since + + +def get_author(repo, use_git_config): + """Get author and email from git configuration""" + author = email = None + + if use_git_config: + modifier = repo.get_author_info() + author = modifier.name + email = modifier.email + + passwd_data = pwd.getpwuid(os.getuid()) + if not author: + # On some distros (Ubuntu, at least) the gecos field has it's own + # internal structure of comma-separated fields + author = passwd_data.pw_gecos.split(',')[0].strip() + if not author: + author = passwd_data.pw_name + if not email: + if 'EMAIL' in os.environ: + email = os.environ['EMAIL'] + else: + email = "%s@%s" % (passwd_data.pw_name, socket.getfqdn()) + + return author, email + + +def entries_from_commits(changelog, repo, commits, options): + """Generate a list of formatted changelog entries from a list of commits""" + entries = [] + for commit in commits: + info = repo.get_commit_info(commit) + entry_text = ChangelogEntryFormatter.compose(info, full=options.full, + ignore_re=options.ignore_regex, + id_len=options.idlen) + if entry_text: + entries.append(changelog.create_entry(author=info['author'].name, + text=entry_text)) + return entries + + +def update_changelog(changelog, entries, repo, spec, options): + """Update the changelog with a range of commits""" + # Get info for section header + now = datetime.now() + name, email = get_author(repo, options.git_author) + rev_str_fields = dict(spec.version, + version=compose_version_str(spec.version), + vendor=options.vendor, + tagname=repo.describe('HEAD', longfmt=True, + always=True)) + try: + revision = options.changelog_revision % rev_str_fields + except KeyError as err: + raise GbpError("Unable to construct revision field: unknown key " + "%s, only %s are accepted" % (err, rev_str_fields.keys())) + + # Add a new changelog section if new release or an empty changelog + if options.release or not changelog.sections: + top_section = changelog.add_section(time=now, name=name, + email=email, revision=revision) + else: + # Re-use already parsed top section + top_section = changelog.sections[0] + top_section.set_header(time=now, name=name, + email=email, revision=revision) + + # Add new entries to the topmost section + for entry in entries: + top_section.append_entry(entry) + + +def build_parser(name): + """Construct command line parser""" + try: + parser = GbpOptionParserRpm(command=os.path.basename(name), + prefix='', usage='%prog [options] paths') + except GbpError as err: + gbp.log.err(err) + return None + + range_grp = GbpOptionGroup(parser, "commit range options", + "which commits to add to the changelog") + format_grp = GbpOptionGroup(parser, "changelog entry formatting", + "how to format the changelog entries") + naming_grp = GbpOptionGroup(parser, "naming", + "branch names, tag formats, directory and file naming") + parser.add_option_group(range_grp) + parser.add_option_group(format_grp) + parser.add_option_group(naming_grp) + + # Non-grouped options + parser.add_option("-v", "--verbose", action="store_true", dest="verbose", + help="verbose command execution") + parser.add_config_file_option(option_name="color", dest="color", + type='tristate') + parser.add_config_file_option(option_name="color-scheme", + dest="color_scheme") + parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir") + parser.add_config_file_option(option_name="vendor", action="store", + dest="vendor") + parser.add_config_file_option(option_name="git-log", dest="git_log", + help="options to pass to git-log, default is '%(git-log)s'") + parser.add_boolean_config_file_option(option_name="ignore-branch", + dest="ignore_branch") + parser.add_config_file_option(option_name="customizations", + dest="customization_file", + help="Load Python code from CUSTOMIZATION_FILE. At the " + "moment, the only useful thing the code can do is define a " + "custom ChangelogEntryFormatter class.") + + # Naming group options + naming_grp.add_config_file_option(option_name="packaging-branch", + dest="packaging_branch") + naming_grp.add_config_file_option(option_name="packaging-tag", + dest="packaging_tag") + naming_grp.add_config_file_option(option_name="packaging-dir", + dest="packaging_dir") + naming_grp.add_config_file_option(option_name="changelog-file", + dest="changelog_file") + naming_grp.add_config_file_option(option_name="spec-file", dest="spec_file") + # Range group options + range_grp.add_option("-s", "--since", dest="since", + help="commit to start from (e.g. HEAD^^^, release/0.1.2)") + # Formatting group options + format_grp.add_option("--no-release", action="store_false", default=True, + dest="release", + help="no release, just update the last changelog section") + format_grp.add_boolean_config_file_option(option_name="git-author", + dest="git_author") + format_grp.add_boolean_config_file_option(option_name="full", dest="full") + format_grp.add_config_file_option(option_name="id-length", dest="idlen", + help="include N digits of the commit id in the changelog " + "entry, default is '%(id-length)s'", + type="int", metavar="N") + format_grp.add_config_file_option(option_name="ignore-regex", + dest="ignore_regex", + help="Ignore lines in commit message matching regex, " + "default is '%(ignore-regex)s'") + format_grp.add_config_file_option(option_name="changelog-revision", + dest="changelog_revision") + format_grp.add_config_file_option(option_name="spawn-editor", + dest="spawn_editor") + format_grp.add_config_file_option(option_name="editor-cmd", + dest="editor_cmd") + return parser + + +def parse_args(argv): + """Parse command line and config file options""" + parser = build_parser(argv[0]) + if not parser: + return None, None + + options, args = parser.parse_args(argv[1:]) + + if not options.changelog_revision: + options.changelog_revision = RpmPkgPolicy.Changelog.header_rev_format + + gbp.log.setup(options.color, options.verbose, options.color_scheme) + + return options, args + + +def main(argv): + """Script main function""" + options, args = parse_args(argv) + if not options: + return ExitCodes.parse_error + + try: + init_tmpdir(options.tmp_dir, prefix='rpm-ch_') + + load_customizations(options.customization_file) + editor_cmd = determine_editor(options) + + repo = RpmGitRepository('.') + check_branch(repo, options) + + # Find and parse spec file + spec = parse_spec_file(repo, options) + + # Find and parse changelog file + ch_file = parse_changelog_file(repo, spec, options) + since = get_start_commit(ch_file.changelog, repo, options) + + # Get range of commits from where to generate changes + if args: + gbp.log.info("Only looking for changes in '%s'" % ", ".join(args)) + commits = repo.get_commits(since=since, until='HEAD', paths=args, + options=options.git_log.split(" ")) + commits.reverse() + if not commits: + gbp.log.info("No changes detected from %s to %s." % (since, 'HEAD')) + + # Do the actual update + entries = entries_from_commits(ch_file.changelog, repo, commits, + options) + update_changelog(ch_file.changelog, entries, repo, spec, options) + + # Write to file + ch_file.write() + + if editor_cmd: + gbpc.Command(editor_cmd, [ch_file.path])() + + except (GbpError, GitRepositoryError, ChangelogError, NoSpecError) as err: + if len(err.__str__()): + gbp.log.err(err) + return 1 + finally: + del_tmpdir() + + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/supercommand.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/supercommand.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/scripts/supercommand.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/scripts/supercommand.py 2017-02-11 19:33:12.000000000 +0000 @@ -26,7 +26,8 @@ # Command is this module and common/ is shared code # so we don't allow these to be imported: -invalid_modules = [ 'common', 'supercommand' ] +invalid_modules = ['common', 'supercommand'] + def sanitize(cmd): """ @@ -35,6 +36,7 @@ """ return cmd.replace('-', '_') + def usage(): print(""" Usage: @@ -50,6 +52,7 @@ Use '--list-cmds' to list all available commands. """) + def version(prog): try: from gbp.version import gbp_version @@ -64,7 +67,7 @@ """ modulename = sanitize(cmd) if (not re.match(r'[a-z][a-z0-9_]', modulename) or - modulename in invalid_modules): + modulename in invalid_modules): raise ImportError('Illegal module name %s' % modulename) return __import__('gbp.scripts.%s' % modulename, fromlist='main', level=0) @@ -75,7 +78,7 @@ >>> pymod_to_cmd('/x/y/z/a_cmd.py') 'a-cmd' """ - return os.path.basename(mod.rsplit('.', 1)[0]).replace('_','-') + return os.path.basename(mod.rsplit('.', 1)[0]).replace('_', '-') def get_available_commands(path): @@ -125,10 +128,10 @@ elif cmd == 'help': usage() return 0 - elif cmd in [ '--version', 'version' ]: + elif cmd in ['--version', 'version']: version(argv[0]) return 0 - elif cmd in [ '--list-cmds', 'list-cmds' ]: + elif cmd in ['--list-cmds', 'list-cmds']: list_available_commands() return 0 @@ -143,6 +146,7 @@ return module.main(args) + if __name__ == '__main__': sys.exit(supercommand()) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/tmpfile.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/tmpfile.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/tmpfile.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/tmpfile.py 2017-02-11 19:33:12.000000000 +0000 @@ -26,6 +26,7 @@ _old_tempdirs = [] + def init_tmpdir(path, prefix): """Initialize a temporary directory structure""" try: @@ -42,6 +43,7 @@ tempfile.tempdir = tmpdir return tmpdir + def del_tmpdir(): """Remove tempdir and restore tempfile module""" if _old_tempdirs: @@ -51,4 +53,3 @@ tempfile.tempdir = _old_tempdirs.pop() # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp/tristate.py git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/tristate.py --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp/tristate.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp/tristate.py 2017-02-11 19:33:12.000000000 +0000 @@ -19,27 +19,28 @@ A switch with three states: on|off|auto """ + class Tristate(object): """Tri-state value: on, off or auto """ - ON = True # state is on == do it + ON = True # state is on == do it OFF = False # state is off == don't do it AUTO = -1 # autodetect == do if possible # We accept true as alias for on and false as alias for off - _VALID_NAMES = [ 'on', 'off', 'true', 'false', 'auto' ] + _VALID_NAMES = ['on', 'off', 'true', 'false', 'auto'] def __init__(self, val): - if type(val) in [ type(t) for t in (True, 1) ]: + if type(val) in [type(t) for t in (True, 1)]: if val > 0: self._state = self.ON elif val < 0: self._state = self.AUTO else: self._state = self.OFF - elif type(val) in [ type(t) for t in ("", u"") ]: - if val.lower() in [ 'on', 'true' ]: + elif type(val) in [type(t) for t in ("", u"")]: + if val.lower() in ['on', 'true']: self._state = self.ON - elif val.lower() in [ 'auto' ]: + elif val.lower() in ['auto']: self._state = self.AUTO else: self._state = self.OFF diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp.conf git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.conf --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp.conf 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.conf 2017-02-11 19:33:12.000000000 +0000 @@ -47,7 +47,7 @@ #notify = off # Transparently handle submodules # submodules = True -# Wheter to use cowbuilder via git-pbuilder(1) +# Whether to use cowbuilder via git-pbuilder(1) #pbuilder = True # Which distribution to use with git-pbuilder #dist = testing diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/dependency_links.txt git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/dependency_links.txt --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/dependency_links.txt 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/dependency_links.txt 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1 @@ + diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/entry_points.txt git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/entry_points.txt --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/entry_points.txt 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/entry_points.txt 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,3 @@ +[console_scripts] +gbp = gbp.scripts.supercommand:supercommand + diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/PKG-INFO git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/PKG-INFO --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/PKG-INFO 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/PKG-INFO 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,40 @@ +Metadata-Version: 1.1 +Name: gbp +Version: 0.8.12.1 +Summary: Suite to help with Debian packages in Git repositories +Home-page: https://honk.sigxcpu.org/piki/projects/git-buildpackage/ +Author: Guido Günther +Author-email: agx@sigxcpu.org +License: GPLv2+ +Description: Git-buildpackage + ---------------- + Tools to ease the development of Debian and (partially) RPM packages in git + repositories. For documentation see the manual online at: + + http://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.html + + On Debian systems, the documentation can be found in + /usr/share/doc/git-buildpackage/manual-html. + + The API documentation of the gbp module can be found at: + + http://honk.sigxcpu.org/projects/git-buildpackage/apidocs + + The mailing list is at: + + * http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage + * git-buildpackage at lists.sigxcpu.org + + See the HACKING document for details on contributing to gbp development. The + package is also available on Pypi at: + + https://pypi.python.org/pypi/gbp/ + + [![Build Status](https://travis-ci.org/agx/git-buildpackage.svg?branch=master)](https://travis-ci.org/agx/git-buildpackage) + +Platform: UNKNOWN +Classifier: Environment :: Console +Classifier: Programming Language :: Python :: 2 +Classifier: Topic :: Software Development :: Version Control +Classifier: Operating System :: POSIX :: Linux +Requires: six diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/SOURCES.txt git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/SOURCES.txt --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/SOURCES.txt 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/SOURCES.txt 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,259 @@ +.coveragerc +.gitignore +.gitmodules +.travis.yml +HACKING +Makefile +README.md +TODO +gbp.conf +requirements.txt +setup.cfg +setup.py +tox.ini +bin/gbp-builder-mock +bin/git-pbuilder +debian/NEWS +debian/bug-presubj +debian/changelog +debian/compat +debian/control +debian/copyright +debian/doc-base +debian/docs +debian/examples +debian/gbp.completion +debian/gbp.conf +debian/git-buildpackage-rpm.install +debian/git-buildpackage-rpm.manpages +debian/git-buildpackage.bash-completion +debian/git-buildpackage.install +debian/git-buildpackage.manpages +debian/git-buildpackage.postinst +debian/git-buildpackage.postrm +debian/git-buildpackage.preinst +debian/git-buildpackage.zsh-completion +debian/links +debian/manpages +debian/rules +debian/source/format +debian/tests/control +debian/tests/smoke-rpm +docs/Makefile +docs/common.ent +docs/copyright.sgml +docs/local-nosgml2x.dsl +docs/local.dsl +docs/man.gbp-buildpackage-rpm.sgml +docs/man.gbp-buildpackage.sgml +docs/man.gbp-clone.sgml +docs/man.gbp-config.sgml +docs/man.gbp-create-remote-repo.sgml +docs/man.gbp-dch.sgml +docs/man.gbp-import-dsc.sgml +docs/man.gbp-import-dscs.sgml +docs/man.gbp-import-orig.sgml +docs/man.gbp-import-srpm.sgml +docs/man.gbp-pq-rpm.sgml +docs/man.gbp-pq.sgml +docs/man.gbp-pull.sgml +docs/man.gbp-rpm-ch.sgml +docs/man.gbp.conf.sgml +docs/man.gbp.sgml +docs/manual.sgml +docs/chapters/building.sgml +docs/chapters/cfgfile.sgml +docs/chapters/chapters.ent +docs/chapters/import.sgml +docs/chapters/intro.sgml +docs/chapters/patches.sgml +docs/chapters/releases.sgml +docs/chapters/special.sgml +docs/manpages/gbp-buildpackage-rpm.sgml +docs/manpages/gbp-buildpackage.sgml +docs/manpages/gbp-clone.sgml +docs/manpages/gbp-config.sgml +docs/manpages/gbp-create-remote-repo.sgml +docs/manpages/gbp-dch.sgml +docs/manpages/gbp-import-dsc.sgml +docs/manpages/gbp-import-dscs.sgml +docs/manpages/gbp-import-orig.sgml +docs/manpages/gbp-import-srpm.sgml +docs/manpages/gbp-pq-rpm.sgml +docs/manpages/gbp-pq.sgml +docs/manpages/gbp-pull.sgml +docs/manpages/gbp-rpm-ch.sgml +docs/manpages/gbp.conf.sgml +docs/manpages/gbp.sgml +docs/manpages/man.common-options.ent +docs/manpages/man.conffiles.sgml +docs/manpages/man.seealso.sgml +docs/manpages/manpages.ent +examples/README.source +examples/gbp-add-patch +examples/gbp-configure-unpatched-source +examples/gbp-posttag-push +examples/gbp-svn-tag +examples/jenkins-scratchbuilder +examples/wrap_cl.py +examples/zeitgeist-git.py +gbp/__init__.py +gbp/command_wrappers.py +gbp/config.py +gbp/dch.py +gbp/errors.py +gbp/format.py +gbp/log.py +gbp/notifications.py +gbp/patch_series.py +gbp/tmpfile.py +gbp/tristate.py +gbp/version.py +gbp.egg-info/PKG-INFO +gbp.egg-info/SOURCES.txt +gbp.egg-info/dependency_links.txt +gbp.egg-info/entry_points.txt +gbp.egg-info/top_level.txt +gbp/deb/__init__.py +gbp/deb/changelog.py +gbp/deb/control.py +gbp/deb/dscfile.py +gbp/deb/format.py +gbp/deb/git.py +gbp/deb/policy.py +gbp/deb/pristinetar.py +gbp/deb/source.py +gbp/deb/upstreamsource.py +gbp/deb/uscan.py +gbp/git/__init__.py +gbp/git/args.py +gbp/git/commit.py +gbp/git/errors.py +gbp/git/fastimport.py +gbp/git/modifier.py +gbp/git/repository.py +gbp/git/vfs.py +gbp/pkg/__init__.py +gbp/pkg/pristinetar.py +gbp/rpm/__init__.py +gbp/rpm/changelog.py +gbp/rpm/git.py +gbp/rpm/lib_rpm.py +gbp/rpm/linkedlist.py +gbp/rpm/policy.py +gbp/scripts/__init__.py +gbp/scripts/buildpackage.py +gbp/scripts/buildpackage_rpm.py +gbp/scripts/clone.py +gbp/scripts/config.py +gbp/scripts/create_remote_repo.py +gbp/scripts/dch.py +gbp/scripts/import_dsc.py +gbp/scripts/import_dscs.py +gbp/scripts/import_orig.py +gbp/scripts/import_srpm.py +gbp/scripts/pq.py +gbp/scripts/pq_rpm.py +gbp/scripts/pull.py +gbp/scripts/rpm_ch.py +gbp/scripts/supercommand.py +gbp/scripts/common/__init__.py +gbp/scripts/common/buildpackage.py +gbp/scripts/common/hook.py +gbp/scripts/common/import_orig.py +gbp/scripts/common/pq.py +gbp/scripts/common/repo_setup.py +packaging/git-buildpackage.spec +tests/01_test_help.py +tests/02_test_upstream_source_tar_unpack.py +tests/03_test_dch_guess_version.py +tests/04_test_submodules.py +tests/05_test_detection.py +tests/06_test_upstream_source.py +tests/07_test_fastimport.py +tests/08_test_patch.py +tests/09_test_write_tree.py +tests/10_test_get_upstream_tree.py +tests/11_test_dch_main.py +tests/12_test_deb.py +tests/13_test_gbp_pq.py +tests/14_test_gbp_import_dscs.py +tests/15_test_DebianSource.py +tests/16_test_supercommand.py +tests/17_test_dch_guess_documented_commit.py +tests/18_test_Config.py +tests/19_test_gbp_scripts_config.py +tests/20_test_rpm.py +tests/21_test_command_wrappers.py +tests/22_test_gbp_buildpackage.py +tests/23_test_dch_extract_bts_cmds.py +tests/24_test_gbp_import_orig.py +tests/25_test_broken_gbp_conf.py +tests/26_test_dch_extract_thanks.py +tests/27_test_create_remote_repo.py +tests/28_test_gbp_git_repository_commit_dir.py +tests/__init__.py +tests/context.py +tests/test_rpm_changelog.py +tests/08_test_patch_data/patch1.diff +tests/component/__init__.py +tests/component/deb/__init__.py +tests/component/deb/fixtures.py +tests/component/deb/test_buildpackage.py +tests/component/deb/test_clone.py +tests/component/deb/test_import_dsc.py +tests/component/deb/test_import_orig.py +tests/component/deb/test_pq.py +tests/component/deb/test_pull.py +tests/component/rpm/__init__.py +tests/component/rpm/test_buildpackage_rpm.py +tests/component/rpm/test_import_srpm.py +tests/component/rpm/test_pq_rpm.py +tests/component/rpm/test_rpm_ch.py +tests/data/foo.patch +tests/data/gbp_config.conf +tests/data/gbp_create_remote_repo.conf +tests/data/test1.conf +tests/data/rpm/rpmbuild/SOURCES/bar.tar.gz +tests/data/rpm/rpmbuild/SOURCES/foo.txt +tests/data/rpm/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2 +tests/data/rpm/rpmbuild/SOURCES/gbp-test-native-1.0.zip +tests/data/rpm/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz +tests/data/rpm/rpmbuild/SOURCES/my.patch +tests/data/rpm/rpmbuild/SOURCES/my2.patch +tests/data/rpm/rpmbuild/SOURCES/my3.patch +tests/data/rpm/rpmbuild/SPECS/gbp-test-native.spec +tests/data/rpm/rpmbuild/SPECS/gbp-test-native2.spec +tests/data/rpm/rpmbuild/SPECS/gbp-test.spec +tests/data/rpm/rpmbuild/SPECS/gbp-test2.spec +tests/data/rpm/specs/gbp-test-native.spec +tests/data/rpm/specs/gbp-test-native2.spec +tests/data/rpm/specs/gbp-test-quirks.spec +tests/data/rpm/specs/gbp-test-reference.spec +tests/data/rpm/specs/gbp-test-reference2.spec +tests/data/rpm/specs/gbp-test-tags.spec +tests/data/rpm/specs/gbp-test-updates-reference.spec +tests/data/rpm/specs/gbp-test-updates.spec +tests/data/rpm/specs/gbp-test.spec +tests/data/rpm/specs/gbp-test2-reference.spec +tests/data/rpm/specs/gbp-test2-reference2.spec +tests/data/rpm/specs/gbp-test2.spec +tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm +tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm +tests/doctests/__init__.py +tests/doctests/test_Changelog.py +tests/doctests/test_Config.py +tests/doctests/test_Control.py +tests/doctests/test_GitModifier.py +tests/doctests/test_GitRepository.py +tests/doctests/test_GitVfs.py +tests/doctests/test_PristineTar.py +tests/doctests/test_create_remote_repo.py +tests/helpers/run-in-docker +tests/test_PristineTar_data/tesfile1 +tests/test_PristineTar_data/tesfile2 +tests/testutils/__init__.py +tests/testutils/capture.py +tests/testutils/data.py +tests/testutils/debiangittestrepo.py +tests/testutils/gbplogtester.py \ No newline at end of file diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/top_level.txt git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/top_level.txt --- git-buildpackage-0.7.5ubuntu0~ppa1/gbp.egg-info/top_level.txt 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/gbp.egg-info/top_level.txt 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1 @@ +gbp diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/HACKING git-buildpackage-0.8.12.2ubuntu0~ppa1/HACKING --- git-buildpackage-0.7.5ubuntu0~ppa1/HACKING 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/HACKING 2017-02-11 19:33:12.000000000 +0000 @@ -2,7 +2,7 @@ ----------------- The tests are run via - python setup.py nosetests + make To also run the component tests, you need to initialize the git submodules once via: @@ -12,12 +12,19 @@ This will fetch the necessary binary data for the DEB and RPM component tests, and the tests are from now on included within each regular test run. +Some tests reach out to the network. To run these in addition to all +other tests use: + + make all+net + +You can run the tests in a debian/sid docker container by using +tests/helpers/run-in-docker. Building the API Docs --------------------- You can build the API docs using - epydoc -v --config=setup.cfg + make apidocs Contributing Patches @@ -27,3 +34,34 @@ http://bugs.debian.org/src:git-buildpackage + +Layout +------ + + gbp/scripts/*.py - the actual gbp commands (buildpackage, dch, …) + gbp/scripts/common/ - code shared between Debian and RPM commands + gbp/deb/ - Debian package handling (control, dsc, …) + gbp/rpm/ - RPM package handling (spec files, …) + gbp/git/ - Git repository interaction + tests/*.py - unit tests + tests/doctests - doctests that also serve as examples + tests/component/ - component tests that invoke actual commands + +Interfaces +---------- +A gbp command in gbp/scripts/.py must provide these interfaces: + +When one invokes `gbp ` gbp/scripts/.py is imported by + + gbp/scripts/supercommand.py + +which then invokes it's *main* function with all given command line arguments. +It is expected to return with the exit status that should be passed back to the +shell. + +When one invokes `gbp config ` gbp/scripts/.py is imported by + + gbp/scripts/config.py + +which then invokes it's *build_parser* function with the command name as argument. +It is expected to return a GbpConfigParser with all config files parsed. diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/Makefile git-buildpackage-0.8.12.2ubuntu0~ppa1/Makefile --- git-buildpackage-0.7.5ubuntu0~ppa1/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/Makefile 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,29 @@ +PY_EXAMPLES=$(shell grep -l /usr/bin/python examples/*) +FLAKE_OPTS=$(shell test -w /dev/shm || echo '-j1') +NOSE_FLAGS=--with-xcoverage + +all: syntax-check test + +all+net: + $(MAKE) GBP_NETWORK_TESTS=1 all + +test: + export GIT_AUTHOR_NAME="Gbp Tests"; \ + export GIT_AUTHOR_EMAIL=tests@example.com; \ + export GIT_COMMITTER_NAME=$$GIT_AUTHOR_NAME; \ + export GIT_COMMITTER_EMAIL=$$GIT_AUTHOR_EMAIL; \ + PYTHONPATH=. \ + python setup.py nosetests $(NOSE_FLAGS) + +syntax-check: + flake8 $(FLAKE_OPTS) + flake8 $(FLAKE_OPTS) $(PY_EXAMPLES) + +docs: + make -C docs + +apidocs: + mkdir -p build + epydoc -v --config=setup.cfg + +.PHONY: docs diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/nosetests.xml git-buildpackage-0.8.12.2ubuntu0~ppa1/nosetests.xml --- git-buildpackage-0.7.5ubuntu0~ppa1/nosetests.xml 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/nosetests.xml 2017-02-11 19:33:12.000000000 +0000 @@ -1,29 +1,1141 @@ -..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: gbp-test.spec + deleted: my-bzip2.patch.bz2 + deleted: my-gz.patch.gz + deleted: my2.patch + deleted: my3.patch + +Untracked files: + (use "git add ..." to include in what will be committed) + + 0002-my2.patch + 6450890-to-2def99b.diff + +no changes added to commit (use "git add" and/or "git commit -a") +]]>..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: gbp-test.spec + deleted: my-bzip2.patch.bz2 + deleted: my-gz.patch.gz + deleted: my2.patch + deleted: my3.patch + +Untracked files: + (use "git add ..." to include in what will be committed) + + 0001-my-gz.patch + 0002-my-bzip2.patch + 0003-my2.patch + +no changes added to commit (use "git add" and/or "git commit -a") +On branch master +Changes not staged for commit: + (use "git add/rm ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: gbp-test.spec + deleted: my-bzip2.patch.bz2 + deleted: my-gz.patch.gz + deleted: my2.patch + deleted: my3.patch + +Untracked files: + (use "git add ..." to include in what will be committed) + + 0001-my-gz.patch + 0002-my-bzip2.patch + 0003-my2.patch + +no changes added to commit (use "git add" and/or "git commit -a") +]]>..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: packaging/gbp-test2.spec + deleted: packaging/my2.patch + deleted: packaging/my3.patch + +Untracked files: + (use "git add ..." to include in what will be committed) + + packaging/0001-My-modification.patch + +no changes added to commit (use "git add" and/or "git commit -a") +]]>..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: gbp-test.spec + deleted: my-bzip2.patch.bz2 + deleted: my-gz.patch.gz + deleted: my2.patch + deleted: my3.patch + +Untracked files: + (use "git add ..." to include in what will be committed) + + 0001-my-gz.patch + 0002-my-bzip2.patch + 0003-my2.patch + +no changes added to commit (use "git add" and/or "git commit -a") +]]>..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: gbp-test.spec + deleted: my-bzip2.patch.bz2 + deleted: my-gz.patch.gz + modified: my2.patch + deleted: my3.patch + +Untracked files: + (use "git add ..." to include in what will be committed) + + my-bzip2.patch + my-gz.patch + +no changes added to commit (use "git add" and/or "git commit -a") +]]>..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: gbp-test.spec + deleted: my-bzip2.patch.bz2 + deleted: my-gz.patch.gz + deleted: my2.patch + deleted: my3.patch + +Untracked files: + (use "git add ..." to include in what will be committed) + + 0001-my-gz.patch + 0002-my-bzip2.patch + 0003-my2.patch + +no changes added to commit (use "git add" and/or "git commit -a") +]]>:::', e.g. - 'cyan:34::'. Numerical values and color names are - accepted, empty fields indicate using the default. - - branch options: - branch tracking and layout options - - --all track all branches, not only debian and upstream - --upstream-branch=UPSTREAM_BRANCH - Upstream branch, default is 'upstream' - --debian-branch=DEBIAN_BRANCH - Branch the Debian package is being developed on, - default is 'master' - --pristine-tar Use pristine-tar to create orig tarball, default is - 'True' - --no-pristine-tar negates '--pristine-tar' - --depth=DEPTH git history depth (for creating shallow clones) - --reference=REFERENCE - git reference repository (use local copies where - possible) Usage: gbp doesnotmatter [options] command[.optionname] - display configuration settings Options: @@ -198,7 +1281,11 @@ format is ':::', e.g. 'cyan:34::'. Numerical values and color names are accepted, empty fields indicate using the default. -Usage: gbp doesnotmatter [options] - create a remote repository +Usage: gbp doesnotmatter [options] - create a remote git repository +Actions: + create create the repository. This is the default when no action is + given. + list list available configuration templates for remote repositories Options: --version show program's version number and exit @@ -233,6 +1320,9 @@ --no-pristine-tar negates '--pristine-tar' --track Set up tracking for remote branches, default is 'True' --no-track negates '--track' + --bare wether to create a bare repository on the remote side. + 'Default is 'True'. + --no-bare negates '--bare' Usage: gbp doesnotmatter [options] paths Options: @@ -275,7 +1365,7 @@ -N NEW_VERSION, --new-version=NEW_VERSION use this as base for the new version number -U URGENCY, --urgency=URGENCY - Set urgency level + Set urgency level, default is 'medium' --bpo Increment the Debian release number for an upload to backports, and add a backport upload changelog comment. @@ -350,6 +1440,8 @@ -h, --help show this help message and exit --interactive Run command interactively, default is 'True' --no-interactive negates '--interactive' + --rollback Rollback repository changes when encountering an error + --no-rollback negates '--rollback' -v, --verbose verbose command execution --color=COLOR Whether to use colored output, default is 'auto' --color-scheme=COLOR_SCHEME @@ -359,7 +1451,7 @@ accepted, empty fields indicate using the default. --no-dch deprecated - don't use. --uscan use uscan(1) to download the new tarball. - --download Download from URL via http(s). + --download Ignored. Accepted for compatibility. import options: pristine-tar and filtering @@ -376,11 +1468,13 @@ negates '--filter-pristine-tar' --import-msg=IMPORT_MSG Format string for commit message used to commit the - upstream tarball, default is 'Imported Upstream - version %(version)s' + upstream tarball, default is 'New upstream version + %(version)s' --symlink-orig Whether to creat a symlink from the upstream tarball to the orig.tar.gz if needed, default is 'True' --no-symlink-orig negates '--symlink-orig' + --component=COMPONENT + component name for additional tarballs version and branch naming options: version number and branch layout options @@ -417,7 +1511,7 @@ --postimport=POSTIMPORT hook run after a successful import, default is '' -Usage: gbp doesnotmatter [options] /path/to/package.dsc +Usage: gbp doesnotmatter [options] /path/to/package.dsc [target] Options: --version show program's version number and exit @@ -429,7 +1523,15 @@ format is ':::', e.g. 'cyan:34::'. Numerical values and color names are accepted, empty fields indicate using the default. - --download download source package + --repo-user=REPO_USER + Set repo username from the DEBFULLNAME and DEBEMAIL + environment variables ('DEBIAN') or fallback to the + git configuration ('GIT'), default is 'DEBIAN' + --repo-email=REPO_EMAIL + Set repo email from the DEBFULLNAME and DEBEMAIL + environment variables ('DEBIAN') or fallback to the + git configuration ('GIT'), default is 'DEBIAN' + --download Ignored. Accepted for compatibility. import options: pristine-tar and filtering @@ -485,7 +1587,7 @@ Format string for upstream tags, default is 'upstream/%(version)s' --skip-debian-tag Don't add a tag after importing the Debian patch -Usage: gbp doesnotmatter [options] - safely update a repository from remote +Usage: gbp doesnotmatter [options] [repo] - safely update a repository from remote Options: --version show program's version number and exit @@ -565,7 +1667,154 @@ --meta-closes-bugnum=META_CLOSES_BUGNUM Meta bug number format, default is '(?:bug|issue)?\#?\s?\d+' -]]>:::', e.g. + 'cyan:34::'. Numerical values and color names are + accepted, empty fields indicate using the default. + --git-notify=NOTIFY Whether to send a desktop notification after the + build, default is 'auto' + --git-vendor=VENDOR Distribution vendor name, default is 'Downstream' + --git-native=NATIVE Treat this package as native, default is 'auto' + + tag options: + options related to git tag creation + + --git-tag create a tag after a successful build + --git-tag-only don't build, only tag and run the posttag hook + --git-retag don't fail if the tag already exists + --git-sign-tags Whether to sign tags, default is 'True' + --git-no-sign-tags negates '--git-sign-tags' + --git-keyid=KEYID GPG keyid to sign tags with, default is + '0xB999CDB58C8DDBD2' + --git-packaging-tag=PACKAGING_TAG + Format string for packaging tags, RPM counterpart of + the 'debian-tag' option, default is + 'packaging/%(version)s' + --git-packaging-tag-msg=PACKAGING_TAG_MSG + Format string for packaging tag messages, default is + '%(pkg)s (vendor)s release %(version)s' + --git-upstream-tag=UPSTREAM_TAG + Format string for upstream tags, default is + 'upstream/%(version)s' + + orig tarball options: + options related to the creation of the orig tarball + + --git-upstream-tree=UPSTREAM_TREE + Where to generate the upstream tarball from (tag or + branch), default is 'TAG' + --git-pristine-tar Use pristine-tar to create orig tarball, default is + 'True' + --git-no-pristine-tar + negates '--git-pristine-tar' + --git-pristine-tar-commit + When generating a tarball commit it to the pristine- + tar branch 'False' default is 'False' + --git-no-pristine-tar-commit + negates '--git-pristine-tar-commit' + --git-force-create force creation of upstream source tarball + --git-no-create-orig + don't create upstream source tarball + --git-tarball-dir=TARBALL_DIR + location to look for external tarballs + --git-compression-level=COMP_LEVEL + Compression level, default is '' + + branch options: + branch layout options + + --git-upstream-branch=UPSTREAM_BRANCH + Upstream branch, default is 'upstream' + --git-packaging-branch=PACKAGING_BRANCH + Branch the packaging is being maintained on, rpm + counterpart of the 'debian-branch' option, default is + 'master' + --git-ignore-branch + Build although debian-branch != current branch, + default is 'False' + --git-no-ignore-branch + negates '--git-ignore-branch' + --git-submodules Transparently handle submodules in the upstream tree, + default is 'False' + --git-no-submodules + negates '--git-submodules' + + external command options: + how and when to invoke external commands and hooks + + --git-builder=BUILDER + command to build the package, default is 'rpmbuild' + --git-cleaner=CLEANER + command to clean the working copy, default is + '/bin/true' + --git-prebuild=PREBUILD + command to run before a build, default is '' + --git-postexport=POSTEXPORT + command to run after exporting the source tree, + default is '' + --git-postbuild=POSTBUILD + hook run after a successful build, default is '' + --git-posttag=POSTTAG + hook run after a successful tag operation, default is + '' + --git-mock Invoke mock for building using gbp-builder-mock, + default is 'False' + --git-no-mock negates '--git-mock' + --git-dist=MOCK_DIST + Build for this distribution when using mock. E.g.: + epel-6, default is 'DEP14' + --git-arch=MOCK_ARCH + Build for this architecture when using mock, default + is '' + --git-mock-root=MOCK_ROOT + The mock root (-r) name for building with mock: + -, default is '' + --git-mock-options=MOCK_OPTIONS + Options to pass to mock, default is '' + --git-hooks Enable running all hooks, default is True + --git-no-hooks negates '--git-hooks' + + export build-tree options: + alternative build tree related options + + --git-no-build Don't run builder or the associated hooks + --git-export-dir=EXPORT_DIR + Build topdir, also export the sources under + EXPORT_DIR, default is '../rpmbuild' + --git-export-specdir=EXPORT_SPECDIR + Subdir (under EXPORT_DIR) where package spec file is + exported default is 'SPECS' + --git-export-sourcedir=EXPORT_SOURCEDIR + Subdir (under EXPORT_DIR) where packaging sources + (other than the spec file) are exported, default is + 'SOURCES' + --git-export=TREEISH + export treeish object TREEISH, default is 'HEAD' + --git-packaging-dir=PACKAGING_DIR + Subdir for RPM packaging files, default is '' + --git-spec-file=SPEC_FILE + Spec file to use, causes the packaging-dir option to + be ignored, default is '' +Usage: gbp doesnotmatter [options] /path/to/package.src.rpm [target] Options: --version show program's version number and exit @@ -581,6 +1830,14 @@ created, default is '/var/tmp/gbp/' --vendor=VENDOR Distribution vendor name, default is 'Downstream' --download download source package + --repo-user=REPO_USER + Set repo username from the DEBFULLNAME and DEBEMAIL + environment variables ('DEBIAN') or fallback to the + git configuration ('GIT'), default is 'DEBIAN' + --repo-email=REPO_EMAIL + Set repo email from the DEBFULLNAME and DEBEMAIL + environment variables ('DEBIAN') or fallback to the + git configuration ('GIT'), default is 'DEBIAN' import options: pristine-tar and filtering @@ -632,7 +1889,129 @@ --upstream-tag=UPSTREAM_TAG Format string for upstream tags, default is 'upstream/%(version)s' -]]>:::', e.g. + 'cyan:34::'. Numerical values and color names are + accepted, empty fields indicate using the default. + --tmp-dir=TMP_DIR Base directory under which temporary directories are + created, default is '/var/tmp/gbp/' + --vendor=VENDOR Distribution vendor name, default is 'Downstream' + --git-log=GIT_LOG options to pass to git-log, default is '--no-merges' + --ignore-branch Build although debian-branch != current branch, + default is 'False' + --no-ignore-branch negates '--ignore-branch' + --customizations=CUSTOMIZATION_FILE + Load Python code from CUSTOMIZATION_FILE. At the + moment, the only useful thing the code can do is + define a custom ChangelogEntryFormatter class. + + commit range options: + which commits to add to the changelog + + -s SINCE, --since=SINCE + commit to start from (e.g. HEAD^^^, release/0.1.2) + + changelog entry formatting: + how to format the changelog entries + + --no-release no release, just update the last changelog section + --git-author Use name and email from git-config for the changelog + header, default is 'False' + --no-git-author negates '--git-author' + --full Include the full commit message instead of only the + first line, default is 'False' + --no-full negates '--full' + --id-length=N include N digits of the commit id in the changelog + entry, default is '0' + --ignore-regex=IGNORE_REGEX + Ignore lines in commit message matching regex, default + is '' + --changelog-revision=CHANGELOG_REVISION + Format string for the revision field in the changelog + header. If empty or not defined the default from + packaging policy is used. + --spawn-editor=SPAWN_EDITOR + Whether to spawn an editor after adding the changelog + entry, default is 'always' + --editor-cmd=EDITOR_CMD + Editor command to use + + naming: + branch names, tag formats, directory and file naming + + --packaging-branch=PACKAGING_BRANCH + Branch the packaging is being maintained on, rpm + counterpart of the 'debian-branch' option, default is + 'master' + --packaging-tag=PACKAGING_TAG + Format string for packaging tags, RPM counterpart of + the 'debian-tag' option, default is + 'packaging/%(version)s' + --packaging-dir=PACKAGING_DIR + Subdir for RPM packaging files, default is '' + --changelog-file=CHANGELOG_FILE + Changelog file to be used, default is 'auto' + --spec-file=SPEC_FILE + Spec file to use, causes the packaging-dir option to + be ignored, default is '' +Usage: gbp doesnotmatter [options] action - maintain patches on a patch queue branch +Ations: +export Export the patch queue / devel branch associated to the + current branch into a patch series in and update the spec file +import Create a patch queue / devel branch from spec file + and patches in current dir. +rebase Switch to patch queue / devel branch associated to the current + branch and rebase against upstream. +drop Drop (delete) the patch queue /devel branch associated to + the current branch. +apply Apply a patch +switch Switch to patch-queue branch and vice versa. + +Options: + --version show program's version number and exit + -h, --help show this help message and exit + --patch-numbers Whether to number patch files, default is True + --no-patch-numbers negates '--patch-numbers' + -v, --verbose Verbose command execution + --force In case of import even import if the branch already + exists + --color=COLOR Whether to use colored output, default is 'auto' + --color-scheme=COLOR_SCHEME + Colors to use in output (when color is enabled), + format is ':::', e.g. + 'cyan:34::'. Numerical values and color names are + accepted, empty fields indicate using the default. + --tmp-dir=TMP_DIR Base directory under which temporary directories are + created, default is '/var/tmp/gbp/' + --upstream-tag=UPSTREAM_TAG + Format string for upstream tags, default is + 'upstream/%(version)s' + --spec-file=SPEC_FILE + Spec file to use, causes the packaging-dir option to + be ignored, default is '' + --packaging-dir=PACKAGING_DIR + Subdir for RPM packaging files, default is '' +]]> + Date: Tue Feb 7 07:27:11 2017 +0100 + 1 file changed, 1 insertion(+) + create mode 100644 bar +Current branch patch-queue/master is up to date. +]]> [] @@ -671,7 +2050,7 @@ Use '--list-cmds' to list all available commands. -]]> [] @@ -684,5 +2063,7 @@ Use '--list-cmds' to list all available commands. -]]> \ No newline at end of file +]]> \ No newline at end of file diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/packaging/git-buildpackage.spec git-buildpackage-0.8.12.2ubuntu0~ppa1/packaging/git-buildpackage.spec --- git-buildpackage-0.7.5ubuntu0~ppa1/packaging/git-buildpackage.spec 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/packaging/git-buildpackage.spec 2017-02-11 19:33:12.000000000 +0000 @@ -161,6 +161,8 @@ WITHOUT_NOSETESTS=1 %{__python} ./setup.py install --root=%{buildroot} --prefix=/usr mkdir -p %{buildroot}/usr/share/%{name} mv %{buildroot}/usr/bin/gbp-builder-mock %{buildroot}/usr/share/%{name}/ +mkdir -p %{buildroot}/%{_sysconfdir}/git-buildpackage/ +mv %{buildroot}/usr/share/%{name}/gbp.conf %{buildroot}/%{_sysconfdir}/git-buildpackage/ %if %{with docs} # Install man pages @@ -249,6 +251,7 @@ %{_mandir}/man1/gbp-buildpackage-rpm.1* %{_mandir}/man1/gbp-pq-rpm.1* %{_mandir}/man1/gbp-import-srpm.1* +%{_mandir}/man1/gbp-rpm-ch.1* %endif diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/README git-buildpackage-0.8.12.2ubuntu0~ppa1/README --- git-buildpackage-0.7.5ubuntu0~ppa1/README 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -Git-buildpackage ----------------- -This is a bunch of scripts to ease the development of Debian packages with git. -For more documentation on how to use these tools, see the manual online at: - - http://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.html - -On Debian systems, this can be found in -/usr/share/doc/git-buildpackage/manual-html. - -The API documentation of the gbp module can be found at: - - http://honk.sigxcpu.org/projects/git-buildpackage/apidocs/ - -The mailing list is at: - - http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage - git-buildpackage at lists.sigxcpu.org - -See the HACKING document for details on contributing to gbp development. diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/README.md git-buildpackage-0.8.12.2ubuntu0~ppa1/README.md --- git-buildpackage-0.7.5ubuntu0~ppa1/README.md 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/README.md 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,25 @@ +Git-buildpackage +---------------- +Tools to ease the development of Debian and (partially) RPM packages in git +repositories. For documentation see the manual online at: + + http://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.html + +On Debian systems, the documentation can be found in +/usr/share/doc/git-buildpackage/manual-html. + +The API documentation of the gbp module can be found at: + + http://honk.sigxcpu.org/projects/git-buildpackage/apidocs + +The mailing list is at: + + * http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage + * git-buildpackage at lists.sigxcpu.org + +See the HACKING document for details on contributing to gbp development. The +package is also available on Pypi at: + + https://pypi.python.org/pypi/gbp/ + +[![Build Status](https://travis-ci.org/agx/git-buildpackage.svg?branch=master)](https://travis-ci.org/agx/git-buildpackage) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/requirements.txt git-buildpackage-0.8.12.2ubuntu0~ppa1/requirements.txt --- git-buildpackage-0.7.5ubuntu0~ppa1/requirements.txt 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/requirements.txt 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,7 @@ -six>=1.9.0 -nose>=0.11.1 coverage>=2.85 +flake8>=3 +mock +nose>=0.11.1 nosexcover>=1.0.7 python-dateutil -mock +six>=1.9.0 diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/setup.cfg git-buildpackage-0.8.12.2ubuntu0~ppa1/setup.cfg --- git-buildpackage-0.7.5ubuntu0~ppa1/setup.cfg 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/setup.cfg 2017-02-11 19:33:12.000000000 +0000 @@ -13,6 +13,8 @@ fail-on = docstring_warning modules = gbp, tests/test_*.py -[pep8] +[flake8] # E501: ignore line length -ignore=E501 +# E265: block comment should start with '# ' +ignore=E501,E265 +builtins=unicode,execfile,raw_input diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/setup.py git-buildpackage-0.8.12.2ubuntu0~ppa1/setup.py --- git-buildpackage-0.7.5ubuntu0~ppa1/setup.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/setup.py 2017-02-11 19:33:12.000000000 +0000 @@ -34,41 +34,48 @@ version = line.split(' ')[1].strip() break except OSError: - pass # Failing is fine, we just can't print the version then + pass # Failing is fine, we just can't print the version then with open('gbp/version.py', 'w') as f: f.write('"The current gbp version number"\n') - f.write('gbp_version="%s"\n' % version) + f.write('gbp_version = "%s"\n' % version) return version def readme(): - with open('README') as file: + with open('README.md') as file: return file.read() -setup(name = "gbp", - version = fetch_version(), - author = u'Guido Günther', - author_email = 'agx@sigxcpu.org', - url = 'https://honk.sigxcpu.org/piki/projects/git-buildpackage/', - description = 'Suite to help with Debian packages in Git repositories', - license = 'GPLv2+', - long_description = readme(), - classifiers = [ + +def setup_requires(): + if os.getenv('WITHOUT_NOSETESTS'): + return [] + else: + return ['nose>=0.11.1', 'coverage>=2.85', 'nosexcover>=1.0.7'] + + +setup(name="gbp", + version=fetch_version(), + author=u'Guido Günther', + author_email='agx@sigxcpu.org', + url='https://honk.sigxcpu.org/piki/projects/git-buildpackage/', + description='Suite to help with Debian packages in Git repositories', + license='GPLv2+', + long_description=readme(), + classifiers=[ 'Environment :: Console', 'Programming Language :: Python :: 2', - 'Topic :: Software Development :: Version Control :: Git', + 'Topic :: Software Development :: Version Control', 'Operating System :: POSIX :: Linux', ], - scripts = ['bin/git-pbuilder', - 'bin/gbp-builder-mock'], - packages = find_packages(exclude=['tests', 'tests.*']), - data_files = [("/etc/git-buildpackage/", ["gbp.conf"]),], - requires = ["six"], - setup_requires=['nose>=0.11.1', 'coverage>=2.85', 'nosexcover>=1.0.7'] if \ - os.getenv('WITHOUT_NOSETESTS') is None else [], - entry_points = { - 'console_scripts': [ 'gbp = gbp.scripts.supercommand:supercommand' ], + scripts=['bin/git-pbuilder', + 'bin/gbp-builder-mock'], + packages=find_packages(exclude=['tests', 'tests.*']), + data_files=[("share/git-buildpackage/", ["gbp.conf"]), ], + requires=["six"], + setup_requires=setup_requires(), + entry_points={ + 'console_scripts': ['gbp=gbp.scripts.supercommand:supercommand'], }, -) + ) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/01_test_help.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/01_test_help.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/01_test_help.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/01_test_help.py 2017-02-11 19:33:12.000000000 +0000 @@ -2,36 +2,34 @@ """Check if --help works""" -from . import context +from . import context # noqa: F401 -import unittest +from .testutils.data import TestCaseWithData -class TestHelp(unittest.TestCase): + +class TestHelp(TestCaseWithData): """Test help output of gbp commands""" - def testHelp(self): - for script in ['buildpackage', - 'clone', - 'config', - 'create_remote_repo', - 'dch', - 'import_orig', - 'import_dsc', - 'pull', - 'pq']: - module = 'gbp.scripts.%s' % script - m = __import__(module, globals(), locals(), ['main'], 0) - self.assertRaises(SystemExit, - m.main, - ['doesnotmatter', '--help']) - - """Test help output of RPM-specific commands""" - def testHelpRpm(self): - for script in ['import_srpm']: - module = 'gbp.scripts.%s' % script - m = __import__(module, globals(), locals(), ['main'], 0) - self.assertRaises(SystemExit, - m.main, - ['doesnotmatter', '--help']) + deb_cmds = ['buildpackage', + 'config', + 'create_remote_repo', + 'dch', + 'import_orig', + 'import_dsc', + 'pull', + 'pq'] + + rpm_cmds = ['buildpackage_rpm', + 'import_srpm', + 'rpm_ch', + 'pq_rpm'] + + @TestCaseWithData.feed(deb_cmds + rpm_cmds) + def testHelp(self, script): + module = 'gbp.scripts.%s' % script + m = __import__(module, globals(), locals(), ['main'], 0) + self.assertRaises(SystemExit, + m.main, + ['doesnotmatter', '--help']) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/02_test_upstream_source_tar_unpack.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/02_test_upstream_source_tar_unpack.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/02_test_upstream_source_tar_unpack.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/02_test_upstream_source_tar_unpack.py 2017-02-11 19:33:12.000000000 +0000 @@ -12,6 +12,7 @@ import gbp.pkg + class TestUnpack(unittest.TestCase): """Make sure we unpack gzip and bzip2 archives correctly""" archive_prefix = "archive" @@ -26,10 +27,10 @@ assert os.path.exists(target), "%s does not exist" % target def _create_archive(self, comp): - filelist = [ 'README', 'setup.py' ] + filelist = ['README.md', 'setup.py'] name = "%s_0.1.tar.%s" % (self.archive_prefix, comp) - t = tarfile.open(name= name, mode='w:%s' % comp) + t = tarfile.open(name=name, mode='w:%s' % comp) for f in filelist: t.add(os.path.join(self.top, f), os.path.join(self._unpack_dir(comp), f)) @@ -41,7 +42,7 @@ self.top = context.projectdir context.chdir(self.dir) self.archives = {} - for ext in [ "gz", "bz2" ]: + for ext in ["gz", "bz2"]: self.archives[ext] = self._create_archive(ext) def tearDown(self): @@ -50,12 +51,12 @@ def test_upstream_source_type(self): for (comp, archive) in six.iteritems(self.archives): source = gbp.pkg.UpstreamSource(archive[0]) - assert source.is_orig() == True - assert source.is_dir() == False - assert source.unpacked == None + assert source.is_orig() is True + assert source.is_dir() is False + assert source.unpacked is None source.unpack(".") - assert source.is_orig() == True - assert source.is_dir() == False + assert source.is_orig() is True + assert source.is_dir() is False assert type(source.unpacked) == str def test_upstream_source_unpack(self): @@ -71,7 +72,7 @@ self._check_files(archive[1], comp) def test_upstream_source_unpack_filtered(self): - exclude = "README" + exclude = "README.md" for (comp, archive) in six.iteritems(self.archives): source = gbp.pkg.UpstreamSource(archive[0]) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/03_test_dch_guess_version.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/03_test_dch_guess_version.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/03_test_dch_guess_version.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/03_test_dch_guess_version.py 2017-02-11 19:33:12.000000000 +0000 @@ -2,11 +2,12 @@ """Test L{Changelog}'s guess_version_from_upstream""" -from . import context +from . import context # noqa: F401 from . import testutils from gbp.scripts import dch + class TestGuessVersionFromUpstream(testutils.DebianGitTestRepo): """Test guess_version_from_upstream""" @@ -17,7 +18,6 @@ uversion = '1.1' upstream_branch = 'upstream' - self.add_file('doesnot', 'matter') self.repo.create_branch('upstream') tag = self.repo.version_to_tag(tagformat, uversion) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/04_test_submodules.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/04_test_submodules.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/04_test_submodules.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/04_test_submodules.py 2017-02-11 19:33:12.000000000 +0000 @@ -27,6 +27,7 @@ TESTFILE_NAME = "testfile" TESTDIR_NAME = "testdir" + class Submodule(object): """Class representing remote repo for Git submodule""" def __init__(self, name, tmpdir): @@ -53,6 +54,7 @@ """Test module teardown""" context.teardown() + def test_empty_has_submodules(): """Test empty repo for submodules""" ok_(not REPO.has_submodules()) @@ -87,6 +89,7 @@ REPO.add_submodule(SUBMODULES[0].dir) REPO.commit_all(msg='Added submodule %s' % SUBMODULES[0].dir) + def test_has_submodules(): """Check for submodules""" ok_(REPO.has_submodules()) @@ -97,8 +100,8 @@ def test_get_submodules(): """Check for submodules list of (name, hash)""" modules = REPO.get_submodules("master")[0] - eq_(modules[0] , 'test_submodule') - eq_(len(modules[1]) , 40) + eq_(modules[0], 'test_submodule') + eq_(len(modules[1]), 40) def test_dump_tree(): @@ -122,13 +125,14 @@ def test_create_tarballs(): """Create an upstream tarball""" # Tarball with submodules - changelog = { "Source": "test", "Upstream-Version": "0.1" } + changelog = {"Source": "test", "Upstream-Version": "0.1"} ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), "HEAD", "bzip2", - "9", True)) + 9, True)) # Tarball without submodules - changelog = { "Source": "test", "Upstream-Version": "0.2" } + changelog = {"Source": "test", "Upstream-Version": "0.2"} ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), "HEAD", "bzip2", - "9", False)) + 9, False)) + def test_create_zip_archives(): """Create an upstream zip archive""" @@ -139,34 +143,37 @@ ok_('test/test_submodule/testfile' in contents) git_archive_single('HEAD', 'without-submodules.zip', 'test', - '', '', '', 'zip') + '', None, '', 'zip') contents = ls_zip('without-submodules.zip') ok_('test/test_submodule/testfile' not in contents) + def test_check_tarfiles(): """Check the contents of the created tarfile""" # Check tarball with submodules tarobj = tarfile.open(TMPDIR.join("test_0.1.orig.tar.bz2"), 'r:*') files = tarobj.getmembers() - ok_("test-0.1/.gitmodules" in [ f.name for f in files ]) - eq_(len(files) , 10) + ok_("test-0.1/.gitmodules" in [f.name for f in files]) + eq_(len(files), 10) # Check tarball without submodules tarobj = tarfile.open(TMPDIR.join("test_0.2.orig.tar.bz2"), 'r:*') files = tarobj.getmembers() - ok_(("test-0.2/%s" % TESTFILE_NAME) in [ f.name for f in files ]) - eq_(len(files) , 6) + ok_(("test-0.2/%s" % TESTFILE_NAME) in [f.name for f in files]) + eq_(len(files), 6) + def test_add_whitespace_submodule(): """Add a second submodule with name containing whitespace""" REPO.add_submodule(SUBMODULES[1].dir) REPO.commit_all(msg='Added submodule %s' % SUBMODULES[0].dir) + def test_get_more_submodules(): """Check for submodules list of (name, hash)""" module = REPO.get_submodules("master") eq_(len(module), len(SUBMODULE_NAMES)) for module in REPO.get_submodules("master"): - eq_(len(module[1]) , 40) + eq_(len(module[1]), 40) ok_(os.path.basename(module[0]) in SUBMODULE_NAMES) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/05_test_detection.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/05_test_detection.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/05_test_detection.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/05_test_detection.py 2017-02-11 19:33:12.000000000 +0000 @@ -10,6 +10,7 @@ from gbp.deb import (DebianPkgPolicy, orig_file) from gbp.errors import GbpError + class MockGitRepository: def __init__(self, with_branch=False, subject=None): self.with_branch = with_branch @@ -27,6 +28,7 @@ def get_commit_info(self, commit): return {'subject': self.subject} + class TestDetection(unittest.TestCase): def setUp(self): self.tmpdir = context.new_tmpdir(__name__) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/06_test_upstream_source.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/06_test_upstream_source.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/06_test_upstream_source.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/06_test_upstream_source.py 2017-02-11 19:33:12.000000000 +0000 @@ -12,6 +12,7 @@ from gbp.pkg import UpstreamSource + class TestDir(unittest.TestCase): def setUp(self): self.tmpdir = context.new_tmpdir(__name__) @@ -29,6 +30,7 @@ def tearDown(self): context.teardown() + class TestTar(unittest.TestCase): """Test if packing tar archives works""" def _check_tar(self, us, positive=[], negative=[]): @@ -92,4 +94,3 @@ self.assertEqual(source.guess_version(), ('gbp', '0.1')) source.unpack(str(self.tmpdir)) self.assertNotEqual(source.unpacked, None) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/07_test_fastimport.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/07_test_fastimport.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/07_test_fastimport.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/07_test_fastimport.py 2017-02-11 19:33:12.000000000 +0000 @@ -14,21 +14,25 @@ tf_name = 'testfile' tl_name = 'a_testlink' + def setup(): global repo tmpdir = context.new_tmpdir(__name__) repo = gbp.git.GitRepository.create(tmpdir.join('test_repo')) + def teardown(): context.teardown() + def test_init_fastimport(): """Create a fastimport object""" global fastimport fastimport = gbp.git.FastImport(repo) assert fastimport, "Failed to init FastImport" + def test_add_file(): """Add a file via fastimport""" author = repo.get_author_info() @@ -39,15 +43,18 @@ open(testfile), os.path.getsize(testfile)) + def test_add_symlink(): """Add a symbolic link via fastimport""" author = repo.get_author_info() fastimport.start_commit('master', author, "a 2nd commit") fastimport.add_symlink(tl_name, tf_name) + def test_close(): fastimport.close() + def test_result(): repo.force_head('master', hard=True) @@ -57,4 +64,3 @@ assert os.path.exists(testfile), "%s doesn't exist" % testfile assert os.path.lexists(testlink), "%s doesn't exist" % testlink assert os.readlink(testlink) == tf_name - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/08_test_patch.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/08_test_patch.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/08_test_patch.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/08_test_patch.py 2017-02-11 19:33:12.000000000 +0000 @@ -2,7 +2,7 @@ """Test L{Patch} class""" -from . import context +from . import context # noqa: 401 import os import unittest diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/09_test_write_tree.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/09_test_write_tree.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/09_test_write_tree.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/09_test_write_tree.py 2017-02-11 19:33:12.000000000 +0000 @@ -4,7 +4,7 @@ from __future__ import print_function -from . import context +from . import context # noqa: 401 from . import testutils import os @@ -25,8 +25,8 @@ paths.append(path) return paths - def test_write_tree_index_nonexistant(self): - """Write out index file to nonexistant dir""" + def test_write_tree_index_nonexistent(self): + """Write out index file to non-existent dir""" paths = self._write_testtree() self.repo.add_files(paths) self.assertRaises(gbp.git.GitRepositoryError, @@ -62,7 +62,7 @@ self.assertEqual(len(commit), 40) # commit the same tree again using the previous commit as parent self.repo.commit_tree(sha1, "second commit", parents=[commit]) - # commit the same tree again using a non existant parent + # commit the same tree again using a non-existent parent self.assertRaises(gbp.errors.GbpError, self.repo.commit_tree, sha1, diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/10_test_get_upstream_tree.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/10_test_get_upstream_tree.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/10_test_get_upstream_tree.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/10_test_get_upstream_tree.py 2017-02-11 19:33:12.000000000 +0000 @@ -2,12 +2,13 @@ """Test L{buildpackage}'s get_upstream_tree method""" -from . import context +from . import context # noqa: 401 from . import testutils import gbp.errors import gbp.scripts.buildpackage as buildpackage + class MockOptions(object): def __init__(self, upstream_branch=None, @@ -17,6 +18,7 @@ self.upstream_tree = upstream_tree self.upstream_tag = upstream_tag + class TestGetUpstreamTree(testutils.DebianGitTestRepo): def test_valid_upstream_branch(self): """Get upstream tree from a valid upstream branch""" @@ -60,7 +62,7 @@ """Get upstream tree from a valid tag""" self.add_file('foo') self.repo.rev_parse('master') - cp = { 'Upstream-Version': '1.0~rc3' } + cp = {'Upstream-Version': '1.0~rc3'} self.repo.create_tag('upstream/1.0_rc3') options = MockOptions(upstream_tree="TAG", upstream_tag="upstream/%(version)s") @@ -70,7 +72,7 @@ def test_invalid_tag(self): """Getting upstream tree from an invalid tag must fail""" self.add_file('foo') - cp = { 'Upstream-Version': '1.0~rc3' } + cp = {'Upstream-Version': '1.0~rc3'} options = MockOptions(upstream_tree="TAG", upstream_tag="upstream/%(version)s") self.assertRaises(gbp.errors.GbpError, diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/11_test_dch_main.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/11_test_dch_main.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/11_test_dch_main.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/11_test_dch_main.py 2017-02-11 19:33:12.000000000 +0000 @@ -50,7 +50,6 @@ class TestScriptDch(DebianGitTestRepo): """Test git-dch""" - def setUp(self): DebianGitTestRepo.setUp(self) self.add_file("foo", "bar") @@ -69,12 +68,12 @@ self.options = ["--upstream-tag=%s" % self.upstream_tag, "--debian-branch=debian", "--upstream-branch=upstream", "--id-length=0", "--spawn-editor=/bin/true"] self.repo.create_tag(deb_tag, msg=deb_tag_msg, commit="HEAD~1") - + self.repo.set_user_name("gbp test user") + self.repo.set_user_email("gbp@example.com") def tearDown(self): DebianGitTestRepo.tearDown(self) - def run_dch(self, dch_options=None): # Take care to copy the list options = self.options[:] @@ -82,8 +81,8 @@ options.extend(dch_options) ret = dch.main(options) self.assertEqual(ret, 0) - return open("debian/changelog").readlines() - + cl = os.path.join(self.repo.path, 'debian/changelog') + return open(cl).readlines() def test_dch_main_new_upstream_version(self): """Test dch.py like gbp dch script does: new upstream version""" @@ -91,7 +90,6 @@ self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=%s\n" % default_urgency, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_release(self): """Test dch.py like gbp dch script does: new upstream version - release""" options = ["--release"] @@ -99,7 +97,6 @@ self.assertEqual("test-package (1.0-1) %s; urgency=%s\n" % (os_codename, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_auto(self): """Test dch.py like gbp dch script does: new upstream version - guess last commit""" options = ["--auto"] @@ -107,7 +104,6 @@ self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=%s\n" % default_urgency, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_snapshot(self): """Test dch.py like gbp dch script does: new upstream version - snapshot mode""" options = ["--snapshot"] @@ -118,7 +114,6 @@ self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_2_snapshots_auto(self): """Test dch.py like gbp dch script does: new upstream version - two snapshots - auto""" options = ["--snapshot"] @@ -141,7 +136,6 @@ self.assertIn(""" * added debian/control\n""", lines) self.assertIn(""" * added debian/compat\n""", lines) - def test_dch_main_new_upstream_version_with_2_snapshots_commit_auto(self): """Test dch.py like gbp dch script does: new upstream version - two committed snapshots - auto""" options = ["--commit"] @@ -163,12 +157,11 @@ self.assertIsNotNone(re.search(snap_mark + header2.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) self.assertIn(""" * added debian/compat\n""", lines) - # First snapshot entry must have disapear + # First snapshot entry must have disappeared self.assertNotIn(header1.group(0) + "\n", lines) # But its changelog must be included in the new one self.assertIn(""" * TEST-COMMITTED-SNAPSHOT\n""", lines) - def test_dch_main_new_upstream_version_with_auto_release(self): """Test dch.py like gbp dch script does: new upstream version - auto - release""" options = ["--auto", "--release"] @@ -176,10 +169,9 @@ self.assertEqual("test-package (1.0-1) %s; urgency=%s\n" % (os_codename, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_auto_snapshot(self): """Test dch.py like gbp dch script does: new upstream version - auto - snapshot mode""" - options = [ "--auto", "--snapshot" ] + options = ["--auto", "--snapshot"] options.append("--snapshot") lines = self.run_dch(options) header = re.search(snap_header_1, lines[0]) @@ -188,7 +180,6 @@ self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_snapshot_release(self): """Test dch.py like gbp dch script does: new upstream version - snapshot - release""" options = ["--snapshot", "--release"] @@ -196,7 +187,6 @@ self.assertRaises(SystemExit, self.run_dch, options) self.assertTrue("'--snapshot' and '--release' are incompatible options" in c.output()) - def test_dch_main_new_upstream_version_with_distribution(self): """Test dch.py like gbp dch script does: new upstream version - set distribution""" options = ["--distribution=testing", "--force-distribution"] @@ -204,7 +194,6 @@ self.assertEqual("test-package (1.0-1) testing; urgency=%s\n" % default_urgency, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_release_distribution(self): """Test dch.py like gbp dch script does: new upstream version - release - set distribution""" options = ["--release", "--distribution=testing", "--force-distribution"] @@ -212,7 +201,6 @@ self.assertEqual("test-package (1.0-1) testing; urgency=%s\n" % default_urgency, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_snapshot_distribution(self): """Test dch.py like gbp dch script does: new upstream version - snapshot mode - do not set distribution""" options = ["--snapshot", "--distribution=testing"] @@ -223,7 +211,6 @@ self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_2_snapshots_auto_distribution(self): """Test dch.py like gbp dch script does: new upstream version - two snapshots - do not set distribution""" options = ["--snapshot", "--distribution=testing"] @@ -249,7 +236,6 @@ # we do not commit self.assertNotIn(""" * TEST-COMMITTED-SNAPSHOT\n""", lines) - def test_dch_main_new_upstream_version_with_2_snapshots_commit_auto_distribution(self): """Test dch.py like gbp dch script does: new upstream version - two committed snapshots - do not set distribution""" options = ["--commit"] @@ -272,12 +258,11 @@ self.assertIsNotNone(re.search(snap_mark + header2.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) self.assertIn(""" * added debian/compat\n""", lines) - # First snapshot entry must have disapear + # First snapshot entry must have disappeared self.assertNotIn(header1.group(0) + "\n", lines) # But its changelog must be included in the new one self.assertIn(""" * TEST-COMMITTED-SNAPSHOT\n""", lines) - def test_dch_main_new_upstream_version_with_urgency(self): """Test dch.py like gbp dch script does: new upstream version - set urgency""" options = ["--urgency=emergency"] @@ -285,7 +270,6 @@ self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=emergency\n", lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_release_urgency(self): """Test dch.py like gbp dch script does: new upstream version - release - set urgency""" options = ["--release", "--urgency=emergency"] @@ -293,10 +277,9 @@ self.assertEqual("test-package (1.0-1) %s; urgency=emergency\n" % os_codename, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_snapshot_urgency(self): """Test dch.py like gbp dch script does: new upstream version - snapshot mode - set urgency""" - options = ["--snapshot", "--urgency=emergency"] + options = ["--snapshot", "--urgency=emergency"] lines = self.run_dch(options) header = re.search(snap_header_1, lines[0]) self.assertIsNotNone(header) @@ -304,7 +287,6 @@ self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version(self): """Test dch.py like gbp dch script does: increment debian version""" self.repo.delete_tag("debian/0.9-1") @@ -314,7 +296,6 @@ self.assertEqual("test-package (%s) UNRELEASED; urgency=%s\n" % (new_version_0_9, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_release(self): """Test dch.py like gbp dch script does: increment debian version - release""" self.repo.delete_tag("upstream/1.0") @@ -323,7 +304,6 @@ self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_auto(self): """Test dch.py like gbp dch script does: increment debian version - guess last commit""" self.repo.delete_tag("upstream/1.0") @@ -332,7 +312,6 @@ self.assertEqual("test-package (%s) UNRELEASED; urgency=%s\n" % (new_version_0_9, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_snapshot(self): """Test dch.py like gbp dch script does: increment debian version - snapshot mode""" self.repo.delete_tag("upstream/1.0") @@ -344,20 +323,18 @@ self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_auto_release(self): """Test dch.py like gbp dch script does: increment debian version - auto - release""" self.repo.delete_tag("upstream/1.0") - options = ["--auto", "--release"] + options = ["--auto", "--release"] lines = self.run_dch(options) self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_auto_snapshot(self): """Test dch.py like gbp dch script does: increment debian version - auto - snapshot mode""" self.repo.delete_tag("upstream/1.0") - options = ["--auto", "--snapshot"] + options = ["--auto", "--snapshot"] lines = self.run_dch(options) header = re.search(snap_header_0_9, lines[0]) self.assertIsNotNone(header) @@ -365,6 +342,21 @@ self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) + def test_dch_main_unreleased_debian_version_with_snapshot(self): + """Test dch.py like gbp dch script does: snapshot mode with unreleased debian version""" + new_version_1_0 = '1.0-1' + options = ["--commit"] + options.append("--commit-msg=UNRELEASED-version") + lines = self.run_dch() + header = re.search(r"\(%s\) UNRELEASED" % new_version_1_0, lines[0]) + self.assertIsNotNone(header) + options = ["--snapshot", "--auto"] + lines = self.run_dch(options) + header = re.search(snap_header_1, lines[0]) + self.assertIsNotNone(header) + self.assertEqual(header.lastindex, 1) + self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) + self.assertIn(""" * added debian/control\n""", lines) def test_dch_main_closes_default(self): options = ["--meta"] @@ -374,7 +366,6 @@ self.assertIn(""" * test debian closes commit (Closes: #123456)\n""", lines) - def test_dch_main_closes_non_debian_bug_numbers(self): self.add_file("closes", "test file", msg="""test non-debian closes 1\n\nCloses: EX-123""") @@ -399,3 +390,17 @@ lines) self.assertIn(""" * test non-debian closes 2 (Example: EX-5678)\n""", lines) + + def test_dch_main_git_author(self): + options = ["--git-author", '-S', '-a'] + lines = self.run_dch(options) + self.assertIn("-- gbp test user ", lines[9]) + + def test_dch_main_no_git_author(self): + options = ["--no-git-author", '-S', '-a'] + lines = self.run_dch(options) + self.assertNotIn("-- gbp test user", "\n".join(lines)) + + def test_dch_subdir(self): + os.chdir('debian/') + self.run_dch() diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/12_test_deb.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/12_test_deb.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/12_test_deb.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/12_test_deb.py 2017-02-11 19:33:12.000000000 +0000 @@ -2,16 +2,19 @@ """Test L{gbp.deb}""" -from . import context +from . import context # noqa: 401 -import os, tempfile, unittest +import os +import tempfile +import unittest import gbp.deb from gbp.deb.dscfile import DscFile from gbp.command_wrappers import CommandExecFailed -class TestDscFile(unittest.TestCase): + +class Test30DscFile(unittest.TestCase): """Test L{gbp.deb.DscFile}""" content = """Format: 3.0 (quilt) @@ -28,24 +31,24 @@ Vcs-Git: git://git.debian.org/git/pkg-libvirt/libvirt.git Build-Depends: cdbs (>= 0.4.90~), debhelper (>= 7), libxml2-dev, libncurses5-dev, libreadline-dev, zlib1g-dev, libgcrypt11-dev, libgnutls-dev, python-all-dev (>= 2.6.6-3~), libavahi-client-dev, libsasl2-dev, libxen-dev [i386 amd64], lvm2 [linux-any], open-iscsi [linux-any], libparted0-dev (>= 2.2), parted (>= 2.2), libdevmapper-dev [linux-any], uuid-dev, libudev-dev [linux-any], libhal-dev [!linux-any], libpciaccess-dev, module-init-tools [linux-any], policykit-1, libcap-ng-dev [linux-any], libnl-dev [linux-any], libyajl-dev, libpcap0.8-dev, libnuma-dev [amd64 i386 ia64 mips mipsel powerpc], radvd [linux-any], libnetcf-dev [linux-any], dwarves, libxml2-utils, dnsmasq-base, openssh-client, netcat-openbsd Build-Conflicts: dpkg-dev (= 1.15.3) -Package-List: +Package-List: libvirt-bin deb admin optional libvirt-dev deb libdevel optional libvirt-doc deb doc optional libvirt0 deb libs optional libvirt0-dbg deb debug extra python-libvirt deb python optional -Checksums-Sha1: +Checksums-Sha1: 3743dc4f3e58d5912a98f568c3e854d97d81f216 20054618 libvirt_0.9.12.orig.tar.gz 3743dc4f3e58d5912a98f568c3e854d97d81f123 20054618 libvirt_0.9.12.orig-foo.tar.gz 3743dc4f3e58d5912a98f568c3e854d97d81f123 20054618 libvirt_0.9.12.orig-bar.tar.gz a7ffa64c18a5ee448c98b1dc894a0a27e1670357 35935 libvirt_0.9.12-4.debian.tar.gz -Checksums-Sha256: +Checksums-Sha256: 298ffc7f2a6d6e78aae46f11a0980f4bc17fa2928f5de6cd9e8abaf5990336e7 20054618 libvirt_0.9.12.orig.tar.gz 298ffc7f2a6d6e78aae46f11a0980f4bc17fa2928f5de6cd9e8abaf599033123 20054618 libvirt_0.9.12.orig-foo.tar.gz 298ffc7f2a6d6e78aae46f11a0980f4bc17fa2928f5de6cd9e8abaf599033123 20054618 libvirt_0.9.12.orig-bar.tar.gz e75110c493995ba5366e751f20f3842f30674c3918357fa6eb83175d0afbec31 35935 libvirt_0.9.12-4.debian.tar.gz -Files: +Files: 5e842bc55733ceba60c64767580ff3e4 20054618 libvirt_0.9.12.orig.tar.gz 5e842bc55733ceba60c64767580ff123 20054618 libvirt_0.9.12.orig-foo.tar.gz 5e842bc55733ceba60c64767580ff123 20054618 libvirt_0.9.12.orig-bar.tar.gz @@ -72,6 +75,49 @@ 'libvirt_0.9.12.orig-%s.tar.gz' % s) +class Test10DscNonNativeFile(unittest.TestCase): + """Test L{gbp.deb.DscFile}""" + + content = """Format: 1.0 +Source: latencytop +Binary: latencytop +Architecture: any +Version: 0.5 +Maintainer: Giacomo Catenazzi +Homepage: http://www.latencytop.org/ +Standards-Version: 3.8.2 +Build-Depends: cdbs, debhelper (>= 5), pkg-config, libncursesw5-dev, libglib2.0-dev, libgtk2.0-dev +Package-List: + latencytop deb utils extra arch=any +Checksums-Sha1: + cfd8a83fa40e630cf680d96a186ff4fdbf6f22c8 25374 latencytop_0.5.orig.tar.gz + 1fa907254c61c73679fd173c828327e9a2273c31 1978 latencytop_0.5.diff.gz +Checksums-Sha256: + 9e7f72fbea7bd918e71212a1eabaad8488d2c602205d2e3c95d62cd57e9203ef 25374 latencytop_0.5.orig.tar.gz + 66342c4d55ae31e529bdcdf88d41a7d114b355f438b0d10efb107f3aef1a0db6 1978 latencytop_0.5.diff.gz +Files: + 73bb3371c6ee0b0e68e25289027e865c 25374 latencytop_0.5.orig.tar.gz + bf7afb3e0d68b0e33e5abf4f1542af71 1978 latencytop_0.5.diff.gz +""" + + def setUp(self): + with tempfile.NamedTemporaryFile(delete=False) as self.dscfile: + self.dscfile.write(self.content) + + def tearDown(self): + os.unlink(self.dscfile.name) + + def test_dscfile_parse(self): + """Test parsing a a 1.0 non-native dsc file without debian revision""" + dsc = DscFile.parse(self.dscfile.name) + self.assertEqual(dsc.version, '0.5') + self.assertEqual(dsc.native, False) + self.assertEqual(os.path.basename(dsc.tgz), 'latencytop_0.5.orig.tar.gz') + self.assertEqual(os.path.basename(dsc.deb_tgz), '') + self.assertEqual(os.path.basename(dsc.diff), 'latencytop_0.5.diff.gz') + self.assertEqual(dsc.additional_tarballs, {}), + + @unittest.skipIf(not os.path.exists('/usr/bin/dpkg'), 'Dpkg not found') class TestDpkgCompareVersions(unittest.TestCase): """Test L{gbp.deb.DpkgCompareVersions}""" @@ -93,4 +139,3 @@ def testBadVersion(self): self.assertRaises(CommandExecFailed, self.cmp, '_', '_ _') - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/13_test_gbp_pq.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/13_test_gbp_pq.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/13_test_gbp_pq.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/13_test_gbp_pq.py 2017-02-11 19:33:12.000000000 +0000 @@ -21,7 +21,9 @@ import os import unittest -from gbp.scripts.pq import generate_patches, export_patches +from gbp.command_wrappers import GitCommand +from gbp.scripts.pq import (generate_patches, export_patches, + import_quilt_patches, rebase_pq, SERIES_FILE) import gbp.scripts.common.pq as pq import gbp.patch_series @@ -117,7 +119,7 @@ self.assertEqual(len(changes), len(expected_patches)) d = context.new_tmpdir(__name__) - expected_paths = [os.path.join(str(d), n) for n in expected_patches ] + expected_paths = [os.path.join(str(d), n) for n in expected_patches] # Commit changes for c in changes: @@ -148,14 +150,14 @@ renumber = False patch_num_format = '%04d-' - expected_patches = [ 'gbptest/added-foo.patch', - 'gbptest/patchname.diff' ] + expected_patches = ['gbptest/added-foo.patch', + 'gbptest/patchname.diff'] - changes = [ ('foo', 'foo', ("added foo\n\n" - "Gbp-Pq: Topic gbptest")), - ('baz', 'baz', ("added bar\n\n" - "Gbp-Pq: Topic gbptest\n" - "Gbp-Pq: Name patchname.diff")) ] + changes = [('foo', 'foo', ("added foo\n\n" + "Gbp-Pq: Topic gbptest")), + ('baz', 'baz', ("added bar\n\n" + "Gbp-Pq: Topic gbptest\n" + "Gbp-Pq: Name patchname.diff"))] self._test_generate_patches(changes, expected_patches, opts) @@ -167,14 +169,14 @@ renumber = True patch_num_format = '%02d_' - expected_patches = [ 'gbptest/01_added-foo.patch', - 'gbptest/02_patchname.diff' ] + expected_patches = ['gbptest/01_added-foo.patch', + 'gbptest/02_patchname.diff'] - changes = [ ('foo', 'foo', ("added foo\n\n" - "Gbp-Pq: Topic gbptest")), - ('baz', 'baz', ("added bar\n\n" - "Gbp-Pq: Topic gbptest\n" - "Gbp-Pq: Name 099-patchname.diff")) ] + changes = [('foo', 'foo', ("added foo\n\n" + "Gbp-Pq: Topic gbptest")), + ('baz', 'baz', ("added bar\n\n" + "Gbp-Pq: Topic gbptest\n" + "Gbp-Pq: Name 099-patchname.diff"))] self._test_generate_patches(changes, expected_patches, opts) @@ -186,30 +188,35 @@ renumber = True patch_num_format = '%02d_' - expected_patches = [ 'gbptest/added-foo.patch', - 'gbptest/patchname.diff', - 'gbptest/patchname-1.diff', - 'gbptest/patchname-2.diff' ] - - changes = [ ('foo', 'foo', ("added foo\n\n" - "Gbp-Pq: Topic gbptest")), - ('baz', 'baz', ("added bar\n\n" - "Gbp-Pq: Topic gbptest\n" - "Gbp-Pq: Name 099-patchname.diff")), - ('qux', 'qux', ("added qux\n\n" - "Gbp-Pq: Topic gbptest\n" - "Gbp-Pq: Name 100-patchname.diff")), - ('norf', 'norf', ("added norf\n\n" - "Gbp-Pq: Topic gbptest\n" - "Gbp-Pq: Name 101-patchname.diff")) ] + expected_patches = ['gbptest/added-foo.patch', + 'gbptest/patchname.diff', + 'gbptest/patchname-1.diff', + 'gbptest/patchname-2.diff'] + + changes = [('foo', 'foo', ("added foo\n\n" + "Gbp-Pq: Topic gbptest")), + ('baz', 'baz', ("added bar\n\n" + "Gbp-Pq: Topic gbptest\n" + "Gbp-Pq: Name 099-patchname.diff")), + ('qux', 'qux', ("added qux\n\n" + "Gbp-Pq: Topic gbptest\n" + "Gbp-Pq: Name 100-patchname.diff")), + ('norf', 'norf', ("added norf\n\n" + "Gbp-Pq: Topic gbptest\n" + "Gbp-Pq: Name 101-patchname.diff"))] self._test_generate_patches(changes, expected_patches, opts) class TestExport(testutils.DebianGitTestRepo): class Options(object): - drop = True + drop = False patch_numbers = False + renumber = False + patch_num_format = '' + meta_closes = False + meta_closes_bugnum = '' + pq_from = 'DEBIAN' def setUp(self): testutils.DebianGitTestRepo.setUp(self) @@ -220,12 +227,36 @@ repo = self.repo start = repo.get_branch() pq_branch = os.path.join('patch-queue', start) + opts = TestExport.Options() + opts.drop = True + pq.switch_pq(repo, start) self.assertEqual(repo.get_branch(), pq_branch) - export_patches(repo, pq_branch, TestExport.Options) + export_patches(repo, pq_branch, opts) self.assertEqual(repo.get_branch(), start) self.assertFalse(repo.has_branch(pq_branch)) + def test_commit(self): + """Test if we commit the patch-queue branch with --commit""" + repo = self.repo + start = repo.get_branch() + pq_branch = os.path.join('patch-queue', start) + opts = TestExport.Options() + opts.commit = True + pq.switch_pq(repo, start) + self.assertEqual(len(repo.get_commits()), 1) + self.assertEqual(repo.get_branch(), pq_branch) + self.add_file('foo', 'foo') + export_patches(repo, pq_branch, opts) + self.assertEqual(repo.get_branch(), start) + self.assertTrue(repo.has_branch(pq_branch)) + self.assertEqual(len(repo.get_commits()), 2, + "Export did not create commit") + export_patches(repo, pq_branch, opts) + self.assertEqual(repo.get_branch(), start) + self.assertEqual(len(repo.get_commits()), 2, + "Export must not create another commit") + class TestParseGbpCommand(unittest.TestCase): def test_empty_body(self): @@ -252,5 +283,121 @@ self.assertEquals(body, 'Foo') +class TestFromTAG(testutils.DebianGitTestRepo): + """Test L{gbp.pq}'s pq-from=TAG""" + + class Options(object): + commit = True + drop = False + force = False + meta_closes = 'Closes|LP' + meta_closes_bugnum = r'(?:bug|issue)?\#?\s?\d+' + patch_num_format = '%04d-' + patch_numbers = False + pq_from = 'TAG' + renumber = False + upstream_tag = 'upstream/%(version)s' + + def git_create_empty_branch(self, branch): + GitCommand('checkout', cwd=self.repo.path)(['-q', '--orphan', branch]) + GitCommand('rm', cwd=self.repo.path)(['-rf', '.']) + + def setUp(self): + testutils.DebianGitTestRepo.setUp(self) + self.add_file('debian/control') + self.add_file( + 'debian/changelog', + 'foo (0.0.1-1) UNRELEASED; urgency=medium\n' + '\n' + ' * Initial foo\n' + '\n' + ' -- Mr. T. S. ' + 'Thu, 01 Jan 1970 00:00:00 +0000\n' + ) + self.git_create_empty_branch('bar') + self.add_file('foo', 'foo') + self.repo.create_tag('upstream/0.0.1') + self.repo.set_branch('master') + + def test_empty(self): + + import_quilt_patches(self.repo, + branch=self.repo.get_branch(), + series=SERIES_FILE, + tries=1, + force=TestFromTAG.Options.force, + pq_from=TestFromTAG.Options.pq_from, + upstream_tag=TestFromTAG.Options.upstream_tag) + diff = self.repo.diff(self.repo.get_branch(), 'upstream/0.0.1') + self.assertEqual('', diff) + diff = self.repo.diff(self.repo.get_branch(), 'master') + self.assertNotEqual('', diff) + + rebase_pq(self.repo, + branch=self.repo.get_branch(), + pq_from=TestFromTAG.Options.pq_from, + upstream_tag=TestFromTAG.Options.upstream_tag) + diff = self.repo.diff(self.repo.get_branch(), 'upstream/0.0.1') + self.assertEqual('', diff) + diff = self.repo.diff(self.repo.get_branch(), 'master') + self.assertNotEqual('', diff) + + export_patches(self.repo, + branch=self.repo.get_branch(), + options=TestFromTAG.Options()) + diff = self.repo.diff(self.repo.get_branch(), self.repo.head) + self.assertEqual('', diff) + + def test_adding_patch(self): + import_quilt_patches(self.repo, + branch=self.repo.get_branch(), + series=SERIES_FILE, + tries=1, + force=TestFromTAG.Options.force, + pq_from=TestFromTAG.Options.pq_from, + upstream_tag=TestFromTAG.Options.upstream_tag) + self.add_file('bar', 'bar', 'added bar') + export_patches(self.repo, + branch=self.repo.get_branch(), + options=TestFromTAG.Options()) + self.assertTrue(os.path.exists(os.path.join(self.repo.path, + os.path.dirname(SERIES_FILE), + 'added-bar.patch'))) + rebase_pq(self.repo, + branch=self.repo.get_branch(), + pq_from=TestFromTAG.Options.pq_from, + upstream_tag=TestFromTAG.Options.upstream_tag) + export_patches(self.repo, + branch=self.repo.get_branch(), + options=TestFromTAG.Options()) + self.assertTrue(os.path.exists(os.path.join(self.repo.path, + os.path.dirname(SERIES_FILE), + 'added-bar.patch'))) + # New upstream release + self.repo.set_branch('bar') + GitCommand('cherry-pick', cwd=self.repo.path)(['patch-queue/master']) + self.repo.create_tag('upstream/0.0.2') + self.repo.set_branch('master') + self.add_file( + 'debian/changelog', + 'foo (0.0.2-1) UNRELEASED; urgency=medium\n' + '\n' + ' * Initial foo\n' + '\n' + ' -- Mr. T. S. ' + 'Thu, 01 Jan 1970 00:00:00 +0000\n' + ) + rebase_pq(self.repo, + branch=self.repo.get_branch(), + pq_from=TestFromTAG.Options.pq_from, + upstream_tag=TestFromTAG.Options.upstream_tag) + export_patches(self.repo, + branch=self.repo.get_branch(), + options=TestFromTAG.Options()) + self.assertFalse(os.path.exists(os.path.join(self.repo.path, + os.path.dirname(SERIES_FILE), + 'added-bar.patch'))) + + def _patch_path(name): return os.path.join(context.projectdir, 'tests/data', name) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/14_test_gbp_import_dscs.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/14_test_gbp_import_dscs.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/14_test_gbp_import_dscs.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/14_test_gbp_import_dscs.py 2017-02-11 19:33:12.000000000 +0000 @@ -23,6 +23,7 @@ from gbp.errors import GbpError + class StubGitImportDsc(object): """ A Stub for GitImportDsc. @@ -40,6 +41,7 @@ """ return 1 if dsc.filename == self.failfile else 0 + class DscStub(object): def __init__(self, filename, version): self.filename = filename @@ -53,10 +55,12 @@ version = filename[4] return cls(filename, version) + # hook up stubs import_dscs.GitImportDsc = StubGitImportDsc import_dscs.DscFile = DscStub + class TestImportDscs(testutils.DebianGitTestRepo): """Test L{gbp.scripts.import_dscs}'s """ @@ -93,4 +97,3 @@ gbp.log.err = self.orig_err testutils.DebianGitTestRepo.tearDown(self) context.teardown() - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/15_test_DebianSource.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/15_test_DebianSource.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/15_test_DebianSource.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/15_test_DebianSource.py 2017-02-11 19:33:12.000000000 +0000 @@ -24,6 +24,7 @@ from gbp.deb.format import DebianSourceFormat from gbp.git.vfs import GitVfs + class TestDebianSource(testutils.DebianGitTestRepo): """Test L{gbp.deb.source}'s """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/16_test_supercommand.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/16_test_supercommand.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/16_test_supercommand.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/16_test_supercommand.py 2017-02-11 19:33:12.000000000 +0000 @@ -15,10 +15,12 @@ # """Test L{gbp} command wrapper""" -import sys import unittest import gbp.scripts.supercommand +from tests.testutils import capture_stdout, capture_stderr + + class TestSuperCommand(unittest.TestCase): def test_import(self): @@ -36,13 +38,19 @@ def test_invalid_command(self): """Test if we fail correctly with an invalid command""" - old_stderr = sys.stderr - with open('/dev/null', 'w') as sys.stderr: + with capture_stderr(): self.assertEqual(gbp.scripts.supercommand.supercommand( ['argv0', 'asdf']), 2) self.assertEqual(gbp.scripts.supercommand.supercommand( ['argv0', 'asdf', '--verbose']), 2) - sys.stderr = old_stderr + + def test_list_commands(self): + """Invoking with --list-cmds must not raise an error""" + with capture_stdout() as out: + self.assertEqual(gbp.scripts.supercommand.supercommand(['argv0', + '--list-cmds']), 0) + for cmd in ['import-orig', 'create-remote-repo', 'pq']: + self.assertIn("%s - " % cmd, out.output()) def test_help_command(self): """Invoking with --help must not raise an error""" @@ -52,4 +60,3 @@ def test_missing_arg(self): self.assertEqual(gbp.scripts.supercommand.supercommand( ['argv0']), 1) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/17_test_dch_guess_documented_commit.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/17_test_dch_guess_documented_commit.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/17_test_dch_guess_documented_commit.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/17_test_dch_guess_documented_commit.py 2017-02-11 19:33:12.000000000 +0000 @@ -2,11 +2,12 @@ """Test L{Changelog}'s guess_version_from_upstream""" -from . import context +from . import context # noqa: 401 from . import testutils from gbp.scripts import dch + class TestGuessDocumentedCommit(testutils.DebianGitTestRepo): def setUp(self): self.version = '1.0-1' @@ -19,7 +20,7 @@ Guess the commit to start from from the snapshot banner """ cp = testutils.MockedChangeLog(self.version, - "*** SNAPSHOT build @12345 ***") + "*** SNAPSHOT build @12345 ***") guessed_commit = dch.guess_documented_commit(cp, None, None) self.assertEqual(guessed_commit, '12345') diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/18_test_Config.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/18_test_Config.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/18_test_Config.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/18_test_Config.py 2017-02-11 19:33:12.000000000 +0000 @@ -109,3 +109,25 @@ self.assertTrue('upstream-branch' in params) self.assertTrue('debian-branch' in params) self.assertTrue('color' in params) + + def test_short_option_with_prefix(self): + """Options with short options can't have a prefix""" + class TestOptonParser(GbpOptionParser): + list_opts = [] + defaults = {'withshort': 'foo'} + short_opts = {'withshort': '-S'} + parser = TestOptonParser('cmd', prefix='p') + with self.assertRaisesRegexp(ValueError, "Options with prefix cannot have a short option"): + parser.add_config_file_option(option_name="withshort", dest="with_short", help="foo") + + def test_short_option(self): + class TestOptionParser(GbpOptionParser): + list_opts = [] + defaults = {'withshort': 'foo'} + short_opts = {'withshort': '-S'} + + parser = TestOptionParser('cmd') + parser.add_config_file_option(option_name="withshort", dest="with_short", help="foo") + self.assertItemsEqual(['withshort'], parser.valid_options) + self.assertTrue(parser.has_option("--withshort")) + self.assertTrue(parser.has_option("-S")) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/19_test_gbp_scripts_config.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/19_test_gbp_scripts_config.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/19_test_gbp_scripts_config.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/19_test_gbp_scripts_config.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,5 +1,5 @@ # vim: set fileencoding=utf-8 : -# (C) 2014 Guido Günther +# (C) 2014,2016 Guido Günther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -40,17 +40,21 @@ def setUp(self): self.conffiles_save = os.environ.get('GBP_CONF_FILES') self.confname = 'tests/data/gbp_config.conf' - self.assertTrue(os.stat(self.confname)) + self.assertTrue(os.path.exists(self.confname)) os.environ['GBP_CONF_FILES'] = self.confname + def tearDown(self): + if self.conffiles_save: + os.environ['GBP_CONF_FILES'] = self.conffiles_save + def test_invocation_single_value(self): """Can invoke it for a sngle value without error""" - ret = gbp.scripts.config.main(['doesnotmatter', 'config.color']) + ret = gbp.scripts.config.main(['argv0', 'config.color']) self.assertEqual(ret, 0) def test_invocation_missing_value(self): """Can we detect a missing value""" - ret = gbp.scripts.config.main(['doesnotmatter', 'config.doesnotexist']) + ret = gbp.scripts.config.main(['argv0', 'config.doesnotexist']) self.assertEqual(ret, 2) def test_print_cmd_single_value_default(self): @@ -70,7 +74,7 @@ self.assertEqual(ret, 0) def test_print_cmd_single_value_override(self): - """Can we fetch a single configuration value that is overriden by config""" + """Can we fetch a single configuration value that is overridden by config""" printstub = self.SingleValuePrintStub() query = 'config.color-scheme' ret = gbp.scripts.config.print_cmd_values(query, printstub) @@ -79,24 +83,28 @@ def test_print_cmd_all_values(self): """Can we fetch the configuration for all commands""" - for cmd in [ 'buildpackage', - 'clone', - 'config', - 'create_remote_repo', - 'dch', - 'import_dsc', - 'import_orig', - 'pq', - 'pull' ]: + for cmd in ['buildpackage', + 'buildpackage_rpm', + 'clone', + 'config', + 'create_remote_repo', + 'dch', + 'import_dsc', + 'import_orig', + 'import_srpm', + 'pq', + 'pq_rpm', + 'pull', + 'rpm_ch']: printstub = self.AllValuesPrintStub(cmd) ret = gbp.scripts.config.print_cmd_values(cmd, printstub) self.assertIn('%s.color' % cmd, printstub.result.keys()) self.assertEquals(printstub.result['%s.color' % cmd], 'auto') self.assertEqual(ret, 0) - def test_unexistent_cmds(self): - """Unexisting commands should print no values""" - for cmd in ["import_dscs", "supercommand"]: + def test_nonexistent_cmds(self): + """Non-existing commands should print no values""" + for cmd in ["import_dscs", "supercommand", "nonexistent"]: printstub = self.AllValuesPrintStub(cmd) ret = gbp.scripts.config.print_cmd_values(cmd, printstub) self.assertEquals(printstub.result, dict()) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/20_test_rpm.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/20_test_rpm.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/20_test_rpm.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/20_test_rpm.py 2017-02-11 19:33:12.000000000 +0000 @@ -20,7 +20,7 @@ import os import shutil import tempfile -from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 +from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 import six @@ -60,6 +60,7 @@ """Test case teardown""" shutil.rmtree(self.tmpdir) + class TestSrcRpmFile(RpmTestBase): """Test L{gbp.rpm.SrcRpmFile}""" @@ -85,7 +86,8 @@ for fn in ['gbp-test-1.0.tar.bz2', 'foo.txt', 'bar.tar.gz', 'my.patch', 'my2.patch', 'my3.patch']: ok_(os.path.exists(os.path.join(self.tmpdir, fn)), - "%s not found" % fn) + "%s not found" % fn) + class TestSpecFile(RpmTestBase): """Test L{gbp.rpm.SpecFile}""" @@ -250,7 +252,7 @@ spec.protected('_delete_special_macro')('invalidmacro', 0) with assert_raises(GbpError): spec.protected('_set_special_macro')('invalidmacro', 0, 'args', - prev) + prev) # Check resulting spec file spec.write_spec_file() @@ -307,7 +309,7 @@ rval = 'my_%s' % name if rval: eq_(val['value'], rval, ("'%s:' is '%s', expecting '%s'" % - (name, val['value'], rval))) + (name, val['value'], rval))) eq_(spec.ignorepatches, []) # Check patch numbers and patch filenames patches = {} @@ -344,15 +346,15 @@ eq_(files, ['05.patch', '01.patch']) # Also ignored patches are returned in the correct order files = [os.path.basename(patch.path) for patch in - spec.patchseries(ignored=True)] + spec.patchseries(ignored=True)] eq_(files, ['05.patch', '02.patch', '01.patch']) # Unapplied patches are added to the end of the series files = [os.path.basename(patch.path) for patch in - spec.patchseries(unapplied=True)] + spec.patchseries(unapplied=True)] eq_(files, ['05.patch', '01.patch', '03.patch']) # Return all patches (for which tag is found) files = [os.path.basename(patch.path) for patch in - spec.patchseries(unapplied=True, ignored=True)] + spec.patchseries(unapplied=True, ignored=True)] eq_(files, ['05.patch', '02.patch', '01.patch', '03.patch', '04.patch']) @@ -371,7 +373,7 @@ guess_spec(SPEC_DIR, recursive=False) # Spec found spec = guess_spec(SPEC_DIR, recursive=False, - preferred_name = 'gbp-test2.spec') + preferred_name='gbp-test2.spec') eq_(spec.specfile, 'gbp-test2.spec') eq_(spec.specdir, SPEC_DIR) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/21_test_command_wrappers.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/21_test_command_wrappers.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/21_test_command_wrappers.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/21_test_command_wrappers.py 2017-02-11 19:33:12.000000000 +0000 @@ -63,6 +63,21 @@ self.assertEqual(self.false.stderr, '') self.assertEqual(self.false.stdout, 'we have a problem') + def test_log_use_err_or_reason_for_error_messge_reason(self): + self.false.run_error = "AFAIK {stderr_or_reason}" + with self.assertRaises(CommandExecFailed): + self.false.__call__() + self.log_tester._check_log(0, "gbp:error: AFAIK execution failed: .Errno 2. No such file or directory") + self.assertEqual(self.false.retcode, 1) + + @patch_popen(stderr='we have a problem', returncode=1) + def test_log_use_err_or_reason_for_error_messge_error(self, create_mock): + self.false.run_error = "Erpel {stderr_or_reason}" + with self.assertRaises(CommandExecFailed): + self.false.__call__() + self.log_tester._check_log(0, "gbp:error: Erpel we have a problem") + self.assertEqual(self.false.retcode, 1) + @patch_popen(returncode=0) def test_no_log_on_success(self, create_mock): self.false.__call__() diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/22_test_gbp_buildpackage.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/22_test_gbp_buildpackage.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/22_test_gbp_buildpackage.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/22_test_gbp_buildpackage.py 2017-02-11 19:33:12.000000000 +0000 @@ -34,6 +34,14 @@ patch.assert_called_once_with() @patch('gbp.deb.get_vendor', return_value='Debian') + def test_get_pbuilder_dist_dep14_debian_master(self, patch): + branch = 'debian/master' + self.repo.create_branch(branch) + self.repo.set_branch(branch) + self.assertEqual(get_pbuilder_dist(self.options, self.repo), '') + patch.assert_called_once_with() + + @patch('gbp.deb.get_vendor', return_value='Debian') def test_get_pbuilder_dist_dep14_debian_suite(self, patch): branch = 'debian/squeeze-lts' self.repo.create_branch(branch) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/23_test_dch_extract_bts_cmds.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/23_test_dch_extract_bts_cmds.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/23_test_dch_extract_bts_cmds.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/23_test_dch_extract_bts_cmds.py 2017-02-11 19:33:12.000000000 +0000 @@ -14,16 +14,17 @@ # """Test gbp.dch.extract_bts_cmds()""" -import os import unittest from gbp.dch import extract_bts_cmds + class OptionsStub: def __init__(self): self.meta_closes = "Closes|LP" self.meta_closes_bugnum = r'(?:bug|issue)?\#?\s?\d+' + class TestExtractBTSCmds(unittest.TestCase): def test_debian_commands(self): """Test default BTS command extraction that is applicable to Debian""" diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/24_test_gbp_import_orig.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/24_test_gbp_import_orig.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/24_test_gbp_import_orig.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/24_test_gbp_import_orig.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,54 @@ +# vim: set fileencoding=utf-8 : +"""Test L{gbp.command_wrappers.Command}'s tarball unpack""" + +import os +import unittest + +from gbp.scripts.import_orig import (ImportOrigDebianGitRepository, GbpError) +from gbp.scripts.common.import_orig import download_orig +from . testutils import DebianGitTestRepo + + +class TestImportOrigGitRepository(DebianGitTestRepo): + + def setUp(self): + DebianGitTestRepo.setUp(self, ImportOrigDebianGitRepository) + + def test_empty_rollback(self): + self.repo.rollback() + self.assertEquals(self.repo.rollback_errors, []) + + def test_rrr_delete_tag(self): + self.repo.rrr('doesnotmatter', 'delete', 'tag') + self.assertEquals(self.repo.rollbacks, [('doesnotmatter', 'tag', 'delete', None)]) + self.repo.rollback() + self.assertEquals(self.repo.rollback_errors, []) + + def test_rrr_delete_branch(self): + self.repo.rrr('doesnotmatter', 'delete', 'branch') + self.assertEquals(self.repo.rollbacks, [('doesnotmatter', 'branch', 'delete', None)]) + self.repo.rollback() + self.assertEquals(self.repo.rollback_errors, []) + + def test_rrr_unknown_action(self): + with self.assertRaisesRegexp(GbpError, "Unknown action unknown for tag doesnotmatter"): + self.repo.rrr('doesnotmatter', 'unknown', 'tag') + + +@unittest.skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled") +class TestImportOrigDownload(DebianGitTestRepo): + HOST = 'git.sigxcpu.org' + + def setUp(self): + DebianGitTestRepo.setUp(self, ImportOrigDebianGitRepository) + os.chdir(self.repodir) + + def test_404_download(self): + with self.assertRaisesRegexp(GbpError, "404 Client Error: Not Found for url"): + download_orig("https://{host}/does_not_exist".format(host=self.HOST)) + + def test_200_download(self): + pkg = 'hello-debhelper_2.6.orig.tar.gz' + url = "https://{host}/cgit/gbp/deb-testdata/tree/dsc-3.0/{pkg}".format(host=self.HOST, + pkg=pkg) + self.assertEqual(download_orig(url).path, '../%s' % pkg) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/25_test_broken_gbp_conf.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/25_test_broken_gbp_conf.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/25_test_broken_gbp_conf.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/25_test_broken_gbp_conf.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,58 @@ +# vim: set fileencoding=utf-8 : + +"""Check if we fail correcdtly on broken gbp.conf""" + +from . import context + +from . testutils.data import TestCaseWithData +from . testutils.gbplogtester import GbpLogTester + +import os +import unittest + + +class TestBrokenConfig(TestCaseWithData, GbpLogTester): + """Test that broken config gives a sensible error for all commands""" + + cmds = ['buildpackage', + 'clone', + 'config', + 'create_remote_repo', + 'dch', + 'import_orig', + 'import_dsc', + 'pull', + 'pq', + 'import_srpm', + 'buildpackage_rpm', + 'pq_rpm', + 'rpm_ch'] + + def __init__(self, methodName='runTest'): + unittest.TestCase.__init__(self, methodName) + GbpLogTester.__init__(self) + + def setUp(self): + tmpdir = str(context.new_tmpdir('bar')) + confname = os.path.join(tmpdir, 'gbp.conf') + with open(confname, 'w') as f: + f.write("this is a broken config\n") + os.environ['GBP_CONF_FILES'] = confname + self._capture_log(True) + + def tearDown(self): + del os.environ['GBP_CONF_FILES'] + + @TestCaseWithData.feed(cmds) + def testBrokenConf(self, cmd): + module = 'gbp.scripts.%s' % cmd + try: + m = __import__(module, globals(), locals(), ['main'], 0) + ret = m.main([cmd, '--help']) + self.assertEquals(ret, 3) + except Exception as e: + self.assertTrue(False, "Caught '%s'" % e) + self._check_log(-1, "See 'man gbp.conf' for the format.") + self._clear_log() + +# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/26_test_dch_extract_thanks.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/26_test_dch_extract_thanks.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/26_test_dch_extract_thanks.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/26_test_dch_extract_thanks.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,40 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2015 Jonathan Toppins +# (C) 2016 Guido Günther +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# +"""Test gbp.dch.extract_thanks_info()""" + +import unittest + +from gbp.dch import extract_thanks_info + + +class OptionsStub: + def __init__(self): + self.meta_closes = "Closes|LP" + self.meta_closes_bugnum = r'(?:bug|issue)?\#?\s?\d+' + + +class TestExtractThanks(unittest.TestCase): + def test_debian_commands(self): + """Test default thanks extraction""" + lines = """ +thAnks: a lot +Thanks: everyone""" + + lines += " \n" # Add some trailing whitespace + bugs, dummy = extract_thanks_info(lines.split('\n'), None) + self.assertEquals(bugs, ['a lot', 'everyone']) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/27_test_create_remote_repo.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/27_test_create_remote_repo.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/27_test_create_remote_repo.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/27_test_create_remote_repo.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,47 @@ +# vim: set fileencoding=utf-8 : +# (C) 2016 Guido Günther +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# +"""Test the L{gbp} create_remote_repo command""" + +import os +import unittest +import gbp.scripts.create_remote_repo as create_remote_repo + + +class TestGbpCreateRemoteRepoCommand(unittest.TestCase): + def setUp(self): + self.conffiles_save = os.environ.get('GBP_CONF_FILES') + + def tearDown(self): + if self.conffiles_save: + os.environ['GBP_CONF_FILES'] = self.conffiles_save + + def test_no_config_templates(self): + self.confname = 'tests/data/gbp_nonexistent.conf' + self.assertFalse(os.path.exists(self.confname)) + os.environ['GBP_CONF_FILES'] = self.confname + + _, _, sections = create_remote_repo.parse_args(['create-remote-repo']) + self.assertEqual(create_remote_repo.get_config_names(sections), + []) + + def test_list_config_templates(self): + self.confname = 'tests/data/gbp_create_remote_repo.conf' + self.assertTrue(os.path.exists(self.confname)) + os.environ['GBP_CONF_FILES'] = self.confname + + _, _, sections = create_remote_repo.parse_args(['create-remote-repo']) + self.assertEqual(create_remote_repo.get_config_names(sections), + ['config1', 'config2']) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/28_test_gbp_git_repository_commit_dir.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/28_test_gbp_git_repository_commit_dir.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/28_test_gbp_git_repository_commit_dir.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/28_test_gbp_git_repository_commit_dir.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,42 @@ +# vim: set fileencoding=utf-8 : + +import os + +from . testutils import DebianGitTestRepo +from gbp.git.repository import GitRepositoryError + + +class TestGitRepositoryCommitDir(DebianGitTestRepo): + def setUp(self): + DebianGitTestRepo.setUp(self) + self.content = os.path.join(str(self.tmpdir), 'new') + os.mkdir(self.content) + with open(os.path.join(self.content, 'file1'), 'w') as f: + f.write('content1') + + def test_simple(self): + self.repo.commit_dir(self.content, + 'new content', + 'master', + create_missing_branch=True) + self.assertEquals(self.repo.show('master:file1'), 'content1') + + def test_long_reflog(self): + """Make sure we fail on onverly long msg resulting in an + overly long reflog enry""" + with self.assertRaises(GitRepositoryError): + self.repo.commit_dir(self.content, + 'foo' * 100000, + 'master', + create_missing_branch=True) + + def test_long_msg_854333(self): + """Make sure we shorten the reflog entry properly""" + self.repo.commit_dir(self.content, + 'foo\n' * 100000, + 'master', + create_missing_branch=True) + self.assertEquals(self.repo.show('master:file1'), 'content1') + out, dummy, ret = self.repo._git_inout('reflog', []) + self.assertEquals(ret, 0) + self.assertIn('HEAD@{0}: gbp: foo\n', out) Binary files /tmp/tmpbS9pBY/xR1LTe4Eqr/git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-1.0/hello-debhelper_2.6-2.diff.gz and /tmp/tmpbS9pBY/QPYyDSFWGx/git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-1.0/hello-debhelper_2.6-2.diff.gz differ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-1.0/hello-debhelper_2.6-2.dsc git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-1.0/hello-debhelper_2.6-2.dsc --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-1.0/hello-debhelper_2.6-2.dsc 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-1.0/hello-debhelper_2.6-2.dsc 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,20 @@ +Format: 1.0 +Source: hello-debhelper +Binary: hello-debhelper +Architecture: any +Version: 2.6-2 +Maintainer: Santiago Vila +Homepage: http://www.gnu.org/software/hello/ +Standards-Version: 3.9.1 +Build-Depends: debhelper (>= 8) +Package-List: + hello-debhelper deb devel extra arch=any +Checksums-Sha1: + d0bcb2df85485a3bc7838b490df951c95a7e69b4 594257 hello-debhelper_2.6.orig.tar.gz + c925344d14a1a4a9448b0e670f338a45e70a60da 14104 hello-debhelper_2.6-2.diff.gz +Checksums-Sha256: + 747aa9c3a0d105ad649af2f8ab95fb3526b280f2c1d04233d87d9ecce794cec0 594257 hello-debhelper_2.6.orig.tar.gz + 7e50c231fa60ffe9d986850fdd645989688ea23a0f9cd74827c2244736d6c78b 14104 hello-debhelper_2.6-2.diff.gz +Files: + 066ba7113eed3554cde6bc34b7b43e9b 594257 hello-debhelper_2.6.orig.tar.gz + 7471f786fca191e79c5520ed8f750384 14104 hello-debhelper_2.6-2.diff.gz Binary files /tmp/tmpbS9pBY/xR1LTe4Eqr/git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-1.0/hello-debhelper_2.6.orig.tar.gz and /tmp/tmpbS9pBY/QPYyDSFWGx/git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-1.0/hello-debhelper_2.6.orig.tar.gz differ Binary files /tmp/tmpbS9pBY/xR1LTe4Eqr/git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.8.orig-foo.tar.gz and /tmp/tmpbS9pBY/QPYyDSFWGx/git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.8.orig-foo.tar.gz differ Binary files /tmp/tmpbS9pBY/xR1LTe4Eqr/git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9-1.debian.tar.gz and /tmp/tmpbS9pBY/QPYyDSFWGx/git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9-1.debian.tar.gz differ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9-1.dsc git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9-1.dsc --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9-1.dsc 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9-1.dsc 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,38 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA256 + +Format: 3.0 (quilt) +Source: hello-debhelper +Binary: hello-debhelper +Architecture: any +Version: 2.8-1 +Maintainer: Santiago Vila +Homepage: http://www.gnu.org/software/hello/ +Standards-Version: 3.9.2 +Build-Depends: debhelper (>= 9.20120311) +Package-List: + hello-debhelper deb devel extra +Checksums-Sha1: + 5a32898ddce0586bb3f4035fc63324a6a515ce38 697483 hello-debhelper_2.9.orig.tar.gz + 272c3ae004959649941c6b0ccd4453d66683b107 697483 hello-debhelper_2.9.orig-foo.tar.gz + 272c3ae004959649941c6b0ccd4453d66683b107 5980 hello-debhelper_2.9-1.debian.tar.gz +Checksums-Sha256: + e6b77f81f7cf7daefad4a9f5b65de6cae9c3f13b8cfbaea8cb53bb5ea5460d73 697483 hello-debhelper_2.9.orig.tar.gz + e6b77f81f7cf7daefad4a9f5b65de6cae9c3f13b8cfbaea8cb53bb5ea5460d73 697483 hello-debhelper_2.9.orig-foo.tar.gz + b6b5722a2e353dc91282b8fc7231b014a1d26678960affa0dcfa74d84236aa0a 5980 hello-debhelper_2.9-1.debian.tar.gz +Files: + 6a67cbbbc0420061ef938a9a2736fbd6 697483 hello-debhelper_2.9.orig.tar.gz + 6a67cbbbc0420061ef938a9a2736fbd6 697483 hello-debhelper_2.9.orig-foo.tar.gz + b2b4b3a45587caa115a27944557ce29d 5980 hello-debhelper_2.9-1.debian.tar.gz + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.12 (GNU/Linux) + +iQEcBAEBCAAGBQJPwpzUAAoJEEHOfwufG4syx1gH/1FiR+Wts28apKS3oSVDBaWL +8Qznm+V+Vb9WVAbWc67dmwZhObYaqDKztaI8qXPSWXDEq0FeldPnQzAmLqmwqeO3 +aEu2VqMwgoCwF0oBFyiedfKqWpv9zUWd1wPsHXCI5tSTBGzNEoZLmu8KPtoMVgaa +04w3tEnkQzYVX/dde7JiOpGk2nkLedVXATxW7Ts3HdF2CMivMsG4Rfc3/k5c+TmJ ++qUiyZm/XUjwzdqO/Ko/F/3qlt0C/J2KTo03oop0B57Nv9jq53/0Dr3OZhIQfYx+ +wnv55jgh80PbPfGiS6ITtveFHQ9E/z/ufDZ6Jh/gVL7h34U+9aY6P8ReIoreYGI= +=Tt6n +-----END PGP SIGNATURE----- Binary files /tmp/tmpbS9pBY/xR1LTe4Eqr/git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9.orig-foo.tar.gz and /tmp/tmpbS9pBY/QPYyDSFWGx/git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9.orig-foo.tar.gz differ Binary files /tmp/tmpbS9pBY/xR1LTe4Eqr/git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9.orig.tar.gz and /tmp/tmpbS9pBY/QPYyDSFWGx/git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/data/dsc-3.0-additional-tarballs/hello-debhelper_2.9.orig.tar.gz differ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/fixtures.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/fixtures.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/fixtures.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/fixtures.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,88 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2017 Guido Guenther +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# + +import os + +from functools import wraps +from tests.component import (ComponentTestBase, + ComponentTestGitRepository) +from tests.component.deb import DEB_TEST_DATA_DIR + +from nose.tools import eq_ + +from gbp.deb.dscfile import DscFile +from gbp.scripts.import_dsc import main as import_dsc + +DEFAULT_NATIVE = os.path.join(DEB_TEST_DATA_DIR, + 'dsc-native', + 'git-buildpackage_%s.dsc' % '0.4.14') + +DEFAULT_QUILT30 = os.path.join(DEB_TEST_DATA_DIR, + 'dsc-3.0', + 'hello-debhelper_%s.dsc' % '2.8-1') + + +class RepoFixtures(object): + @classmethod + def native(cls, dsc=DEFAULT_NATIVE, opts=None): + """Docorator to be used as Debian native test fixture""" + def wrapper(fn): + @wraps(fn) + def _native_repo(*args): + repo = cls.import_native(dsc, opts) + return fn(*args, repo=repo) + return _native_repo + return wrapper + + @classmethod + def quilt30(cls, dsc=DEFAULT_QUILT30, opts=None): + """Decorator to be used as 3.0 (quilt) test fixture""" + def wrapper(fn): + @wraps(fn) + def _quilt30_repo(*args): + repo = cls.import_quilt30(dsc, opts) + return fn(*args, repo=repo) + return _quilt30_repo + return wrapper + + @classmethod + def _import_one(cls, dsc, opts): + opts = opts or [] + assert import_dsc(['arg0'] + opts + [dsc]) == 0 + parsed = DscFile(dsc) + return ComponentTestGitRepository(parsed.pkg) + + @classmethod + def import_native(cls, dsc=DEFAULT_NATIVE, opts=None): + """Import a Debian native package, verify and change into repo""" + repo = cls._import_one(dsc, opts) + ComponentTestBase._check_repo_state(repo, 'master', ['master']) + eq_(len(repo.get_commits()), 1) + os.chdir(repo.path) + return repo + + @classmethod + def import_quilt30(cls, dsc=DEFAULT_QUILT30, opts=None): + """Import a 3.0 (quilt) package, verify and change into repo""" + repo = cls._import_one(dsc, opts) + expected_branches = ['master', 'upstream'] + if opts and '--pristine-tar' in opts: + expected_branches.append('pristine-tar') + ComponentTestBase._check_repo_state(repo, 'master', expected_branches) + eq_(len(repo.get_commits()), 2) + os.chdir(repo.path) + return repo diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/__init__.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -23,10 +23,9 @@ DEB_TEST_SUBMODULE = os.path.join('tests', 'component', 'deb', 'data') DEB_TEST_DATA_DIR = os.path.abspath(DEB_TEST_SUBMODULE) +DEB_TEST_DOWNLOAD_URL = 'https://git.sigxcpu.org/cgit/gbp/deb-testdata/plain/' + def setup(): """Test Module setup""" ComponentTestGitRepository.check_testdata(DEB_TEST_SUBMODULE) - - - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_buildpackage.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_buildpackage.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_buildpackage.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_buildpackage.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2015,2016 Guido Günther +# (C) 2015-2017 Guido Günther # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,11 +16,14 @@ # along with this program; if not, please see # +import hashlib import os +import subprocess from tests.component import (ComponentTestBase, ComponentTestGitRepository) from tests.component.deb import DEB_TEST_DATA_DIR +from tests.component.deb.fixtures import RepoFixtures from nose.tools import ok_, eq_, assert_false, assert_true @@ -31,42 +34,28 @@ class TestBuildpackage(ComponentTestBase): """Test building a debian package""" - def check_hook_vars(self, name, vars): - """ - Check that a hook hat the given vars in - it's environment. - This assumes the hook was set too - printenv > hookname.oug - """ - env = [] - with open('%s.out' % name) as f: - env = [line.split('=')[0] for line in f.readlines()] - - for var in vars: - ok_(var in env, "%s not found in %s" % (var, env)) - @staticmethod def _dsc_name(pkg, version, dir): return os.path.join(DEB_TEST_DATA_DIR, dir, '%s_%s.dsc' % (pkg, version)) - def _test_buildpackage(self, pkg, dir, version): - dsc = self._dsc_name(pkg, version, dir) - assert import_dsc(['arg0', dsc]) == 0 - ComponentTestGitRepository(pkg) - os.chdir(pkg) - ret = buildpackage(['arg0', - '--git-prebuild=printenv > prebuild.out', - '--git-postbuild=printenv > postbuild.out', - '--git-builder=/bin/true', - '--git-cleaner=/bin/true']) + def _test_buildpackage(self, repo, opts=[]): + prebuild_out = os.path.join(repo.path, 'prebuild.out') + postbuild_out = os.path.join(repo.path, 'postbuild.out') + args = ['arg0', + '--git-prebuild=printenv > %s' % prebuild_out, + '--git-postbuild=printenv > %s' % postbuild_out, + '--git-builder=/bin/true', + '--git-cleaner=/bin/true'] + opts + os.chdir(repo.path) + ret = buildpackage(args) ok_(ret == 0, "Building the package failed") - eq_(os.path.exists('prebuild.out'), True) + eq_(os.path.exists(prebuild_out), True) + eq_(os.path.exists(postbuild_out), True) self.check_hook_vars('prebuild', ["GBP_BUILD_DIR", "GBP_GIT_DIR", - "GBP_GIT_DIR", "GBP_BUILD_DIR"]) self.check_hook_vars('postbuild', ["GBP_CHANGES_FILE", @@ -74,25 +63,19 @@ "GBP_CHANGES_FILE", "GBP_BUILD_DIR"]) - def test_debian_buildpackage(self): - """Test that building a native debian package works""" - self._test_buildpackage('git-buildpackage', 'dsc-native', '0.4.14') - - def test_non_native_buildpackage(self): - """Test that building a native debian package works""" - self._test_buildpackage('hello-debhelper', 'dsc-3.0', '2.8-1') + @RepoFixtures.native() + def test_debian_buildpackage(self, repo): + """Test that building a native debian package works""" + self._test_buildpackage(repo) + + @RepoFixtures.quilt30() + def test_non_native_buildpackage(self, repo): + """Test that building a source 3.0 debian package works""" + self._test_buildpackage(repo) - def test_tag_only(self): + @RepoFixtures.native() + def test_tag_only(self, repo): """Test that only tagging a native debian package works""" - def _dsc(version): - return os.path.join(DEB_TEST_DATA_DIR, - 'dsc-native', - 'git-buildpackage_%s.dsc' % version) - - dsc = _dsc('0.4.14') - assert import_dsc(['arg0', dsc]) == 0 - repo = ComponentTestGitRepository('git-buildpackage') - os.chdir('git-buildpackage') repo.delete_tag('debian/0.4.14') # make sure we can tag again ret = buildpackage(['arg0', '--git-tag-only', @@ -102,11 +85,11 @@ ok_(ret == 0, "Building the package failed") eq_(os.path.exists('posttag.out'), True) eq_(os.path.exists('builder-run.stamp'), False) - self.check_hook_vars('posttag', ["GBP_TAG", - "GBP_BRANCH", + self.check_hook_vars('posttag', [("GBP_TAG", "debian/0.4.14"), + ("GBP_BRANCH", "master"), "GBP_SHA1"]) - def test_subtarball_generation(self): + def test_component_generation(self): """Test that generating tarball and additional tarball works without pristine-tar""" pkg = 'hello-debhelper' dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs') @@ -120,7 +103,7 @@ for t in tarballs: self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t) ret = buildpackage(['arg0', - '--git-subtarball=foo', + '--git-component=foo', '--git-no-pristine-tar', '--git-posttag=printenv > posttag.out', '--git-builder=touch builder-run.stamp', @@ -129,7 +112,7 @@ for t in tarballs: self.assertTrue(os.path.exists(t), "Tarball %s not found" % t) - def test_pristinetar_subtarball_generation(self): + def test_pristinetar_component_generation(self): """Test that generating tarball and additional tarball works with pristine-tar""" pkg = 'hello-debhelper' dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs') @@ -142,8 +125,10 @@ assert_true(repo.has_branch('pristine-tar'), "Pristine-tar branch must exist") for t in tarballs: self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t) + # Make sure the tree object for importing the main tarball is recreated + repo.collect_garbage(prune='all', aggressive=True) ret = buildpackage(['arg0', - '--git-subtarball=foo', + '--git-component=foo', '--git-pristine-tar', '--git-posttag=printenv > posttag.out', '--git-builder=touch builder-run.stamp', @@ -151,3 +136,47 @@ ok_(ret == 0, "Building the package failed") for t in tarballs: self.assertTrue(os.path.exists(t), "Tarball %s not found" % t) + + @RepoFixtures.quilt30() + def test_export_dir_buildpackage(self, repo): + """Test that building with a export dir works""" + self._test_buildpackage(repo, ['--git-export-dir=../foo/bar']) + ok_(os.path.exists('../foo/bar')) + + @RepoFixtures.native() + def test_argument_quoting(self, repo): + """Test that we quote arguments to builder (#)""" + with open('../arg with spaces', 'w'): + pass + # We use ls as builder to look for a file with spaces. This + # will fail if build arguments are not properly quoted and + # therefore split up + ret = buildpackage(['arg0', + '--git-builder=ls', + '--git-cleaner=/bin/true', + '../arg with spaces']) + ok_(ret == 0, "Building the package failed") + + @RepoFixtures.quilt30() + def test_tarball_default_compression(self, repo): + """Test that we use defaults for compression if not given (#820846)""" + self._test_buildpackage(repo, ['--git-no-pristine-tar']) + tarball = "../hello-debhelper_2.8.orig.tar.gz" + out = subprocess.check_output(["file", tarball]) + ok_("max compression" not in out) + m1 = hashlib.md5(open(tarball, 'rb').read()).hexdigest() + os.unlink(tarball) + eq_(buildpackage(['arg0', + '--git-ignore-new', + '--git-builder=/bin/true', + '--git-cleaner=/bin/true', + '../arg with spaces']), 0) + m2 = hashlib.md5(open(tarball, 'rb').read()).hexdigest() + eq_(m1, m2, "Regenerated tarball has different checksum") + + @RepoFixtures.quilt30 + def test_tarball_max_compression(self, repo): + """Test that passing max compression works (#820846)""" + self._test_buildpackage(repo, ['--git-no-pristine-tar', '--git-compression-level=9']) + out = subprocess.check_output(["file", "../hello-debhelper_2.8.orig.tar.gz"]) + ok_("max compression" in out) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_clone.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_clone.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_clone.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_clone.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,70 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2016 Guido Günther +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# + +import os + +from tests.component import (ComponentTestBase, + ComponentTestGitRepository) +from tests.component.deb.fixtures import RepoFixtures + +from nose.tools import ok_ + +from gbp.scripts.clone import main as clone + + +class TestClone(ComponentTestBase): + """Test cloning from a remote""" + + @RepoFixtures.native() + def test_clone_nonempty(self, repo): + """Test that cloning into an existing dir fails""" + os.chdir('..') + ok_(clone(['arg0', repo.path]) == 1, + "Cloning did no fail as expected") + self._check_log(-2, + "gbp:error: Git command failed: Error " + "running git clone: fatal: destination path " + "'git-buildpackage' already exists and is not " + "an empty directory.") + + @RepoFixtures.native() + def test_clone_native(self, repo): + """Test that cloning of debian native packages works""" + dest = os.path.join(self._tmpdir, + 'cloned_repo') + clone(['arg0', + '--postclone=printenv > postclone.out', + repo.path, dest]) + cloned = ComponentTestGitRepository(dest) + self._check_repo_state(cloned, 'master', ['master']) + assert len(cloned.get_commits()) == 1 + self.check_hook_vars('postclone', ["GBP_GIT_DIR"]) + + def test_clone_environ(self): + """Test that environment variables influence git configuration""" + # Build up somethng we can clone from + os.environ['DEBFULLNAME'] = 'testing tester' + os.environ['DEBEMAIL'] = 'gbp-tester@debian.invalid' + repo = RepoFixtures.import_native() + got = repo.get_config("user.email") + want = os.environ['DEBEMAIL'] + ok_(got == want, "unexpected git config user.email: got %s, want %s" % (got, want)) + + got = repo.get_config("user.name") + want = os.environ['DEBFULLNAME'] + ok_(got == want, "unexpected git config user.name: got %s, want %s" % (got, want)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_import_dsc.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_import_dsc.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_import_dsc.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_import_dsc.py 2017-02-11 19:33:12.000000000 +0000 @@ -17,11 +17,11 @@ # import os -import hashlib from tests.component import (ComponentTestBase, - ComponentTestGitRepository) -from tests.component.deb import DEB_TEST_DATA_DIR + ComponentTestGitRepository, + skipUnless) +from tests.component.deb import DEB_TEST_DATA_DIR, DEB_TEST_DOWNLOAD_URL from nose.tools import ok_, eq_ @@ -33,15 +33,7 @@ class TestImportDsc(ComponentTestBase): """Test importing of debian source packages""" - @staticmethod - def _hash_file(filename): - h = hashlib.md5() - with open(filename, 'rb') as f: - buf = f.read() - h.update(buf) - return h.hexdigest() - - def test_debian_import(self): + def test_import_debian_native(self): """Test that importing of debian native packages works""" def _dsc(version): return os.path.join(DEB_TEST_DATA_DIR, @@ -53,17 +45,54 @@ repo = ComponentTestGitRepository('git-buildpackage') self._check_repo_state(repo, 'master', ['master']) assert len(repo.get_commits()) == 1 + commitmsg = repo.get_commit_info('HEAD')['body'] + ok_("git-buildpackage (0.01) unstable; urgency=low" in commitmsg) + ok_("git-buildpackage (0.4.14) unstable; urgency=low" in commitmsg) os.chdir('git-buildpackage') dsc = _dsc('0.4.15') assert import_dsc(['arg0', dsc]) == 0 self._check_repo_state(repo, 'master', ['master']) assert len(repo.get_commits()) == 2 + commitmsg = repo.get_commit_info('HEAD')['body'] + ok_("git-buildpackage (0.4.14) unstable; urgency=low" not in commitmsg) + ok_("git-buildpackage (0.4.15) unstable; urgency=low" in commitmsg) dsc = _dsc('0.4.16') assert import_dsc(['arg0', dsc]) == 0 self._check_repo_state(repo, 'master', ['master']) assert len(repo.get_commits()) == 3 + commitmsg = repo.get_commit_info('HEAD')['body'] + ok_("git-buildpackage (0.4.14) unstable; urgency=low" not in commitmsg) + ok_("git-buildpackage (0.4.15) unstable; urgency=low" not in commitmsg) + ok_("git-buildpackage (0.4.16) unstable; urgency=low" in commitmsg) + + @skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled") + def test_download(self): + def _dsc(version): + return os.path.join(DEB_TEST_DOWNLOAD_URL, + 'dsc-native', + 'git-buildpackage_%s.dsc' % version) + dsc = _dsc('0.4.14') + assert import_dsc(['arg0', + '--allow-unauthenticated', + dsc]) == 0 + repo = ComponentTestGitRepository('git-buildpackage') + self._check_repo_state(repo, 'master', ['master']) + assert len(repo.get_commits()) == 1 + + @skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled") + def test_broken_download(self): + def _not_a_dsc(version): + return os.path.join(DEB_TEST_DOWNLOAD_URL, + 'dsc-3.0', + 'hello-debhelper_%s.orig.tar.gz' % version) + + f = _not_a_dsc('2.6') + assert import_dsc(['arg0', + '--allow-unauthenticated', + f]) == 1 + self._check_log(-1, "gbp:error: Did not find a dsc file at") def test_create_branches(self): """Test if creating missing branches works""" @@ -82,6 +111,9 @@ repo = ComponentTestGitRepository('hello-debhelper') os.chdir('hello-debhelper') assert len(repo.get_commits()) == 2 + reflog, ret = repo._git_getoutput('reflog') + ok_("gbp: Import Debian changes" in reflog[1]) + ok_("gbp: Import Upstream version 2.6" in reflog[2]) self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream']) dsc = _dsc('2.8-1') assert import_dsc(['arg0', @@ -112,6 +144,9 @@ repo = ComponentTestGitRepository('hello-debhelper') self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream']) commits, expected = len(repo.get_commits()), 2 + commitmsg = repo.get_commit_info('HEAD')['body'] + ok_("hello-debhelper (2.8-1) unstable; urgency=low" in commitmsg) + ok_("hello (1.3-7) experimental; urgency=LOW" in commitmsg) for file in ['foo/test1', 'foo/test2']: ok_(file in repo.ls_tree('HEAD'), @@ -120,7 +155,7 @@ ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected)) dsc = DscFile.parse(dscfile) - # Check if we can rebuild the tarball and subtarball + # Check if we can rebuild the tarball and component ptars = [('hello-debhelper_2.8.orig.tar.gz', 'pristine-tar', '', dsc.tgz), ('hello-debhelper_2.8.orig-foo.tar.gz', 'pristine-tar^', 'foo', dsc.additional_tarballs['foo'])] @@ -128,9 +163,9 @@ outdir = os.path.abspath('.') for f, w, s, o in ptars: eq_(repo.get_subject(w), 'pristine-tar data for %s' % f) - old = self._hash_file(o) - p.checkout('hello-debhelper', '2.8', 'gzip', outdir, subtarball=s) - new = self._hash_file(os.path.join(outdir, f)) + old = self.hash_file(o) + p.checkout('hello-debhelper', '2.8', 'gzip', outdir, component=s) + new = self.hash_file(os.path.join(outdir, f)) eq_(old, new, "Checksum %s of regenerated tarball %s does not match original %s" % (f, old, new)) @@ -155,3 +190,72 @@ dsc]) == 1 self._check_log(0, "gbp:error: Directory 'hello-debhelper' already exists. If you want to import into it, " "please change into this directory otherwise move it away first") + + def test_import_10(self): + """Test if importing a 1.0 source format package works""" + def _dsc(version): + return os.path.join(DEB_TEST_DATA_DIR, + 'dsc-1.0', + 'hello-debhelper_%s.dsc' % version) + + dsc = _dsc('2.6-2') + assert import_dsc(['arg0', dsc]) == 0 + repo = ComponentTestGitRepository('hello-debhelper') + self._check_repo_state(repo, 'master', ['master', 'upstream'], + tags=['upstream/2.6', 'debian/2.6-2']) + assert len(repo.get_commits()) == 2 + + def test_target_dir(self): + """Test if setting the target dir works""" + def _dsc(version): + return os.path.join(DEB_TEST_DATA_DIR, + 'dsc-3.0', + 'hello-debhelper_%s.dsc' % version) + dsc = _dsc('2.6-2') + assert import_dsc(['arg0', + '--verbose', + '--no-pristine-tar', + dsc, + 'targetdir']) == 0 + assert os.path.exists('targetdir') + repo = ComponentTestGitRepository('targetdir') + self._check_repo_state(repo, 'master', ['master', 'upstream']) + + def test_bare(self): + """Test if importing into bare repository""" + def _dsc(version): + return os.path.join(DEB_TEST_DATA_DIR, + 'dsc-3.0', + 'hello-debhelper_%s.dsc' % version) + + dsc = _dsc('2.6-2') + assert import_dsc(['arg0', + '--verbose', + '--pristine-tar', + '--debian-branch=master', + '--upstream-branch=upstream', + dsc]) == 0 + repo = ComponentTestGitRepository('hello-debhelper') + os.chdir('hello-debhelper') + assert len(repo.get_commits()) == 2 + reflog, ret = repo._git_getoutput('reflog') + ok_("gbp: Import Debian changes" in reflog[1]) + ok_("gbp: Import Upstream version 2.6" in reflog[2]) + self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream']) + commitmsg = repo.get_commit_info('HEAD')['body'] + ok_("hello-debhelper (2.6-2) unstable; urgency=medium" in commitmsg) + ok_("hello (1.3-7) experimental; urgency=LOW" in commitmsg) + + dsc = _dsc('2.8-1') + assert import_dsc(['arg0', + '--verbose', + '--pristine-tar', + '--debian-branch=master', + '--upstream-branch=upstream', + dsc]) == 0 + commits, expected = len(repo.get_commits()), 4 + ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected)) + commitmsg = repo.get_commit_info('HEAD')['body'] + ok_("hello-debhelper (2.8-1) unstable; urgency=low" in commitmsg) + ok_("ello-debhelper (2.7-1) unstable; urgency=low" in commitmsg) + ok_("hello-debhelper (2.6-2) unstable; urgency=medium" not in commitmsg) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_import_orig.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_import_orig.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_import_orig.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_import_orig.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2015 Guido Günther +# (C) 2015,2017 Guido Günther # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,25 +17,51 @@ # import os +import shutil +import tarfile -from tests.component import ComponentTestBase -from tests.component.deb import DEB_TEST_DATA_DIR +from mock import patch, DEFAULT + +from tests.component import (ComponentTestBase, skipUnless) +from tests.component.deb import DEB_TEST_DATA_DIR, DEB_TEST_DOWNLOAD_URL +from tests.component.deb.fixtures import RepoFixtures from gbp.scripts.import_orig import main as import_orig -from gbp.git.repository import GitRepository +from gbp.deb.pristinetar import DebianPristineTar +from gbp.deb.dscfile import DscFile +from gbp.git.repository import GitRepository, GitRepositoryError -from nose.tools import ok_ +from nose.tools import ok_, eq_, assert_raises -class TestImportOrig(ComponentTestBase): - """Test importing of new upstream sources""" +def raise_if_tag_match(match): + def wrapped(*args, **kwargs): + if len(args) > 0 and args[0].startswith(match) or kwargs.get('name', '').startswith(match): + raise GitRepositoryError('this is a create tag error mock for %s %s' % (match, kwargs)) + return DEFAULT + return wrapped + + +def _dsc_file(pkg, version, dir='dsc-3.0'): + return os.path.join(DEB_TEST_DATA_DIR, dir, '%s_%s.dsc' % (pkg, version)) + +DEFAULT_DSC = _dsc_file('hello-debhelper', '2.6-2') + + +class TestImportOrig(ComponentTestBase): + """Test importing of new upstream versions""" pkg = "hello-debhelper" def_branches = ['master', 'upstream', 'pristine-tar'] - def _orig(self, version): + def _orig(self, version, dir='dsc-3.0'): return os.path.join(DEB_TEST_DATA_DIR, - 'dsc-3.0', + dir, + '%s_%s.orig.tar.gz' % (self.pkg, version)) + + def _download_url(self, version, dir='dsc-3.0'): + return os.path.join(DEB_TEST_DOWNLOAD_URL, + dir, '%s_%s.orig.tar.gz' % (self.pkg, version)) def test_initial_import(self): @@ -44,14 +70,98 @@ os.chdir(self.pkg) orig = self._orig('2.6') ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0) + self._check_repo_state(repo, 'master', self.def_branches, + tags=['upstream/2.6']) + @skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled") + def test_download(self): + """Test that importing via download works""" + repo = GitRepository.create(self.pkg) + os.chdir(self.pkg) + orig = self._download_url('2.6') + ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0) self._check_repo_state(repo, 'master', self.def_branches, tags=['upstream/2.6']) + def _check_component_tarballs(self, repo, files): + for file in files: + ok_(file in repo.ls_tree('HEAD'), + "Could not find component tarball file %s in %s" % (file, repo.ls_tree('HEAD'))) + ok_(file in repo.ls_tree('upstream'), + "Could not find component tarball file %s in %s" % (file, repo.ls_tree('upstream'))) + + @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar']) + def test_update(self, repo): + """ + Test that importing a new version works + """ + orig = self._orig('2.8') + ok_(import_orig(['arg0', + '--postimport=printenv > postimport.out', + '--no-interactive', '--pristine-tar', orig]) == 0) + self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], + tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8']) + eq_(os.path.exists('postimport.out'), True) + self.check_hook_vars('postimport', [("GBP_BRANCH", "master"), + ("GBP_TAG", "upstream/2.8"), + ("GBP_UPSTREAM_VERSION", "2.8"), + ("GBP_DEBIAN_VERSION", "2.8-1")]) + + @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar']) + def test_update_component_tarballs(self, repo): + """ + Test importing new version with additional tarballs works + """ + # Import 2.8 + orig = self._orig('2.8', dir='dsc-3.0-additional-tarballs') + ok_(import_orig(['arg0', '--component=foo', '--no-interactive', '--pristine-tar', orig]) == 0) + self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], + tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8']) + self._check_component_tarballs(repo, ['foo/test1', 'foo/test2']) + + dsc = DscFile.parse(_dsc_file(self.pkg, '2.8-1', dir='dsc-3.0-additional-tarballs')) + # Check if we can rebuild the upstream tarball and additional tarball + ptars = [('hello-debhelper_2.8.orig.tar.gz', 'pristine-tar', '', dsc.tgz), + ('hello-debhelper_2.8.orig-foo.tar.gz', 'pristine-tar^', 'foo', dsc.additional_tarballs['foo'])] + + p = DebianPristineTar(repo) + outdir = os.path.abspath('.') + for f, w, s, o in ptars: + eq_(repo.get_subject(w), 'pristine-tar data for %s' % f) + old = self.hash_file(o) + p.checkout('hello-debhelper', '2.8', 'gzip', outdir, component=s) + out = os.path.join(outdir, f) + new = self.hash_file(out) + eq_(old, new, "Checksum %s of regenerated tarball %s does not match original %s" % + (f, old, new)) + os.unlink(out) + + # Import 2.9 + orig = self._orig('2.9', dir='dsc-3.0-additional-tarballs') + ok_(import_orig(['arg0', '--component=foo', '--no-interactive', '--pristine-tar', orig]) == 0) + self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], + tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8', 'upstream/2.9']) + self._check_component_tarballs(repo, ['foo/test1', 'foo/test2', 'foo/test3']) + + dsc = DscFile.parse(_dsc_file(self.pkg, '2.9-1', dir='dsc-3.0-additional-tarballs')) + # Check if we can rebuild the upstream tarball and additional tarball + ptars = [('hello-debhelper_2.9.orig.tar.gz', 'pristine-tar', '', dsc.tgz), + ('hello-debhelper_2.9.orig-foo.tar.gz', 'pristine-tar^', 'foo', dsc.additional_tarballs['foo'])] + + p = DebianPristineTar(repo) + outdir = os.path.abspath('.') + for f, w, s, o in ptars: + eq_(repo.get_subject(w), 'pristine-tar data for %s' % f) + old = self.hash_file(o) + p.checkout('hello-debhelper', '2.9', 'gzip', outdir, component=s) + new = self.hash_file(os.path.join(outdir, f)) + eq_(old, new, "Checksum %s of regenerated tarball %s does not match original %s" % + (f, old, new)) + def test_tag_exists(self): - """Test that importing an already importet version fails""" + """Test that importing an already imported version fails""" repo = GitRepository.create(self.pkg) - os.chdir(self.pkg) + os.chdir(repo.path) orig = self._orig('2.6') # First import ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0) @@ -61,3 +171,147 @@ self._check_log(0, "gbp:error: Upstream tag 'upstream/2.6' already exists") # Check that the second import didn't change any refs self.check_refs(repo, heads) + + @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar']) + def test_update_fail_create_upstream_tag(self, repo): + """ + Test that we can recover from a failure to create the upstream + tag + """ + heads = self.rem_refs(repo, self.def_branches) + orig = self._orig('2.8') + with patch('gbp.git.repository.GitRepository.create_tag', + side_effect=GitRepositoryError('this is a create tag error mock')): + ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1) + self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], + tags=['debian/2.6-2', 'upstream/2.6']) + self.check_refs(repo, heads) + + @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar']) + def test_update_fail_merge(self, repo): + """ + Test that we can recover from a failed merge + """ + heads = self.rem_refs(repo, self.def_branches) + orig = self._orig('2.8') + with patch('gbp.scripts.import_orig.debian_branch_merge', + side_effect=GitRepositoryError('this is a fail merge error mock')): + ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1) + self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], + tags=['debian/2.6-2', 'upstream/2.6']) + self.check_refs(repo, heads) + + @patch('gbp.git.repository.GitRepository.create_tag', + side_effect=raise_if_tag_match('upstream/')) + def test_initial_import_fail_create_upstream_tag(self, RepoMock): + """ + Test that we can recover from a failure to create the upstream + tag on initial import + """ + repo = GitRepository.create(self.pkg) + os.chdir(repo.path) + orig = self._orig('2.6') + ok_(import_orig(['arg0', '--no-interactive', orig]) == 1) + + self._check_repo_state(repo, None, [], tags=[]) + + def test_initial_import_fail_create_debian_branch(self): + """ + Test that we can recover from creating the Debian branch on + initial import + """ + repo = GitRepository.create(self.pkg) + os.chdir(self.pkg) + orig = self._orig('2.6') + + with patch('gbp.git.repository.GitRepository.create_branch', + side_effect=GitRepositoryError('this is a create branch error mock')): + ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1) + + self._check_repo_state(repo, None, [], tags=[]) + + @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar']) + def test_filter_with_component_tarballs(self, repo): + """ + Test that using a filter works even with component tarballs (#840602) + """ + # copy data since we don't want the repacked tarball to end up in DEB_TEST_DATA_DIR + os.mkdir('../tarballs') + for f in ['hello-debhelper_2.8.orig-foo.tar.gz', 'hello-debhelper_2.8.orig.tar.gz']: + src = os.path.join(DEB_TEST_DATA_DIR, 'dsc-3.0-additional-tarballs', f) + shutil.copy(src, '../tarballs') + + ok_(import_orig(['arg0', + '--component=foo', + '--no-interactive', + '--pristine-tar', + '--filter-pristine-tar', + '--filter=README*', + '../tarballs/hello-debhelper_2.8.orig.tar.gz']) == 0) + self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], + tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8']) + self._check_component_tarballs(repo, ['foo/test1', 'foo/test2']) + + ok_('README' not in repo.ls_tree('HEAD'), + "README not filtered out of %s" % repo.ls_tree('HEAD')) + tar = '../hello-debhelper_2.8.orig.tar.gz' + + # Check if tar got filtered properly + ok_(os.path.exists(tar)) + t = tarfile.open(name=tar, mode="r:gz") + for f in ['hello-2.8/configure']: + i = t.getmember(f) + eq_(type(i), tarfile.TarInfo) + for f in ['hello-2.8/README']: + with assert_raises(KeyError): + t.getmember(f) + t.close() + + @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar']) + def test_filter_with_orig_tarball(self, repo): + """ + Test that using a filter works even with an upstream tarball + that has already the correct name (#558777) + """ + f = 'hello-debhelper_2.8.orig.tar.gz' + src = os.path.join(DEB_TEST_DATA_DIR, 'dsc-3.0', f) + shutil.copy(src, '..') + + ok_(import_orig(['arg0', + '--no-interactive', + '--pristine-tar', + '--filter-pristine-tar', + '--filter=README*', + '../hello-debhelper_2.8.orig.tar.gz']) == 0) + self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], + tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8']) + + filtered = os.path.join('..', f) + ok_(os.path.exists(filtered)) + eq_(os.readlink(filtered).split('/')[-1], + 'hello-debhelper_2.8.orig.gbp.tar.gz') + # Check if tar got filtered properly + t = tarfile.open(name=filtered, mode="r:gz") + for f in ['hello-2.8/configure']: + i = t.getmember(f) + eq_(type(i), tarfile.TarInfo) + for f in ['hello-2.8/README']: + with assert_raises(KeyError): + t.getmember(f) + t.close() + + @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar']) + def test_import_in_submodule(self, repo): + """ + Test that importing works if repo is a git submodule (#674015) + """ + parent_repo = GitRepository.create('../parent') + parent_repo.add_submodule(repo.path) + parent_repo.update_submodules(init=True, recursive=True) + submodule = GitRepository(os.path.join(parent_repo.path, + 'hello-debhelper')) + ok_(submodule.path.endswith, 'parent/hello-debhelper') + os.chdir(submodule.path) + orig = self._orig('2.8') + submodule.create_branch('upstream', 'origin/upstream') + ok_(import_orig(['arg0', '--no-interactive', orig]) == 0) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_pull.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_pull.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/deb/test_pull.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/deb/test_pull.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,52 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2017 Guido Günther +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# + +import os + +from tests.component import (ComponentTestBase, + ComponentTestGitRepository) +from tests.component.deb.fixtures import RepoFixtures + +from nose.tools import eq_ + +from gbp.scripts.clone import main as clone +from gbp.scripts.pull import main as pull + + +class TestPull(ComponentTestBase): + """Test cloning from a remote""" + + @RepoFixtures.native() + def test_pull_explicit_remote(self, repo): + """Test that pulling of debian native packages works""" + dest = os.path.join(self._tmpdir, 'cloned_repo') + clone(['arg0', repo.path, dest]) + cloned = ComponentTestGitRepository(dest) + self._check_repo_state(cloned, 'master', ['master']) + eq_(pull(['argv0', 'origin']), 0) + assert len(repo.get_commits()) == 1 + + @RepoFixtures.native() + def test_pull_default_remote(self, repo): + """Test that pulling of debian native packages works""" + dest = os.path.join(self._tmpdir, 'cloned_repo') + clone(['arg0', repo.path, dest]) + cloned = ComponentTestGitRepository(dest) + self._check_repo_state(cloned, 'master', ['master']) + eq_(pull(['argv0']), 0) + assert len(repo.get_commits()) == 1 diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/__init__.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -20,10 +20,12 @@ Module for testing individual command line tools of the git-buildpackage suite """ +import hashlib import os import shutil import tempfile import unittest +from unittest import skipUnless from nose import SkipTest from nose.tools import eq_, ok_ # pylint: disable=E0611 from .. testutils import GbpLogTester @@ -31,6 +33,9 @@ from gbp.git import GitRepository, GitRepositoryError +__all__ = ['ComponentTestGitRepository', 'ComponentTestBase', 'GbpLogTester', 'skipUnless'] + + class ComponentTestGitRepository(GitRepository): """Git repository class for component tests""" def submodule_status(self): @@ -205,3 +210,32 @@ for (h, s) in rem: n = repo.rev_parse(h) ok_(n == s, "Head '%s' points to %s' instead of '%s'" % (h, n, s)) + + @staticmethod + def hash_file(filename): + h = hashlib.md5() + with open(filename, 'rb') as f: + buf = f.read() + h.update(buf) + return h.hexdigest() + + @staticmethod + def check_hook_vars(name, expected): + """ + Check that a hook had the given vars in + it's environment. + This assumes the hook was set too + printenv > hookname.out + """ + with open('%s.out' % name) as f: + parsed = dict([line[:-1].split('=', 1) for line in f.readlines() if line.startswith("GBP_")]) + + for var in expected: + if len(var) == 2: + k, v = var + else: + k, v = var, None + ok_(k in parsed, "%s not found in %s" % (k, parsed)) + if v is not None: + ok_(v == parsed[k], + "Got %s not expected value %s for %s" % (parsed[k], v, k)) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/data/manage.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/data/manage.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/data/manage.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/data/manage.py 2017-02-11 19:33:12.000000000 +0000 @@ -60,6 +60,7 @@ ret_err = stderr.splitlines() if stderr else stderr return (popen.returncode, ret_out, ret_err) + def git_cmd(cmd, opts=None, capture_stdout=False, input_data=None, extra_env=None): """Run git command""" @@ -71,6 +72,7 @@ ('git ' + ' '.join(git_opts), '\n'.join(stderr))) return stdout + def git_cat_file(treeish): """Get object content""" info = {} @@ -86,9 +88,10 @@ info['parents'] = [val] else: info[key] = val - info['message'] = output[num+1:] + info['message'] = output[num + 1:] return info + def git_write_patch(treeish, outfile): """Write patch with user-defined filename""" cmd = ['git', 'format-patch', '-1', '--stdout', '--no-stat', @@ -139,7 +142,7 @@ "new repository is created") # Export command parser = subparsers.add_parser('export-repo', - help='Serialize test package repositories') + help='Serialize test package repositories') parser.set_defaults(func=cmd_export_repos) parser.add_argument('--output-dir', '-o', default='.', help="Target directory for the exported repo(s)") @@ -163,6 +166,7 @@ else: LOG.debug('Skipping %s', src) + def do_build(tag, builddir, silent_build=False): """Run git-buildpackage-rpm""" gbp_opts = ['buildpackage-rpm', '--git-ignore-new', @@ -173,7 +177,7 @@ True, silent_build) if ret: for line in out: - print line + print(line) raise Exception('Building %s failed! Builddata can be found ' 'in %s' % (tag, builddir)) @@ -318,9 +322,9 @@ else: raise Exception("Merge commits (%s) not supported!" % commit['sha1']) # Sanity check for commit - assert sha1 == commit['sha1'], \ - "SHA-1 of the created commit is wrong (%s != %s)" % \ - (sha1, commit['sha1']) + assert sha1 == commit['sha1'], ( + "SHA-1 of the created commit is wrong (%s != %s)" % + (sha1, commit['sha1'])) def import_repo(datadir, repodir, force): @@ -348,7 +352,7 @@ # Create child mapping of commit history commits = defaultdict(list) for sha1, info in manifest['commits'].iteritems(): - if not 'parents' in info: + if 'parents' not in info: commits['root'].append(sha1) else: for parent in info['parents']: @@ -364,9 +368,9 @@ # Re-create tags for sha1, tag in manifest['tags'].iteritems(): - signature_data = "object %s\ntype %s\ntag %s\ntagger %s\n\n%s\n" % \ - (tag['object'], tag['type'], tag['tag'], tag['tagger'], - tag['message']) + signature_data = "object %s\ntype %s\ntag %s\ntagger %s\n\n%s\n" % ( + tag['object'], tag['type'], tag['tag'], tag['tagger'], + tag['message']) new_sha1 = git_cmd('mktag', None, True, signature_data)[0] assert new_sha1 == sha1, \ "SHA-1 of the re-created tag is wrong (%s != %s)" % \ @@ -440,7 +444,7 @@ 'tagger': tag_info['tagger'], 'message': '\n'.join(tag_info['message'])} # Serialize commits objects - refs = [ref for sha1, ref in refs] + refs = [ref for _, ref in refs] revisions = git_cmd('rev-list', ['--reverse'] + refs + ['--'], True) series = defaultdict(int) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/__init__.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -16,16 +16,12 @@ # """Test module for RPM command line tools of the git-buildpackage suite""" -import six - from nose.tools import nottest import os import shutil from glob import glob -from xml.dom import minidom from gbp.command_wrappers import Command -from gbp.git import GitRepositoryError from tests.component import ComponentTestBase, ComponentTestGitRepository @@ -33,10 +29,12 @@ RPM_TEST_DATA_SUBMODULE = os.path.join('tests', 'component', 'rpm', 'data') RPM_TEST_DATA_DIR = os.path.abspath(RPM_TEST_DATA_SUBMODULE) + def setup(): """Test Module setup""" ComponentTestGitRepository.check_testdata(RPM_TEST_DATA_SUBMODULE) + class RpmRepoTestBase(ComponentTestBase): """Baseclass for tests run in a Git repository with packaging data""" diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/test_buildpackage_rpm.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/test_buildpackage_rpm.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/test_buildpackage_rpm.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/test_buildpackage_rpm.py 2017-02-11 19:33:12.000000000 +0000 @@ -26,12 +26,12 @@ import subprocess from nose import SkipTest -from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 +from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 from gbp.git import GitRepository from gbp.scripts.buildpackage_rpm import main as gbp_rpm from tests.component.rpm import RpmRepoTestBase, RPM_TEST_DATA_DIR -from tests.testutils import ls_tar, ls_zip +from tests.testutils import ls_tar, ls_zip, capture # Disable "Method could be a function warning" # pylint: disable=R0201 @@ -47,8 +47,10 @@ def mock_gbp(args): """Wrapper for gbp-buildpackage-rpm""" - return gbp_rpm(['arg0', '--git-notify=off'] + args + - ['-ba', '--clean', '--target=noarch', '--nodeps']) + with capture.capture_stderr(): + return gbp_rpm(['arg0', '--git-notify=off'] + args + + ['-ba', '--clean', '--target=noarch', '--nodeps']) + def mock_notify(summary, message, notify_opt): """Mock notification system""" @@ -75,7 +77,7 @@ raise Exception("Failed to get file metadata for %s: %s" % (rpm, stderr)) return sorted([(nam, mod, dig) for dig, mod, nam in - [lin.split(None, 2) for lin in stdout.splitlines()]]) + [lin.split(None, 2) for lin in stdout.splitlines()]]) @staticmethod def check_rpms(directory): @@ -104,18 +106,7 @@ """Run outside a git repository""" eq_(mock_gbp([]), 1) self._check_log(0, 'gbp:error: %s is not a git repository' % - os.path.abspath('.')) - - def test_invalid_config_file(self): - """Test invalid config file""" - # Create and commit dummy invalid config file - repo = GitRepository.create('.') - with open('.gbp.conf', 'w') as conffd: - conffd.write('foobar\n') - repo.add_files('.gbp.conf') - repo.commit_all('Add conf') - eq_(mock_gbp([]), 1) - self._check_log(0, 'gbp:error: File contains no section headers.') + os.path.abspath('.')) def test_native_build(self): """Basic test of native pkg""" @@ -224,7 +215,7 @@ eq_(mock_gbp(['--git-tag', '--git-packaging-tag=rel-tag']), 1) # Re-tag - eq_(mock_gbp(['--git-retag', '--git-packaging-tag=rel-tag']), 1) + eq_(mock_gbp(['--git-retag', '--git-packaging-tag=rel-tag']), 3) self._check_log(-1, "gbp:error: '--git-retag' needs either '--git-tag'") eq_(mock_gbp(['--git-tag', '--git-packaging-tag=rel-tag', @@ -256,8 +247,8 @@ # Dummy update to upstream branch pkg_branch = repo.get_branch() upstr_branch = 'upstream' - orig_files = ['gbp-test/' + path for \ - path in repo.ls_tree(upstr_branch)] + ['gbp-test'] + orig_files = ['gbp-test/' + path for + path in repo.ls_tree(upstr_branch)] + ['gbp-test'] repo.set_branch(upstr_branch) with open('new-file', 'w') as fobj: fobj.write('New file\n') @@ -329,7 +320,7 @@ eq_(len(repo.get_commits(until='pristine-tar')), 2) shutil.rmtree('../rpmbuild') - # Second time no pristine-tar should not be commited + # Second time no pristine-tar should not be committed eq_(mock_gbp(['--git-pristine-tar-commit']), 0) eq_(len(repo.get_commits(until='pristine-tar')), 2) @@ -384,7 +375,7 @@ sub_files = sub_repo.ls_tree('HEAD') upstr_files = ['gbp-test/' + path for - path in repo.ls_tree(upstr_branch)] + path in repo.ls_tree(upstr_branch)] # Test the "no" option eq_(mock_gbp(['--git-no-submodules', '--git-upstream-tree=%s' % @@ -398,7 +389,7 @@ upstr_branch, '--git-ignore-new']), 0) tar_files = ls_tar('../rpmbuild/SOURCES/gbp-test-1.1.tar.bz2', False) ref_files = upstr_files + ['gbp-test/gbp-test-native.repo/' + path for - path in sub_files] + path in sub_files] self.check_files(ref_files, tar_files) shutil.rmtree('../rpmbuild') @@ -407,6 +398,10 @@ repo.create('gbp-test-native.repo') eq_(mock_gbp(['--git-submodules', '--git-upstream-tree=%s' % upstr_branch, '--git-ignore-new']), 2) + self._check_log(-2, + ".*Error generating submodules' archives: " + "Failed to list submodules of [0-9a-f]{40}: fatal: " + "not a tree object") def test_option_submodules_native(self): """Test the --git-submodules option for native packages""" @@ -419,14 +414,13 @@ sub_files = sub_repo.ls_tree('HEAD') master_files = ['gbp-test-native-1.0/' + path for - path in repo.ls_tree('HEAD')] + path in repo.ls_tree('HEAD')] # Test eq_(mock_gbp(['--git-submodules']), 0) zip_files = ls_zip('../rpmbuild/SOURCES/gbp-test-native-1.0.zip', False) - ref_files = master_files + \ - ['gbp-test-native-1.0/gbp-test-native2.repo/' + path for - path in sub_files] + ref_files = master_files + ['gbp-test-native-1.0/gbp-test-native2.repo/' + path for + path in sub_files] self.check_files(ref_files, zip_files) # Test submodule failure @@ -551,7 +545,7 @@ # Test exporting of some other commit than HEAD eq_(mock_gbp(['--git-export=release/1.0-1']), 0) eq_(os.listdir('../rpmbuild/RPMS/noarch'), - ['gbp-test-1.0-1.noarch.rpm']) + ['gbp-test-1.0-1.noarch.rpm']) self.check_rpms('../rpmbuild/RPMS/*') # Modify one tracked file, create one untracked and one ignored file @@ -613,4 +607,3 @@ # Packaging dir should be taken from spec file if it is defined eq_(mock_gbp(['--git-packaging-dir=foo', '--git-spec-file=packaging/gbp-test-native.spec']), 0) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/test_import_srpm.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/test_import_srpm.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/test_import_srpm.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/test_import_srpm.py 2017-02-11 19:33:12.000000000 +0000 @@ -29,14 +29,17 @@ from tests.component import ComponentTestBase from tests.component.rpm import RPM_TEST_DATA_DIR as DATA_DIR +from tests.testutils import capture_stderr # Disable "Method could be a function warning" # pylint: disable=R0201 + def mock_import(args): """Wrapper for import-srpm""" # Call import-orig-rpm with added arg0 - return import_srpm.main(['arg0'] + args) + with capture_stderr(): + return import_srpm.main(['arg0'] + args) class TestImportPacked(ComponentTestBase): @@ -54,9 +57,11 @@ eq_(mock_import(['--no-pristine-tar', srpm]), 0) # Check repository state repo = GitRepository('gbp-test') - files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt', - 'gbp-test.spec', 'my.patch', 'my2.patch', 'my3.patch'} - self._check_repo_state(repo, 'master', ['master', 'upstream'], files) + files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt', + 'gbp-test.spec', 'my.patch', 'my2.patch', 'my3.patch'} + self._check_repo_state(repo, 'master', ['master', 'upstream'], + files=files, + tags=['packaging/1.0-1', 'upstream/1.0']) # Two commits: upstream and packaging files eq_(len(repo.get_commits()), 2) @@ -69,11 +74,21 @@ files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt', 'gbp-test2.spec', 'gbp-test2-alt.spec', 'my.patch', 'my2.patch', 'my3.patch'} - self._check_repo_state(repo, 'master', ['master', 'upstream'], files) - + self._check_repo_state(repo, 'master', ['master', 'upstream'], + files=files, + tags=['packaging/1%2.0-0', 'upstream/2.0']) # Two commits: upstream and packaging files eq_(len(repo.get_commits()), 2) + def test_target_dir(self): + """Test importing to target dir""" + srpm = os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm') + eq_(mock_import(['--no-pristine-tar', srpm, 'targetdir']), 0) + # Check repository state + assert os.path.exists('targetdir') + repo = GitRepository('targetdir') + self._check_repo_state(repo, 'master', ['master', 'upstream']) + def test_basic_import_orphan(self): """ Test importing of non-native src.rpm to separate packaging and @@ -97,7 +112,9 @@ files = {'.gbp.conf', 'Makefile', 'README', 'dummy.sh', 'packaging/gbp-test-native.spec'} repo = GitRepository('gbp-test-native') - self._check_repo_state(repo, 'master', ['master'], files) + self._check_repo_state(repo, 'master', ['master'], + files=files, + tags=['packaging/1.0-1']) # Only one commit: the imported source tarball eq_(len(repo.get_commits()), 1) @@ -113,9 +130,9 @@ def test_multiple_versions(self): """Test importing of multiple versions""" - srpms = [ os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm'), - os.path.join(DATA_DIR, 'gbp-test-1.0-1.other.src.rpm'), - os.path.join(DATA_DIR, 'gbp-test-1.1-1.src.rpm') ] + srpms = [os.path.join(DATA_DIR, x) for x in ['gbp-test-1.0-1.src.rpm', + 'gbp-test-1.0-1.other.src.rpm', + 'gbp-test-1.1-1.src.rpm']] eq_(mock_import(['--no-pristine-tar', srpms[0]]), 0) repo = GitRepository('gbp-test') self._check_repo_state(repo, 'master', ['master', 'upstream']) @@ -170,7 +187,6 @@ eq_(mock_import(['--packaging-branch=foo', srpm]), 1) self._check_log(-1, 'Also check the --create-missing-branches') - def test_filter(self): """Test filter option""" srpm = os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm') @@ -178,7 +194,7 @@ # Check repository state repo = GitRepository('gbp-test') files = set(['Makefile', 'dummy.sh', 'bar.tar.gz', 'foo.txt', - 'gbp-test.spec', 'my.patch', 'my2.patch', 'my3.patch']) + 'gbp-test.spec', 'my.patch', 'my2.patch', 'my3.patch']) self._check_repo_state(repo, 'master', ['master', 'upstream'], files) def test_misc_options(self): @@ -186,13 +202,13 @@ srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm') eq_(mock_import(['--no-pristine-tar', - '--packaging-branch=pack', - '--upstream-branch=orig', - '--packaging-dir=packaging', - '--packaging-tag=ver_%(upstreamversion)s-rel_%(release)s', - '--upstream-tag=orig/%(upstreamversion)s', - '--author-is-committer', - srpm]), 0) + '--packaging-branch=pack', + '--upstream-branch=orig', + '--packaging-dir=packaging', + '--packaging-tag=ver_%(upstreamversion)s-rel_%(release)s', + '--upstream-tag=orig/%(upstreamversion)s', + '--author-is-committer', + srpm]), 0) # Check repository state repo = GitRepository('gbp-test2') files = {'Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz', @@ -238,7 +254,7 @@ # Check that importing dir with multiple spec files fails eq_(mock_import(['multi-unpack']), 1) self._check_log(-1, 'gbp:error: Failed determine spec file: ' - 'Multiple spec files found') + 'Multiple spec files found') def test_import_spec(self): """Test importing of spec file""" @@ -268,28 +284,28 @@ import_srpm.urlopen = Mock() import_srpm.urlopen.return_value = open(local_fn, 'r') - eq_(mock_import(['--no-pristine-tar', '--download', srpm]), 0) + eq_(mock_import(['--no-pristine-tar', srpm]), 0) # Check repository state repo = GitRepository('gbp-test') self._check_repo_state(repo, 'master', ['master', 'upstream']) def test_nonexistent_url(self): - """Test graceful failure when trying download from nonexistent url""" + """Test graceful failure when trying download from non-existent url""" srpm = 'http://honk.sigxcpu.org/does/not/exist' # Do not connect to remote, mock failure import_srpm.urlopen = Mock() import_srpm.urlopen.side_effect = urllib.error.HTTPError(srpm, 404, "Not found", - None, None) + None, None) - eq_(mock_import(['--download', srpm]), 1) + eq_(mock_import([srpm]), 1) self._check_log(-1, "gbp:error: Download failed: HTTP Error 404") self._clear_log() def test_invalid_url(self): """Test graceful failure when trying download from invalid url""" srpm = 'foob://url.does.not.exist.com/foo.src.rpm' - eq_(mock_import(['--download', srpm]), 1) - self._check_log(-1, "gbp:error: Download failed: unknown url type:") + eq_(mock_import([srpm]), 1) + self._check_log(-1, ".*No such file or directory: 'foob://url.does.not.exist.com/foo.src.rpm") self._clear_log() diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/test_pq_rpm.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/test_pq_rpm.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/test_pq_rpm.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/test_pq_rpm.py 2017-02-11 19:33:12.000000000 +0000 @@ -18,13 +18,15 @@ import os import tempfile -from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 +from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 from gbp.scripts.pq_rpm import main as pq from gbp.git import GitRepository from gbp.command_wrappers import GitCommand +from gbp.rpm import SpecFile from tests.component.rpm import RpmRepoTestBase +from tests.testutils import capture_stderr # Disable "Method could be a function warning" # pylint: disable=R0201 @@ -35,9 +37,15 @@ # Call pq-rpm with added arg0 return pq(['arg0'] + args) + class TestPqRpm(RpmRepoTestBase): """Basic tests for gbp-pq-rpm""" + def _has_patches(self, specfile, patches): + spec = SpecFile(specfile) + eq_(sorted([p['linevalue'] for p in spec._patches().values()]), + sorted(patches)) + def test_invalid_args(self): """See that pq-rpm fails gracefully when called with invalid args""" GitRepository.create('.') @@ -53,23 +61,14 @@ # Test invalid cmdline options with assert_raises(SystemExit): - mock_pq(['--invalid-arg=123']) + with capture_stderr(): + mock_pq(['--invalid-arg=123']) def test_import_outside_repo(self): """Run pq-rpm when not in a git repository""" eq_(mock_pq(['export']), 1) self._check_log(0, 'gbp:error: %s is not a git repository' % - os.path.abspath(os.getcwd())) - - def test_invalid_config_file(self): - """Test invalid config file""" - # Create dummy invalid config file and run pq-rpm - GitRepository.create('.') - with open('.gbp.conf', 'w') as conffd: - conffd.write('foobar\n') - eq_(mock_pq(['foo']), 1) - self._check_log(0, 'gbp:error: Invalid config file: File contains no ' - 'section headers.') + os.path.abspath(os.getcwd())) def test_import_export(self): """Basic test for patch import and export""" @@ -79,6 +78,8 @@ eq_(mock_pq(['import']), 0) files = ['AUTHORS', 'dummy.sh', 'Makefile', 'NEWS', 'README', 'mydir/myfile.txt'] + patches = ['my.patch', '0001-my-gz.patch', '0002-my-bzip2.patch', '0003-my2.patch'] + branches.append('patch-queue/master') self._check_repo_state(repo, 'patch-queue/master', branches, files) eq_(repo.get_merge_base('upstream', 'patch-queue/master'), @@ -89,15 +90,16 @@ # Test export eq_(mock_pq(['export', '--upstream-tag', 'upstream/%(version)s']), 0) files = ['.gbp.conf', '.gitignore', 'bar.tar.gz', 'foo.txt', - 'gbp-test.spec', '0001-my-gz.patch', '0002-my-bzip2.patch', - '0003-my2.patch', 'my.patch'] + 'gbp-test.spec'] + patches self._check_repo_state(repo, 'master', branches, files) eq_(repo.status()[' M'], ['gbp-test.spec']) + self._has_patches('gbp-test.spec', patches) # Another export after removing some patches os.unlink('0001-my-gz.patch') eq_(mock_pq(['export']), 0) self._check_repo_state(repo, 'master', branches, files) + self._has_patches('gbp-test.spec', patches) def test_import_export2(self): """Another test for import and export""" @@ -107,6 +109,7 @@ # Import eq_(mock_pq(['import']), 0) files = ['dummy.sh', 'Makefile', 'README', 'mydir/myfile.txt'] + patches = ['packaging/0001-My-modification.patch', 'my.patch'] self._check_repo_state(repo, 'patch-queue/master-orphan', branches, files) @@ -115,6 +118,7 @@ '--spec-file', 'packaging/gbp-test2.spec']), 0) self._check_repo_state(repo, 'master-orphan', branches) eq_(repo.status()[' M'], ['packaging/gbp-test2.spec']) + self._has_patches('packaging/gbp-test2.spec', patches) def test_rebase(self): """Basic test for rebase action""" @@ -248,10 +252,11 @@ branches = repo.get_local_branches() # Export eq_(mock_pq(['export', '--no-patch-numbers']), 0) + patches = ['my-gz.patch', 'my-bzip2.patch', 'my2.patch', 'my.patch'] files = ['.gbp.conf', '.gitignore', 'bar.tar.gz', 'foo.txt', - 'gbp-test.spec', 'my-gz.patch', 'my-bzip2.patch', 'my2.patch', - 'my.patch'] + 'gbp-test.spec'] + patches self._check_repo_state(repo, 'master', branches, files) + self._has_patches('gbp-test.spec', patches) def test_option_tmp_dir(self): """Test the --tmp-dir cmdline option""" @@ -325,10 +330,12 @@ # Export should create diff up to the merge point and one "normal" patch eq_(mock_pq(['export']), 0) + patches = ['my.patch', + '%s-to-%s.diff' % (upstr_rev, merge_rev), '0002-my2.patch'] files = ['.gbp.conf', '.gitignore', 'bar.tar.gz', 'foo.txt', - 'gbp-test.spec', 'my.patch', - '%s-to-%s.diff' % (upstr_rev, merge_rev), '0002-my2.patch'] + 'gbp-test.spec'] + patches self._check_repo_state(repo, 'master', branches, files) + self._has_patches('gbp-test.spec', patches) def test_import_unapplicable_patch(self): """Test import when a patch does not apply""" @@ -339,10 +346,10 @@ patch_file.write('-this-does\n+not-apply\n') eq_(mock_pq(['import']), 1) self._check_log(-2, "(" - "Aborting|" - "Please, commit your changes or stash them|" - "gbp:error: Import failed.* You have local changes" - ")") + "Aborting|" + "Please, commit your changes or stash them|" + "gbp:error: Import failed.* You have local changes" + ")") self._check_repo_state(repo, 'master', branches) # Now commit the changes to the patch and try again @@ -351,4 +358,3 @@ eq_(mock_pq(['import']), 1) self._check_log(-2, "gbp:error: Import failed: Error running git apply") self._check_repo_state(repo, 'master', branches) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/test_rpm_ch.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/test_rpm_ch.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/component/rpm/test_rpm_ch.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/component/rpm/test_rpm_ch.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,337 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2013-2015 Intel Corporation +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# +"""Tests for the gbp-rpm-ch tool""" + +import os +import re +from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 + +from gbp.scripts.rpm_ch import main as rpm_ch +from gbp.git import GitRepository +from tests.testutils import capture_stderr + +from tests.component.rpm import RpmRepoTestBase + +# Disable "Method could be a function warning" +# pylint: disable=R0201 + + +def mock_ch(args): + """Wrapper for gbp-rpm-ch""" + with capture_stderr(): + return rpm_ch(['arg0', '--packaging-branch=master', + '--spawn-editor=never'] + args) + + +class TestRpmCh(RpmRepoTestBase): + """Basic tests for gbp-rpm-ch""" + + def setUp(self): + """Test case setup""" + super(TestRpmCh, self).setUp() + # Set environment so that commits succeed without git config + os.environ['GIT_AUTHOR_NAME'] = 'My Name' + os.environ['GIT_COMMITTER_NAME'] = 'My Name' + os.environ['EMAIL'] = 'me@example.com' + + @staticmethod + def read_file(filename): + """Read file to a list""" + with open(filename) as fobj: + return fobj.readlines() + + def test_invalid_args(self): + """See that gbp-rpm-ch fails gracefully when called with invalid args""" + GitRepository.create('.') + + with assert_raises(SystemExit): + mock_ch(['--invalid-opt']) + + def test_import_outside_repo(self): + """Run gbp-rpm-ch when not in a git repository""" + eq_(mock_ch([]), 1) + self._check_log(0, 'gbp:error: No Git repository at ') + + def test_update_spec_changelog(self): + """Test updating changelog in spec""" + repo = self.init_test_repo('gbp-test') + eq_(mock_ch([]), 0) + eq_(repo.status(), {' M': ['gbp-test.spec']}) + + def test_update_changes_file(self): + """Test updating a separate changes file""" + repo = self.init_test_repo('gbp-test-native') + eq_(mock_ch([]), 0) + eq_(repo.status(), {' M': ['packaging/gbp-test-native.changes']}) + + def test_create_spec_changelog(self): + """Test creating changelog in spec file""" + repo = self.init_test_repo('gbp-test2') + orig_content = self.read_file('packaging/gbp-test2.spec') + + # Fails if no starting point is given + eq_(mock_ch([]), 1) + self._check_log(-1, "gbp:error: Couldn't determine starting point") + + # Give starting point + eq_(mock_ch(['--since=HEAD^']), 0) + eq_(repo.status(), {' M': ['packaging/gbp-test2.spec']}) + content = self.read_file('packaging/gbp-test2.spec') + # Should contain 4 lines (%changelog, header, 1 entry and an empty line) + eq_(len(content), len(orig_content) + 4) + + def test_create_changes_file(self): + """Test creating a separate changes file""" + repo = self.init_test_repo('gbp-test2') + + # Fails if no starting point is given + eq_(mock_ch(['--changelog-file=CHANGES']), 1) + self._check_log(-1, "gbp:error: Couldn't determine starting point") + + # Give starting point + eq_(mock_ch(['--since=HEAD^', '--changelog-file=CHANGES']), 0) + eq_(repo.status(), {'??': ['packaging/gbp-test2.changes']}) + content = self.read_file('packaging/gbp-test2.changes') + # Should contain 3 lines (header, 1 entry and an empty line) + eq_(len(content), 3) + + def test_option_changelog_file(self): + """Test the --changelog-file cmdline option""" + repo = self.init_test_repo('gbp-test-native') + + # Guess changelog file + eq_(mock_ch(['--changelog-file=CHANGES']), 0) + eq_(repo.status(), {' M': ['packaging/gbp-test-native.changes']}) + + # Use spec file as changelog + eq_(mock_ch(['--changelog-file=SPEC', '--since=HEAD^']), 0) + eq_(repo.status(), {' M': ['packaging/gbp-test-native.changes', + 'packaging/gbp-test-native.spec']}) + + # Arbitrary name + eq_(mock_ch(['--changelog-file=foo.changes', '--since=HEAD^']), 0) + eq_(repo.status(), {' M': ['packaging/gbp-test-native.changes', + 'packaging/gbp-test-native.spec'], + '??': ['foo.changes']}) + + def test_option_spec_file(self): + """Test the --spec-file cmdline option""" + repo = self.init_test_repo('gbp-test2') + + eq_(mock_ch(['--spec-file=foo.spec']), 1) + self._check_log(-1, "gbp:error: Unable to read spec file") + + eq_(mock_ch(['--spec-file=']), 1) + self._check_log(-1, "gbp:error: Multiple spec files found") + + eq_(mock_ch(['--spec-file=packaging/gbp-test2.spec', '--since=HEAD^']), + 0) + eq_(repo.status(), {' M': ['packaging/gbp-test2.spec']}) + + def test_option_packaging_dir(self): + """Test the --packaging-dir cmdline option""" + repo = self.init_test_repo('gbp-test-native') + + eq_(mock_ch(['--packaging-dir=foo']), 1) + self._check_log(-1, "gbp:error: No spec file found") + + # Packaging dir should be taken from spec file if it is defined + eq_(mock_ch(['--packaging-dir', 'foo', '--spec-file', + 'packaging/gbp-test-native.spec']), 0) + eq_(repo.status(), {' M': ['packaging/gbp-test-native.changes']}) + + def test_branch_options(self): + """Test the --packaging-branch and --ignore-branch cmdline options""" + self.init_test_repo('gbp-test-native') + + eq_(mock_ch(['--packaging-branch=foo']), 1) + self._check_log(-2, "gbp:error: You are not on branch 'foo'") + + eq_(mock_ch(['--packaging-branch=foo', '--ignore-branch']), 0) + + def test_option_no_release(self): + """Test the --no-release cmdline option""" + self.init_test_repo('gbp-test-native') + orig_content = self.read_file('packaging/gbp-test-native.changes') + + eq_(mock_ch(['--no-release']), 0) + content = self.read_file('packaging/gbp-test-native.changes') + # Only one line (entry) added + eq_(len(content), len(orig_content) + 1) + + def test_author(self): + """Test determining the author name/email""" + repo = self.init_test_repo('gbp-test-native') + + # Test taking email address from env + os.environ['EMAIL'] = 'user@host.com' + eq_(mock_ch([]), 0) + header = self.read_file('packaging/gbp-test-native.changes')[0] + ok_(re.match(r'.+ .+', header)) + + # Missing git config setting should not cause a failure + del os.environ['EMAIL'] + del os.environ['GIT_AUTHOR_NAME'] + os.environ['GIT_CONFIG_NOSYSTEM'] = '1' + os.environ['HOME'] = os.path.abspath('.') + eq_(mock_ch(['--git-author', '--since=HEAD^1']), 0) + + # Test the --git-author option + saved_author = os.environ.get('GIT_AUTHOR_NAME') + saved_email = os.environ.get('GIT_AUTHOR_EMAIL') + os.environ['GIT_AUTHOR_NAME'] = 'John Doe' + os.environ['GIT_AUTHOR_EMAIL'] = 'jd@host.com' + with open(os.path.join(repo.git_dir, 'config'), 'a') as fobj: + fobj.write('[user]\n name=John Doe\n email=jd@host.com\n') + eq_(mock_ch(['--git-author', '--since=HEAD^']), 0) + header = self.read_file('packaging/gbp-test-native.changes')[0] + ok_(re.match(r'.+ John Doe .+', header), header) + if saved_author: + os.environ['GIT_AUTHOR_NAME'] = saved_author + if saved_email: + os.environ['GIT_AUTHOR_EMAIL'] = saved_email + + def test_option_full(self): + """Test the --full cmdline option""" + repo = self.init_test_repo('gbp-test-native') + orig_content = self.read_file('packaging/gbp-test-native.changes') + + eq_(mock_ch(['--full', '--since=HEAD^']), 0) + commit_msg_body = repo.get_commit_info('HEAD')['body'] + full_msg = [line for line in commit_msg_body.splitlines() if line] + content = self.read_file('packaging/gbp-test-native.changes') + # New lines: header, 1 entry "header", entry "body" from commit message + # and one empty line + eq_(len(content), len(orig_content) + 3 + len(full_msg)) + + def test_option_ignore_regex(self): + """Test the --ignore-regex cmdline option""" + repo = self.init_test_repo('gbp-test-native') + orig_content = self.read_file('packaging/gbp-test-native.changes') + + eq_(mock_ch(['--full', '--since', 'HEAD^', '--ignore-regex', + 'Signed-off-by:.*']), 0) + commit_msg_body = repo.get_commit_info('HEAD')['body'] + full_msg = [line for line in commit_msg_body.splitlines() if + (line and not line.startswith('Signed-off-by:'))] + content = self.read_file('packaging/gbp-test-native.changes') + # New lines: header, 1 entry "header", filtered entry "body" from + # commit message and one empty line + eq_(len(content), len(orig_content) + 3 + len(full_msg)) + + def test_option_id_len(self): + """Test the --id-len cmdline option""" + repo = self.init_test_repo('gbp-test-native') + + eq_(mock_ch(['--id-len=10']), 0) + commit_id = repo.rev_parse('HEAD', 10) + content = self.read_file('packaging/gbp-test-native.changes') + ok_(content[1].startswith('- [%s] ' % commit_id)) + + def test_option_changelog_revision(self): + """Test the --id-len cmdline option""" + self.init_test_repo('gbp-test-native') + + # Test invalid format (unknown field) + eq_(mock_ch(['--changelog-revision=%(unknown_field)s']), 1) + self._check_log(-1, 'gbp:error: Unable to construct revision field') + + # Test acceptable format + eq_(mock_ch(['--changelog-revision=foobar']), 0) + header = self.read_file('packaging/gbp-test-native.changes')[0] + ok_(re.match(r'.+ foobar$', header)) + + def test_option_editor_cmd(self): + """Test the --editor-cmd and --spawn-editor cmdline options""" + repo = self.init_test_repo('gbp-test-native') + eq_(mock_ch(['--spawn-editor=release', '--editor-cmd=rm']), 0) + eq_(repo.status(), {' D': ['packaging/gbp-test-native.changes']}) + + repo.force_head('HEAD', hard=True) + ok_(repo.is_clean()) + + os.environ['EDITOR'] = 'rm' + eq_(mock_ch(['--spawn-editor=always', '--editor-cmd=']), + 0) + + def test_user_customizations(self): + """Test the user customizations""" + repo = self.init_test_repo('gbp-test-native') + + # Non-existent customization file + eq_(mock_ch(['--customizations=customizations.py']), 1) + + # Create user customizations file + with open('customizations.py', 'w') as fobj: + fobj.write("class ChangelogEntryFormatter(object):\n") + fobj.write(" @classmethod\n") + fobj.write(" def compose(cls, commit_info, **kwargs):\n") + fobj.write(" return ['- %s' % commit_info['id']]\n") + + eq_(mock_ch(['--customizations=customizations.py']), 0) + entry = self.read_file('packaging/gbp-test-native.changes')[1] + sha = repo.rev_parse('HEAD') + eq_(entry, '- %s\n' % sha) + + def test_paths(self): + """Test tracking of certain paths only""" + repo = self.init_test_repo('gbp-test-native') + orig_content = self.read_file('packaging/gbp-test-native.changes') + + # Add new commit with known content + with open('new-file.txt', 'w') as fobj: + fobj.write('this is new content\n') + repo.add_files('new-file.txt') + repo.commit_staged('Add new file') + + # Only track a non-existent file + eq_(mock_ch(['--since=HEAD^', 'non-existent-path']), 0) + content = self.read_file('packaging/gbp-test-native.changes') + # New lines: header and one empty line, no entries + eq_(len(content), len(orig_content) + 2) + + # Track existing file + repo.force_head('HEAD', hard=True) + eq_(mock_ch(['--since=HEAD^', 'new-file.txt']), 0) + content = self.read_file('packaging/gbp-test-native.changes') + # New lines: header, one entry line and one empty line + eq_(len(content), len(orig_content) + 3) + + def test_commit_guessing(self): + """Basic tests for guessing the starting point""" + repo = self.init_test_repo('gbp-test-native') + + # Check 'tagname' that is not found + eq_(mock_ch(['--changelog-revision=%(tagname)s']), 0) + self._check_log(0, 'gbp:warning: Changelog points to tagname') + + # Check 'upstreamversion' and 'release' fields + repo.force_head('HEAD', hard=True) + eq_(mock_ch(['--changelog-revision=%(upstreamversion)s-%(release)s']), + 0) + + def test_commit_guessing_fail(self): + """Test for failure of start commit guessing""" + self.init_test_repo('gbp-test-native') + + # Add "very old" header to changelog + with open('packaging/gbp-test-native.changes', 'w') as ch_fp: + ch_fp.write('* Sat Jan 01 2000 User 123\n- foo\n') + # rpm-ch should fail by not being able to find any commits before the + # last changelog section + eq_(mock_ch([]), 1) + self._check_log(-1, "gbp:error: Couldn't determine starting point") diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/context.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/context.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/context.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/context.py 2017-02-11 19:33:12.000000000 +0000 @@ -8,8 +8,8 @@ sys.path.insert(0, os.path.abspath('..')) -import gbp -import gbp.log +import gbp # noqa: E402 +import gbp.log # noqa: E402 gbp.log.setup(False, False) @@ -20,19 +20,22 @@ _chdir_backup = None _tmpdirs = [] + def chdir(dir): global _chdir_backup if not _chdir_backup: _chdir_backup = os.path.abspath(os.curdir) os.chdir(str(dir)) + def new_tmpdir(name): global _tmpdirs - prefix='gbp_%s_' % name + prefix = 'gbp_%s_' % name tmpdir = TmpDir(prefix) _tmpdirs.append(tmpdir) return tmpdir + def teardown(): if _chdir_backup: os.chdir(_chdir_backup) @@ -40,6 +43,7 @@ tmpdir.rmdir() del _tmpdirs[:] + class TmpDir(object): def __init__(self, suffix='', prefix='tmp'): diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/data/gbp_create_remote_repo.conf git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/data/gbp_create_remote_repo.conf --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/data/gbp_create_remote_repo.conf 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/data/gbp_create_remote_repo.conf 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,8 @@ +# Data for TestGbpCreateRemoteRepo + +[remote-config config1]] +remote-url-pattern = ssh://git.debian.org/git/pkg-libvirt/%(pkg)s.git +template-dir = /srv/alioth.debian.org/chroot/home/groups/pkg-libvirt/git-template + +[remote-config config2] +remote-url-pattern = ssh://git.debian.org/git/calendarserver/%(pkg)s.git diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/data/rpm/specs/gbp-test-quirks.spec git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/data/rpm/specs/gbp-test-quirks.spec --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/data/rpm/specs/gbp-test-quirks.spec 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/data/rpm/specs/gbp-test-quirks.spec 2017-02-11 19:33:12.000000000 +0000 @@ -25,6 +25,6 @@ # Patches are applied out-of-order wrt. numbering %patch5 %patch2 -%patch1 +%patch1 -F2 # Patch 999 does not exist, rpmbuild would fail but GBP should not %patch999 diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_Changelog.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_Changelog.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_Changelog.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_Changelog.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,337 @@ +# vim: set fileencoding=utf-8 : + +""" +Test L{gbp.deb.changelog.ChangeLog} +""" +from .. import context # noqa: 401 +import os +import nose + +cl_debian = """git-buildpackage (0.5.32) unstable; urgency=low + + * [efe9220] Use known_compressions in guess_upstream_version too + (Closes: #645477) + * [e984baf] git-import-orig: fix --filter + + -- Guido Günther Mon, 17 Oct 2011 10:15:22 +0200 + +git-buildpackage (0.5.31) unstable; urgency=low + + [ Guido Günther ] + * [3588d88] Fix pristine-tar error message + * [8da98da] gbp-pq: don't fail on missing series file but create an empty + branch instead + + [ Salvatore Bonaccorso ] + * [b33cf74] Fix URL to cl2vcs service. + Refer to https://honk.sigxcpu.org/cl2vcs instead of + https://honk.sigxcpu.org/cl2vcs for the cl2vcs service. (Closes: #640141) + + -- Guido Günther Wed, 28 Sep 2011 20:21:34 +0200 +""" + +cl_upstream = """python-dateutil (1.0-1) unstable; urgency=low + + * Initial release (Closes: #386256) + + -- Guido Günther Wed, 6 Sep 2006 10:33:06 +0200 +""" + +cl_epoch = """xserver-xorg-video-nv (1:1.2.0-3) unstable; urgency=low + + [ Steve Langasek ] + * Upload to unstable + + -- David Nusinow Mon, 18 Sep 2006 19:57:45 -0400 +""" + + +def setup(): + """Setup test module""" + if not os.path.exists('/usr/bin/debchange'): + raise nose.SkipTest('debchange tool not present') + + +def test_parse_debian_only(): + """ + Parse a the changelog of debian only package + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + + Properties tested: + - L{gbp.deb.changelog.ChangeLog.version} + - L{gbp.deb.changelog.ChangeLog.debian_version} + - L{gbp.deb.changelog.ChangeLog.upstream_version} + - L{gbp.deb.changelog.ChangeLog.epoch} + - L{gbp.deb.changelog.ChangeLog.noepoch} + + >>> import gbp.deb.changelog + >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) + >>> cl.version + '0.5.32' + >>> cl.version == cl['Version'] + True + >>> cl.debian_version + '0.5.32' + >>> cl.debian_version == cl['Debian-Version'] + True + >>> cl.noepoch + '0.5.32' + >>> cl.noepoch == cl['NoEpoch-Version'] + True + >>> cl.epoch + >>> cl.upstream_version + """ + + +def test_parse_no_eopch(): + """ + Parse a the changelog of a package without eopch + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + - L{gbp.deb.changelog.ChangeLog.has_epoch} + + Properties tested: + - L{gbp.deb.changelog.ChangeLog.version} + - L{gbp.deb.changelog.ChangeLog.debian_version} + - L{gbp.deb.changelog.ChangeLog.upstream_version} + - L{gbp.deb.changelog.ChangeLog.epoch} + - L{gbp.deb.changelog.ChangeLog.noepoch} + + >>> import gbp.deb.changelog + >>> cl = gbp.deb.changelog.ChangeLog(cl_upstream) + >>> cl.version + '1.0-1' + >>> cl.version == cl['Version'] + True + >>> cl.debian_version + '1' + >>> cl.debian_version == cl['Debian-Version'] + True + >>> cl.noepoch + '1.0-1' + >>> cl.noepoch == cl['NoEpoch-Version'] + True + >>> cl.epoch + >>> cl.upstream_version + '1.0' + >>> cl.has_epoch() + False + """ + + +def test_parse_eopch(): + """ + Parse a the changelog of a package without epoch + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + - L{gbp.deb.changelog.ChangeLog.has_epoch} + + Properties tested: + - L{gbp.deb.changelog.ChangeLog.version} + - L{gbp.deb.changelog.ChangeLog.debian_version} + - L{gbp.deb.changelog.ChangeLog.upstream_version} + - L{gbp.deb.changelog.ChangeLog.epoch} + - L{gbp.deb.changelog.ChangeLog.noepoch} + + >>> import gbp.deb.changelog + >>> cl = gbp.deb.changelog.ChangeLog(cl_epoch) + >>> cl.version + '1:1.2.0-3' + >>> cl.version == cl['Version'] + True + >>> cl.debian_version + '3' + >>> cl.debian_version == cl['Debian-Version'] + True + >>> cl.noepoch + '1.2.0-3' + >>> cl.noepoch == cl['NoEpoch-Version'] + True + >>> cl.epoch + '1' + >>> cl.upstream_version + '1.2.0' + >>> cl.has_epoch() + True + """ + + +def test_parse_name(): + """ + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + + Properties tested: + - L{gbp.deb.changelog.ChangeLog.name} + + >>> import gbp.deb.changelog + >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) + >>> cl.name + 'git-buildpackage' + """ + + +def test_parse_last_mod(): + """ + Test author, email and date of last modification + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + + Properties tested: + - L{gbp.deb.changelog.ChangeLog.name} + - L{gbp.deb.changelog.ChangeLog.email} + - L{gbp.deb.changelog.ChangeLog.date} + + >>> import gbp.deb.changelog + >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) + >>> cl.author.startswith('Guido') + True + >>> cl.email + 'agx@sigxcpu.org' + >>> cl.date + 'Mon, 17 Oct 2011 10:15:22 +0200' + """ + + +def test_parse_sections(): + """ + Test if we can parse sections out of the changelog + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + - L{gbp.deb.changelog.ChangeLogSection.__init__} + - L{gbp.deb.changelog.ChangeLogSection.parse} + + Properties tested: + - L{gbp.deb.changelog.ChangeLog.sections} + + >>> import gbp.deb.changelog + >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) + >>> cl.sections[0].package + 'git-buildpackage' + >>> cl.sections[0].version + '0.5.32' + >>> cl.sections[1].package + 'git-buildpackage' + >>> cl.sections[1].version + '0.5.31' + """ + + +def test_get_changes(): + """ + Test if we can get changes + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + - L{gbp.deb.changelog.ChangeLog.get_changes} + + >>> import gbp.deb.changelog + >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) + >>> len(cl.get_changes().split('\\n')) + 19 + >>> len(cl.get_changes('0.5.31').split('\\n')) + 7 + """ + + +def test_add_section(): + """ + Test if we can add a section to an existing changelog + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + - L{gbp.deb.changelog.ChangeLog._parse} + - L{gbp.deb.changelog.ChangeLog.add_section} + - L{gbp.deb.changelog.ChangeLog.spawn_dch} + + >>> import os + >>> import tempfile + >>> import shutil + >>> import gbp.deb.changelog + >>> from ..testutils import OsReleaseFile + >>> os_release = OsReleaseFile('/etc/lsb-release') + >>> olddir = os.path.abspath(os.path.curdir) + >>> testdir = tempfile.mkdtemp(prefix='gbp-test-changelog-') + >>> testdebdir = os.path.join(testdir, 'debian') + >>> testclname = os.path.join(testdebdir, "changelog") + >>> os.mkdir(testdebdir) + >>> clh = open(os.path.join(testdebdir, "changelog"), "w") + >>> ret = clh.write(cl_debian) + >>> clh.close() + >>> os.chdir(testdir) + >>> os.path.abspath(os.path.curdir) == testdir + True + >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) + >>> cl.add_section(msg=["Test add section"], distribution=None, author="Debian Maintainer", email="maint@debian.org") + >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) + >>> version = '0.5.32ubuntu1' if os_release['DISTRIB_ID'] == 'Ubuntu' else '0.5.33' + >>> cl.version == version + True + >>> cl.debian_version == version + True + >>> distributions = ['UNRELEASED', os_release['DISTRIB_CODENAME'] or 'unstable'] + >>> cl['Distribution'] in distributions + True + >>> 'Test add section' in cl['Changes'] + True + >>> os.chdir(olddir) + >>> os.path.abspath(os.path.curdir) == olddir + True + >>> shutil.rmtree(testdir, ignore_errors=True) + """ + + +def test_add_entry(): + """ + Test if we can add an entry to an existing changelog + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + - L{gbp.deb.changelog.ChangeLog._parse} + - L{gbp.deb.changelog.ChangeLog.add_entry} + - L{gbp.deb.changelog.ChangeLog.spawn_dch} + + >>> import os + >>> import tempfile + >>> import shutil + >>> import gbp.deb.changelog + >>> from ..testutils import OsReleaseFile + >>> os_release = OsReleaseFile('/etc/lsb-release') + >>> olddir = os.path.abspath(os.path.curdir) + >>> testdir = tempfile.mkdtemp(prefix='gbp-test-changelog-') + >>> testdebdir = os.path.join(testdir, 'debian') + >>> testclname = os.path.join(testdebdir, "changelog") + >>> os.mkdir(testdebdir) + >>> clh = open(os.path.join(testdebdir, "changelog"), "w") + >>> ret = clh.write(cl_debian) + >>> clh.close() + >>> os.chdir(testdir) + >>> os.path.abspath(os.path.curdir) == testdir + True + >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) + >>> cl.add_section(msg=["Test add section"], distribution=None, author="Debian Maintainer", email="maint@debian.org") + >>> cl.add_entry(msg=["Test add entry"], author="Debian Maintainer", email="maint@debian.org") + >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) + >>> version = '0.5.32ubuntu1' if os_release['DISTRIB_ID'] == 'Ubuntu' else '0.5.33' + >>> cl.version == version + True + >>> cl.debian_version == version + True + >>> distributions = ['UNRELEASED', os_release['DISTRIB_CODENAME'] or 'unstable'] + >>> cl['Distribution'] in distributions + True + >>> 'Test add entry' in cl['Changes'] + True + >>> cl['Changes'].split('*',1)[1] + ' Test add section\\n * Test add entry' + >>> os.chdir(olddir) + >>> os.path.abspath(os.path.curdir) == olddir + True + >>> shutil.rmtree(testdir, ignore_errors=True) + """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_Config.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_Config.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_Config.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_Config.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,103 @@ +# vim: set fileencoding=utf-8 : + +""" +Test L{gbp.config.GbpOptionParser} +Test L{gbp.config.GbpOptionParserDebian} +""" + +from .. import context # noqa: F401 + + +def test_option_parser(): + """ + Methods tested: + - L{gbp.config.GbpOptionParser.add_config_file_option} + - L{gbp.config.GbpOptionParser.add_boolean_config_file_option} + + >>> import gbp.config + >>> c = gbp.config.GbpOptionParser('common', prefix='test') + >>> c.add_config_file_option(option_name='upstream-branch', dest='upstream') + >>> c.add_boolean_config_file_option(option_name='overlay', dest='overlay') + >>> c.add_boolean_config_file_option(option_name='track', dest='track') + """ + + +def test_option_parser_debian(): + """ + Methods tested: + - L{gbp.config.GbpOptionParserDebian.add_config_file_option} + + >>> import gbp.config + >>> c = gbp.config.GbpOptionParserDebian('debian') + >>> c.add_config_file_option(option_name='builder', dest='builder') + Traceback (most recent call last): + ... + KeyError: 'builder' + >>> c.add_config_file_option(option_name='builder', dest='builder', help='foo') + """ + + +def test_option_group(): + """ + Methods tested: + - L{gbp.config.GbpOptionGroup.add_config_file_option} + - L{gbp.config.GbpOptionGroup.add_boolean_config_file_option} + + >>> import gbp.config + >>> c = gbp.config.GbpOptionParser('debian') + >>> g = gbp.config.GbpOptionGroup(c, 'wheezy') + >>> g.add_config_file_option(option_name='debian-branch', dest='branch') + >>> g.add_boolean_config_file_option(option_name='track', dest='track') + """ + + +def test_tristate(): + """ + Methods tested: + - L{gbp.config.GbpOptionParser.add_config_file_option} + + >>> import gbp.config + >>> c = gbp.config.GbpOptionParser('tristate') + >>> c.add_config_file_option(option_name="color", dest="color", type='tristate') + >>> options, args= c.parse_args(['--color=auto']) + >>> options.color + auto + """ + + +def test_filter(): + """ + The filter option should always parse as a list + >>> import os + >>> from gbp.config import GbpOptionParser + >>> tmpdir = str(context.new_tmpdir('bar')) + >>> confname = os.path.join(tmpdir, 'gbp.conf') + >>> GbpOptionParser._set_config_file_value('bar', 'filter', 'asdf', filename=confname) + >>> os.environ['GBP_CONF_FILES'] = confname + >>> parser = GbpOptionParser('bar') + >>> parser.config['filter'] + ['asdf'] + >>> f = open(confname, 'w') + >>> ret = f.write("[bar]\\nfilter = ['this', 'is', 'a', 'list']\\n") + >>> f.close() + >>> parser = GbpOptionParser('bar') + >>> parser.config['filter'] + ['this', 'is', 'a', 'list'] + >>> del os.environ['GBP_CONF_FILES'] + """ + + +def test_filters(): + """ + The filter can be given in plural form + >>> import os + >>> from gbp.config import GbpOptionParser + >>> tmpdir = str(context.new_tmpdir('bar')) + >>> confname = os.path.join(tmpdir, 'gbp.conf') + >>> GbpOptionParser._set_config_file_value('bar', 'filters', '["abc", "def"]\\n', filename=confname) + >>> os.environ['GBP_CONF_FILES'] = confname + >>> parser = GbpOptionParser('bar') + >>> parser.config['filter'] + ['abc', 'def'] + >>> del os.environ['GBP_CONF_FILES'] + """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_Control.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_Control.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_Control.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_Control.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,93 @@ +# vim: set fileencoding=utf-8 : + +""" +Test L{gbp.deb.control.Control} +""" + +from .. import context # noqa: 401 + +cl_debian = """Source: git-buildpackage +Section: vcs +Priority: optional +Maintainer: Guido Günther +Build-Depends: debhelper (>= 7.0.50~), python (>> 2.6.6-3~), + pychecker, gtk-doc-tools, sgml2x, docbook-utils, jade, python-dateutil, python-nose, + bash-completion, perl, python-epydoc, python-coverage, python-setuptools, + # For the testsuite + git (>= 1:1.7.9.1-1~), bzip2, unzip, pristine-tar +Standards-Version: 3.9.3 +Vcs-Git: git://honk.sigxcpu.org/git/git-buildpackage.git +Vcs-Browser: http://git.debian.org/?p=users/agx/git-buildpackage.git +Homepage: https://honk.sigxcpu.org/piki/projects/git-buildpackage/ +X-Python-Version: >= 2.6 + +Package: git-buildpackage +Architecture: all +Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, devscripts (>= 2.10.66~), + git (>= 1:1.7.9.1-1~), python-dateutil +Recommends: pristine-tar (>= 0.5), cowbuilder +Suggests: python-notify, unzip +Description: Suite to help with Debian packages in Git repositories + This package contains the following tools: + * git-import-{dsc,dscs}: import existing Debian source packages into a git + repository + * git-import-orig: import a new upstream version into the git repository + * git-buildpackage: build a package out of a git repository, check for local + modifications and tag appropriately + * git-dch: generate Debian changelog entries from Git commit messages + * gbp-{pull,clone}: clone and pull from remote repos + * gbp-pq: manage debian/patches easily + * gbp-create-remote-repo: create remote repositories +""" + + +def test_parse_control(): + """ + Parse a the control of debian package + + Methods tested: + - L{gbp.deb.control.Control.__init__} + + Properties tested: + - L{gbp.deb.control.Control.name} + - L{gbp.deb.control.Control.section} + - L{gbp.deb.control.Control.priority} + + >>> import gbp.deb.control + >>> cl = gbp.deb.control.Control(cl_debian) + >>> cl.name + 'git-buildpackage' + >>> cl.name == cl['Source'] + True + >>> cl.section + 'vcs' + >>> cl.section == cl['Section'] + True + >>> cl.priority + 'optional' + >>> cl.priority == cl['Priority'] + True + >>> cl['Standards-Version'] + '3.9.3' + >>> cl['Package'] + + """ + + +def test_no_control_error(): + """ + Raise an error if no control file exist or is empty + + Methods tested: + - L{gbp.deb.control.Control.__init__} + + >>> import gbp.deb.control + >>> cl = gbp.deb.control.Control(filename="doesnotexist") + Traceback (most recent call last): + ... + NoControlError: Control file doesnotexist does not exist + >>> cl = gbp.deb.control.Control("notparsable") + Traceback (most recent call last): + ... + ParseControlError: Empty or invalid control file or contents + """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_create_remote_repo.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_create_remote_repo.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_create_remote_repo.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_create_remote_repo.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,122 @@ +# vim: set fileencoding=utf-8 : + +from gbp.scripts.create_remote_repo import (build_remote_script, # noqa: F401 + parse_url) # noqa: F401 + + +def test_build_remote_script(): + """ + >>> build_remote_script({'base': 'base', 'dir': 'dir', 'pkg': 'pkg', 'template-dir': None, 'bare': True}, 'branch') + '\\nset -e\\numask 002\\nif [ -d base"dir" ]; then\\n echo "Repository at "basedir" already exists - giving up."\\n exit 1\\nfi\\nmkdir -p base"dir"\\ncd base"dir"\\ngit init --shared --bare\\necho "pkg packaging" > ./description\\necho "ref: refs/heads/branch" > ./HEAD\\n' + """ + + +def test_build_remote_script_template_dir(): + """ + >>> build_remote_script({'base': 'base', 'dir': 'dir', 'pkg': 'pkg', 'template-dir': '/doesnot/exist', 'bare': True}, 'branch') + '\\nset -e\\numask 002\\nif [ -d base"dir" ]; then\\n echo "Repository at "basedir" already exists - giving up."\\n exit 1\\nfi\\nmkdir -p base"dir"\\ncd base"dir"\\ngit init --shared --bare --template=/doesnot/exist\\necho "pkg packaging" > ./description\\necho "ref: refs/heads/branch" > ./HEAD\\n' + """ + + +def test_build_remote_script_bare(): + """ + >>> build_remote_script({'base': 'base', 'dir': 'dir', 'pkg': 'pkg', 'template-dir': None, 'bare': False}, 'branch') + '\\nset -e\\numask 002\\nif [ -d base"dir" ]; then\\n echo "Repository at "basedir" already exists - giving up."\\n exit 1\\nfi\\nmkdir -p base"dir"\\ncd base"dir"\\ngit init --shared\\necho "pkg packaging" > .git/description\\necho "ref: refs/heads/branch" > .git/HEAD\\n' + """ + + +def test_parse_url(): + """ + >>> url = parse_url("ssh://host/path/%(pkg)s", "origin", "package") + >>> url['base'] + '' + >>> url['dir'] + '/path/package' + >>> url['host'] + 'host' + >>> url['name'] + 'origin' + >>> url['pkg'] + 'package' + >>> url['port'] + >>> url['scheme'] + 'ssh' + >>> url['template-dir'] + >>> url['url'] + 'ssh://host/path/package' + + >>> url = parse_url("ssh://host:22/path/to/repo.git", "origin", "package") + >>> url['base'] + '' + >>> url['dir'] + '/path/to/repo.git' + >>> url['host'] + 'host' + >>> url['name'] + 'origin' + >>> url['pkg'] + 'package' + >>> url['port'] + '22' + >>> url['scheme'] + 'ssh' + >>> url['template-dir'] + >>> url['url'] + 'ssh://host:22/path/to/repo.git' + + >>> url = parse_url("ssh://host:22/~/path/%(pkg)s.git", "origin", "package") + >>> url['dir'] + 'path/package.git' + >>> url['host'] + 'host' + >>> url['name'] + 'origin' + >>> url['pkg'] + 'package' + >>> url['port'] + '22' + >>> url['scheme'] + 'ssh' + >>> url['template-dir'] + >>> url['url'] + 'ssh://host:22/~/path/package.git' + >>> url['bare'] + True + + >>> url = parse_url("ssh://host:22/~user/path/%(pkg)s.git", "origin", "package", "/doesnot/exist", bare=False) + >>> url['dir'] + 'path/package.git' + >>> url['host'] + 'host' + >>> url['name'] + 'origin' + >>> url['pkg'] + 'package' + >>> url['port'] + '22' + >>> url['scheme'] + 'ssh' + >>> url['template-dir'] + '/doesnot/exist' + >>> url['url'] + 'ssh://host:22/~user/path/package.git' + >>> url['bare'] + False + + >>> parse_url("git://host/repo.git", "origin", "package") + Traceback (most recent call last): + ... + GbpError: URL must use ssh protocol. + >>> parse_url("ssh://host/path/repo", "origin", "package") + Traceback (most recent call last): + ... + GbpError: URL needs to contain either a repository name or '%(pkg)s' + >>> parse_url("ssh://host:asdf/path/%(pkg)s.git", "origin", "package") + Traceback (most recent call last): + ... + GbpError: URL contains invalid port. + >>> parse_url("ssh://host/~us er/path/%(pkg)s.git", "origin", "package") + Traceback (most recent call last): + ... + GbpError: URL contains invalid ~username expansion. + """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_GitModifier.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_GitModifier.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_GitModifier.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_GitModifier.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,84 @@ +# vim: set fileencoding=utf-8 : + +""" +Test L{gbp.git.GitModifier} +""" + +from .. import context # noqa: F401 + + +def test_author(): + """ + Methods tested: + - L{gbp.git.GitModifier.get_author_env} + - L{gbp.git.GitModifier.get_committer_env} + - L{gbp.git.GitModifier.keys} + + >>> import gbp.git + >>> modifier = gbp.git.GitModifier('foo', 'bar') + >>> modifier.name + 'foo' + >>> modifier.email + 'bar' + >>> modifier.get_author_env()['GIT_AUTHOR_EMAIL'] + 'bar' + >>> modifier.get_author_env()['GIT_AUTHOR_NAME'] + 'foo' + >>> modifier.get_committer_env()['GIT_COMMITTER_NAME'] + 'foo' + >>> modifier.get_committer_env()['GIT_COMMITTER_EMAIL'] + 'bar' + >>> modifier._get_env('foo') + Traceback (most recent call last): + ... + GitModifierError: Neither committer nor author + >>> modifier['name'] + 'foo' + >>> modifier['email'] + 'bar' + >>> modifier['date'] + """ + + +def test_date(): + """ + Methods tested: + - L{gbp.git.GitModifier.__init__} + + Properties tested: + - L{gbp.git.GitModifier.date} + - L{gbp.git.GitModifier.datetime} + - L{gbp.git.GitModifier.tz_offset} + + >>> import gbp.git + >>> import datetime + >>> modifier = gbp.git.GitModifier('foo', 'bar', 1) + >>> modifier.date + '1 +0000' + >>> modifier.date = '1 +0400' + >>> modifier.date + '1 +0400' + >>> modifier['date'] + '1 +0400' + >>> modifier.datetime # doctest: +ELLIPSIS + datetime.datetime(1970, 1, 1, 4, 0, 1, tzinfo=) + >>> modifier.date = datetime.datetime(1970, 1, 1, 0, 0, 1) + >>> modifier.date + '1 +0000' + >>> modifier.datetime # doctest: +ELLIPSIS + datetime.datetime(1970, 1, 1, 0, 0, 1, tzinfo=) + >>> modifier.tz_offset + '+0000' + """ + + +def test_dict(): + """ + Test C{dict} interface + >>> import gbp.git + >>> modifier = gbp.git.GitModifier('foo', 'bar', 1) + >>> sorted(modifier.keys()) + ['date', 'email', 'name'] + >>> sorted(modifier.items()) + [('date', '1 +0000'), ('email', 'bar'), ('name', 'foo')] + """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_GitRepository.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_GitRepository.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_GitRepository.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_GitRepository.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,1053 @@ +# vim: set fileencoding=utf-8 : + +""" +Test L{gbp.git.GitRepository} + +This testcase creates several repositores: + + - A repository at I{dirs['repo']} called I{repo} + - A bare repository at I{dirs['bare']} called I{bare} + - A clone of I{repo} below I{dirs['clone']} called I{clone} + - A mirror of I{repo} below I{mirror_dirs['clone']} called I{mirror} +""" + +from .. import context + +import gbp.log + +gbp.log.setup(color=False, verbose=True) + +dirs = {} +subdirs = ['repo', 'bare', 'clone', 'mirror_clone'] + + +def setup_module(): + tmpdir = context.new_tmpdir(__name__) + for s in subdirs: + dirs[s] = tmpdir.join(s) + + +def teardown_module(): + for s in subdirs: + del dirs[s] + context.teardown() + + +def test_create(): + """ + Create a repository + + Methods tested: + - L{gbp.git.GitRepository.create} + + Properties tested: + - L{gbp.git.GitRepository.path} + - L{gbp.git.GitRepository.git_dir} + + >>> import os, gbp.git + >>> repo = gbp.git.GitRepository.create(dirs['repo']) + >>> repo.path == dirs['repo'] + True + >>> repo.git_dir == os.path.join(dirs['repo'], '.git') + True + >>> type(repo) == gbp.git.GitRepository + True + """ + + +def test_empty(): + """ + Empty repos have no branch + + Methods tested: + - L{gbp.git.GitRepository.get_branch} + - L{gbp.git.GitRepository.is_empty} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.get_branch() + >>> repo.branch + >>> repo.is_empty() + True + """ + + +def test_subdir(): + """ + Make surewe can init repos froma subdir + >>> import gbp.git, os + >>> os.mkdir(os.path.join(dirs['repo'], 'subdir')) + >>> repo = gbp.git.GitRepository(os.path.join(dirs['repo'], 'subdir'), toplevel=False) + >>> repo.path == dirs['repo'] + True + >>> repo = gbp.git.GitRepository(os.path.join(dirs['repo'], 'subdir'), toplevel=True) # doctest:+ELLIPSIS + Traceback (most recent call last): + ... + GitRepositoryError: Not the toplevel of a Git repository at ... + """ + + +def test_add_files(): + """ + Add some dummy data + + Methods tested: + - L{gbp.git.GitRepository.add_files} + - L{gbp.git.GitRepository.commit_all} + - L{gbp.git.GitRepository.is_clean} + + Properties tested: + - L{gbp.git.GitRepository.head} + + >>> import gbp.git, shutil, os + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> ret = shutil.copy(os.path.join(repo.path, ".git/HEAD"), + ... os.path.join(repo.path, "testfile")) + >>> repo.is_clean()[0] + False + >>> repo.is_clean('doesnotexist')[0] + True + >>> repo.is_clean(paths='testfile')[0] + False + >>> repo.is_clean(paths=['doesnotexist', 'testfile'])[0] + False + >>> repo.is_clean(ignore_untracked=True)[0] + True + >>> repo.add_files(repo.path, force=True) + >>> repo.commit_all(msg="foo") + >>> repo.is_clean()[0] + True + >>> h = repo.head + >>> len(h) + 40 + """ + + +def test_branch_master(): + """ + First branch is called I{master} + + Methods tested: + - L{gbp.git.GitRepository.get_branch} + >>> import gbp.git, shutil + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.get_branch() + 'master' + >>> repo.branch + 'master' + """ + + +def test_clean(): + """ + Remove untracked files from the working tree + + Methods tested: + - L{gbp.git.GitRepository.clean} + + >>> import gbp.git, shutil, os + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> ret = shutil.copy(os.path.join(repo.path, ".git/HEAD"), + ... os.path.join(repo.path, "testclean")) + >>> repo.clean(dry_run=True) + >>> repo.is_clean()[0] + False + >>> repo.clean(directories=True, force=True) + >>> repo.is_clean()[0] + True + """ + + +def test_create_branch(): + """ + Create a branch name I{foo} + + Methods tested: + - L{gbp.git.GitRepository.create_branch} + - L{gbp.git.GitRepository.branch_contains} + + >>> import gbp.git, shutil + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.create_branch("foo") + >>> repo.branch_contains("foo", 'HEAD') + True + >>> repo.branch_contains("doesnotexist", 'HEAD', remote=True) + False + """ + + +def test_delete_branch(): + """ + Create a branch named I{foo2} and delete it + + Methods tested: + - L{gbp.git.GitRepository.create_branch} + - L{gbp.git.GitRepository.delete_branch} + + >>> import gbp.git, shutil + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.create_branch("bar") + >>> repo.delete_branch("bar") + >>> repo.delete_branch("master") + Traceback (most recent call last): + ... + GitRepositoryError: Can't delete the branch you're on + """ + + +def test_set_branch(): + """ + Switch to branch named I{foo} + + Methods tested: + - L{gbp.git.GitRepository.set_branch} + - L{gbp.git.GitRepository.get_branch} + - L{gbp.git.GitRepository.branch} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.set_branch("foo") + >>> repo.get_branch() == "foo" + True + >>> repo.branch == "foo" + True + """ + + +def test_rename_branch(): + """ + Create branch named I{baz}, rename it to I{bax} and finally delete it + + Methods tested: + - L{gbp.git.GitRepository.create_branch} + - L{gbp.git.GitRepository.rename_branch} + - L{gbp.git.GitRepository.delete_branch} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.create_branch("baz") + >>> repo.rename_branch("baz", "bax") + >>> repo.delete_branch("bax") + """ + + +def test_set_upstream_branch(): + """ + Set upstream branch master -> origin/master + + >>> import os, shutil + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> os.makedirs(os.path.join(repo.git_dir, 'refs/remotes/origin')) + >>> ret = shutil.copy(os.path.join(repo.git_dir, 'refs/heads/master'), \ + os.path.join(repo.git_dir, 'refs/remotes/origin/')) + >>> repo.add_remote_repo('origin', 'git://git.example.com/git/origin') + >>> repo.set_upstream_branch('master', 'origin/master') + >>> repo.get_upstream_branch('master') + 'origin/master' + >>> repo.set_upstream_branch('bla', 'origin/master') + Traceback (most recent call last): + GitRepositoryError: Branch bla doesn't exist! + >>> repo.set_upstream_branch('foo', 'origin/bla') + Traceback (most recent call last): + GitRepositoryError: Branch origin/bla doesn't exist! + """ + + +def test_get_upstream_branch(): + """ + Get info about upstream branches set in test_set_upstream_branch + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.get_upstream_branch('master') + 'origin/master' + >>> repo.get_upstream_branch('foo') + '' + >>> repo.get_upstream_branch('bla') + Traceback (most recent call last): + GitRepositoryError: Branch bla doesn't exist! + """ + + +def test_tag(): + """ + Create a tag named I{tag} and check its existance + + Methods tested: + - L{gbp.git.GitRepository.create_tag} + - L{gbp.git.GitRepository.verify_tag} + - L{gbp.git.GitRepository.has_tag} + - L{gbp.git.GitRepository.get_tags} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.create_tag("tag") + >>> repo.has_tag("tag") + True + >>> repo.has_tag("unknown") + False + >>> repo.create_tag("tag2", msg="foo") + >>> repo.has_tag("tag2") + True + >>> repo.verify_tag("tag2") + False + >>> repo.get_tags() + ['tag', 'tag2'] + >>> repo.tags + ['tag', 'tag2'] + """ + + +def test_describe(): + """ + Describe commit-ish + + Methods tested: + - L{gbp.git.GitRepository.describe} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> sha = repo.rev_parse('HEAD') + >>> repo.describe('HEAD') + 'tag2' + >>> repo.describe('HEAD', longfmt=True) == 'tag2-0-g%s' % sha[:7] + True + >>> repo.describe('HEAD', pattern='foo*') + Traceback (most recent call last): + ... + GitRepositoryError: Can't describe HEAD. Git error: fatal: No names found, cannot describe anything. + >>> repo.describe('HEAD', pattern='foo*', always=True) == sha[:7] + True + >>> repo.describe('HEAD', always=True, abbrev=16) + 'tag2' + >>> repo.describe('HEAD', pattern='foo*', always=True, abbrev=16) == sha[:16] + True + >>> tag = repo.describe('HEAD', longfmt=True, abbrev=16) == 'tag2-0-g%s' % sha[:16] + >>> repo.delete_tag('tag2') + >>> repo.describe('HEAD', tags=True) + 'tag' + >>> repo.describe('HEAD', tags=True, exact_match=True) + 'tag' + >>> repo.create_tag('tag2', msg='foo') + """ + + +def test_find_tag(): + """ + Find tags + + Methods tested: + - L{gbp.git.GitRepository.find_tag} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.find_tag('HEAD') + 'tag2' + >>> repo.find_tag('HEAD', pattern='foo*') + Traceback (most recent call last): + ... + GitRepositoryError: Can't describe HEAD. Git error: fatal: No names found, cannot describe anything. + """ + + +def test_find_branch_tag(): + """ + Find the closest tags on a certain branch to a given commit + + Methods tested: + - L{gbp.git.GitRepository.find_branch_tag} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.find_branch_tag('HEAD', 'master', 'tag*') + 'tag2' + >>> repo.find_branch_tag('HEAD', 'master', 'v*') # doctest:+ELLIPSIS + Traceback (most recent call last): + ... + GitRepositoryError: Can't describe .... Git error: fatal: No names found, cannot describe anything. + """ + + +def test_move_tag(): + """ + Move a tag + + Methods tested: + - L{gbp.git.GitRepository.move_tag} + - L{gbp.git.GitRepository.has_tag} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.move_tag("tag", "moved") + >>> repo.has_tag("tag") + False + >>> repo.has_tag("moved") + True + """ + + +def test_delete_tag(): + """ + Delete tags + + Methods tested: + - L{gbp.git.GitRepository.delete_tag} + - L{gbp.git.GitRepository.has_tag} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.has_tag("moved") + True + >>> repo.delete_tag("moved") + >>> repo.has_tag("moved") + False + """ + + +def test_get_obj_type(): + """ + Find commit SHA1 related to tags + + Methods tested: + - L{gbp.git.GitRepository.create_tag} + - L{gbp.git.GitRepository.get_obj_type} + - L{gbp.git.GitRepository.delete_tag} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.create_tag("tag3", "tag msg") + >>> repo.get_obj_type("tag3") + 'tag' + >>> repo.get_obj_type("HEAD") + 'commit' + >>> repo.get_obj_type("HEAD:testfile") + 'blob' + >>> repo.delete_tag("tag3") + """ + + +def test_list_files(): + """ + List files in the index + + Methods tested: + - L{gbp.git.GitRepository.list_files} + - L{gbp.git.GitRepository.add_files} + - L{gbp.git.GitRepository.commit_staged} + - L{gbp.git.GitRepository.commit_files} + - L{gbp.git.GitRepository.force_head} + + >>> import gbp.git, os, shutil + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> src = os.path.join(repo.path, ".git/HEAD") + >>> dst = os.path.join(repo.path, "testfile") + >>> repo.list_files() + ['testfile'] + >>> repo.list_files(['modified']) + [] + >>> repo.list_files(['modified', 'deleted']) + [] + >>> repo.list_files(['modified', 'deleted', 'cached']) + ['testfile'] + >>> ret = shutil.copy(src, dst) + >>> repo.list_files(['modified']) + ['testfile'] + >>> repo.add_files(dst) + >>> repo.commit_staged(msg="foo") + >>> repo.list_files(['modified']) + [] + >>> repo.list_files(['foo']) + Traceback (most recent call last): + ... + GitRepositoryError: Unknown type 'foo' + >>> repo.force_head('HEAD^', hard=True) + >>> repo.list_files(['modified']) + [] + >>> ret = shutil.copy(src, dst) + >>> repo.list_files(['modified']) + ['testfile'] + >>> repo.commit_files(dst, msg="foo") + >>> repo.list_files(['modified']) + [] + """ + + +def test_get_commits(): + """ + Test listing commits + + Methods tested: + - L{gbp.git.GitRepository.get_commits} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> commits = repo.get_commits() + >>> type(commits) == list and len(commits) == 2 + True + >>> len(repo.get_commits(num=1)) == 1 + True + >>> commits2 = repo.get_commits(since='HEAD~1') + >>> len(commits2) == 1 + True + >>> commits2[0] == commits[0] + True + >>> commits2 = repo.get_commits(until='HEAD~1') + >>> len(commits2) == 1 + True + >>> commits2[0] == commits[-1] + True + >>> repo.get_commits(paths=['foo', 'bar']) + [] + >>> repo.get_commits(paths=['testfile']) == commits + True + """ + + +def test_get_commit_info(): + """ + Test inspecting commits + + Methods tested: + - L{gbp.git.GitRepository.get_commit_info} + + >>> import gbp.git + >>> from datetime import datetime + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> info = repo.get_commit_info('HEAD') + >>> info['id'] + 'HEAD' + >>> info['body'] + '' + >>> info['subject'] + 'foo' + >>> '@' in info['author'].email + True + >>> '@' in info['committer'].email + True + >>> now = datetime.now() + >>> (now - datetime.fromtimestamp(int(info['author'].date.split()[0]))).seconds < 10 + True + >>> (now - datetime.fromtimestamp(int(info['committer'].date.split()[0]))).seconds < 10 + True + >>> info['patchname'] + 'foo' + >>> info['files'] # doctest:+ELLIPSIS + defaultdict(<... 'list'>, {'M': ['testfile']}) + >>> repo.get_subject('HEAD') + 'foo' + """ + + +def test_diff(): + """ + Test git-diff + + Methods tested: + - L{gbp.git.GitRepository.diff} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> len(repo.diff('HEAD~1', 'HEAD')) > 3 + True + >>> len(repo.diff('HEAD~1', 'HEAD', 'testfile')) > 3 + True + >>> len(repo.diff('HEAD~1', 'HEAD', 'testfile', text=True)) > 3 + True + >>> len(repo.diff('HEAD~1', 'HEAD', 'filenotexist')) == 0 + True + >>> repo.diff('HEAD~1', 'HEAD') == repo.diff('HEAD~1') + True + """ + + +def test_diff_status(): + """ + Methods tested: + - L{gbp.git.GitRepository.diff_status} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.diff_status("HEAD", "HEAD") # doctest:+ELLIPSIS + defaultdict(<... 'list'>, {}) + >>> repo.diff_status("HEAD~1", "HEAD") # doctest:+ELLIPSIS + defaultdict(<... 'list'>, {'M': ['testfile']}) + """ + + +def test_mirror_clone(): + """ + Mirror a repository + + Methods tested: + - L{gbp.git.GitRepository.clone} + - L{gbp.git.GitRepository.is_empty} + - L{gbp.git.GitRepository.set_branch} + - L{gbp.git.GitRepository.has_branch} + - L{gbp.git.GitRepository.branch} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.set_branch('master') + >>> mirror = gbp.git.GitRepository.clone(dirs['mirror_clone'], repo.path, mirror=True) + >>> mirror.is_empty() + False + >>> mirror.branch + 'master' + >>> mirror.has_branch('foo') + True + >>> mirror.has_branch('bar') + False + >>> mirror.set_branch('foo') + >>> mirror.branch + 'foo' + >>> mirror.force_head('foo^') + """ + + +def test_clone(): + """ + Clone a repository + + Methods tested: + - L{gbp.git.GitRepository.clone} + - L{gbp.git.GitRepository.is_empty} + - L{gbp.git.GitRepository.set_branch} + - L{gbp.git.GitRepository.branch} + - L{gbp.git.GitRepository.get_merge_branch} + - L{gbp.git.GitRepository.get_remote_branches} + - L{gbp.git.GitRepository.get_local_branches} + - L{gbp.git.GitRepository.get_remote_repos} + - L{gbp.git.GitRepository.has_remote_repo} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.set_branch('master') + >>> clone = gbp.git.GitRepository.clone(dirs['clone'], repo.path) + >>> clone.is_empty() + False + >>> clone.branch + 'master' + >>> clone.get_remote_branches() + ['origin/HEAD', 'origin/foo', 'origin/master'] + >>> clone.get_local_branches() + ['master'] + >>> clone.get_merge_branch('master') + 'origin/master' + >>> clone.create_branch('foo', 'origin/foo') + >>> clone.get_merge_branch('foo') + 'origin/foo' + >>> clone.create_branch('bar') + >>> clone.get_merge_branch('bar') # None if no merge branch exists + >>> clone.get_local_branches() + ['bar', 'foo', 'master'] + >>> clone.get_remote_repos() + ['origin'] + >>> clone.has_remote_repo('origin') + True + >>> clone.has_branch('origin/master', remote=True) + True + >>> clone.has_remote_repo('godiug') + False + """ + + +def test_get_remotes(): + """ + Merge a branch + + Methods tested: + - L{gbp.git.GitRepository.get_remotes} + + >>> import os + >>> import gbp.git.repository + >>> repo = gbp.git.repository.GitRepository(os.path.join(dirs['clone'], 'repo')) + >>> remotes = repo.get_remotes() + >>> len(remotes) + 1 + >>> origin = remotes['origin'] + >>> origin.name + 'origin' + >>> origin.fetch_url == dirs['repo'] + True + >>> origin.push_urls == [dirs['repo']] + True + """ + + +def test_merge(): + """ + Merge a branch + + Methods tested: + - L{gbp.git.GitRepository.merge} + - L{gbp.git.GitRepository.set_branch} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.set_branch('master') + >>> repo.merge('foo') + """ + + +def test_pull(): + """ + Pull from a remote repository + + Methods tested: + - L{gbp.git.GitRepository.set_branch} + - L{gbp.git.GitRepository.pull} + + >>> import gbp.git, os + >>> d = os.path.join(dirs['clone'], 'repo') + >>> clone = gbp.git.GitRepository(d) + >>> clone.set_branch('master') + >>> clone.pull() + >>> clone.pull(all_remotes=True) + >>> clone.pull('origin', all_remotes=True) + """ + + +def test_fetch(): + """ + Fetch from a remote repository + + Methods tested: + - L{gbp.git.GitRepository.fetch} + - L{gbp.git.GitRepository.push} + - L{gbp.git.GitRepository.push_tag} + - L{gbp.git.GitRepository.add_remote_repo} + - L{gbp.git.GitRepository.remove_remote_repo} + + >>> import gbp.git, os + >>> d = os.path.join(dirs['clone'], 'repo') + >>> clone = gbp.git.GitRepository(d) + >>> clone.fetch() + >>> clone.push() + >>> clone.push('origin', dry_run=True) + >>> clone.push('origin') + >>> clone.push('origin', 'master') + >>> clone.push('origin', 'master', force=True) + >>> clone.create_tag('tag3') + >>> clone.push_tag('origin', 'tag3', True) + >>> clone.push_tag('origin', 'tag3') + >>> clone.create_tag('tag4') + >>> clone.push('origin', 'master', tags=True) + >>> clone.add_remote_repo('foo', dirs['repo']) + >>> clone.fetch('foo') + >>> clone.fetch('foo', tags=True) + >>> clone.fetch('foo', refspec='refs/heads/master') + >>> clone.fetch(all_remotes=True) + >>> clone.remove_remote_repo('foo') + """ + + +def test_create_bare(): + """ + Create a bare repository + + Methods tested: + - L{gbp.git.GitRepository.create} + - L{gbp.git.GitRepository.is_empty} + + >>> import gbp.git + >>> bare = gbp.git.GitRepository.create(dirs['bare'], bare=True, description="msg") + >>> bare.path == dirs['bare'] + True + >>> bare.git_dir == dirs['bare'] + True + >>> type(bare) == gbp.git.GitRepository + True + >>> bare.is_empty() + True + >>> bare.is_clean() + (True, '') + """ + + +def test_nonexistent(): + """ + Check that accessing a non-existent repository fails. + + Methods tested: + - L{gbp.git.GitRepository.__init__} + + >>> import gbp.git + >>> bare = gbp.git.GitRepository("/does/not/exist") + Traceback (most recent call last): + ... + GitRepositoryError: No Git repository at '/does/not/exist' + """ + + +def test_create_noperm(): + """ + Check that creating a repository at a path that isn't writeable fails + + Methods tested: + - L{gbp.git.GitRepository.create} + + >>> import gbp.git + >>> gbp.git.GitRepository.create("/does/not/exist") + Traceback (most recent call last): + ... + GitRepositoryError: Cannot create Git repository at '/does/not/exist': Permission denied + """ + + +def test_checkout(): + """ + Checkout treeishs + + Methods tested: + - L{gbp.git.GitRepository.checkout} + - L{gbp.git.GitRepository.get_branch} + - L{gbp.git.GitRepository.set_branch} + - L{gbp.git.GitRepository.rev_parse} + + Properties tested: + - L{gbp.git.GitRepository.branch} + - L{gbp.git.GitRepository.tags} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.checkout('master') + >>> repo.branch + 'master' + >>> repo.rev_parse('doesnotexist') + Traceback (most recent call last): + ... + GitRepositoryError: revision 'doesnotexist' not found + >>> sha1 = repo.rev_parse('master', short=10) + >>> len(sha1) + 10 + >>> sha1 = repo.rev_parse('master') + >>> len(sha1) + 40 + >>> repo.checkout(sha1) + >>> repo.branch + >>> repo.get_branch() + Traceback (most recent call last): + ... + GitRepositoryError: Currently not on a branch + >>> tag = repo.tags[0] + >>> repo.checkout(tag) + >>> repo.branch + """ + + +def test_gc(): + """ + Test garbage collection + + Methods tested: + - L{gbp.git.GitRepository.collect_garbage} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.collect_garbage() + >>> repo.collect_garbage(prune=True) + >>> repo.collect_garbage(prune='all', aggressive=True) + """ + + +def test_grep_log(): + """ + Test grepping through commit messages + + Methods tested: + - L{gbp.git.GitRepository.grep_log} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.set_branch('master') + >>> len(repo.grep_log('foo')) == 2 + True + >>> len(repo.grep_log('foo', 'master')) == 2 + True + >>> repo.grep_log('blafasel') + [] + >>> repo.grep_log('foo', 'doesnotexist') + Traceback (most recent call last): + ... + GitRepositoryError: Error grepping log for foo: fatal: bad revision 'doesnotexist' + """ + + +def test_is_ff(): + """ + Test if branch is fast forwardable + + Methods tested: + - L{gbp.git.GitRepository.is_fast_forward} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.is_fast_forward('master', 'foo') + (True, True) + >>> repo.create_branch('ff', 'HEAD^') + >>> repo.is_fast_forward('ff', 'master') + (True, False) + >>> repo.is_fast_forward('master', 'ff') + (False, True) + """ + + +def test_update_ref(): + """ + Test updating a reference + + Methods tested: + - L{gbp.git.GitRepository.update_ref} + + >>> import gbp.git, os + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.update_ref('new_ref', 'master', msg='update') + >>> os.path.exists(os.path.join(repo.git_dir, 'new_ref')) + True + """ + + +def test_make_tree(): + """ + Test git-mk-tree + + Methods tested: + - L{gbp.git.GitRepository.write_file} + - L{gbp.git.GitRepository.list_tree} + - L{gbp.git.GitRepository.make_tree} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> sha1 = repo.write_file('testfile') + >>> sha1 + '19af7398c894bc5e86e17259317e4db519e9241f' + >>> head = repo.list_tree('HEAD') + >>> head + [['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile']] + >>> head.append(['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile2']) + >>> newtree = repo.make_tree(head) + >>> newtree + '745951810c9e22fcc6de9b23f05efd6ab5512123' + >>> repo.list_tree(newtree, recurse=False, paths='testfile') + [['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile']] + >>> repo.make_tree([]) + '4b825dc642cb6eb9a060e54bf8d69288fbee4904' + """ + + +def test_update_submodules(): + """ + Updating submodules if we don't have any is a noop + + Methods tested: + - L{gbp.git.GitRepository.has_submodules} + - L{gbp.git.GitRepository.update_submodules} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.has_submodules() + False + >>> repo.update_submodules() + """ + + +def test_get_merge_base(): + """ + Find the common ancestor of two objects + + Methods tested: + - L{gbp.git.GitRepository.get_merge_base} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> sha1 = repo.get_merge_base('master', 'foo') + >>> len(sha1) + 40 + >>> repo.get_merge_base('master', 'doesnotexist') + Traceback (most recent call last): + ... + GitRepositoryError: Failed to get common ancestor: fatal: Not a valid object name doesnotexist + """ + + +def test_status(): + r""" + Methods tested: + - L{gbp.git.GitRepository.status} + + >>> import gbp.git, os, shutil + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> fname = os.path.join(repo.path, "test_status") + >>> ret = shutil.copy(os.path.join(repo.path, ".git/HEAD"), fname) + >>> list(repo.status().items()) + [('??', ['test_status'])] + >>> list(repo.status(['bla*']).items()) + [] + >>> list(repo.status(['te*']).items()) + [('??', ['test_status'])] + >>> repo.add_files(repo.path, force=True) + >>> repo.commit_all(msg='added %s' % fname) + >>> _ = repo._git_inout('mv', [fname, fname + 'new']) + >>> list(repo.status().items()) + [('R ', ['test_status\x00test_statusnew'])] + """ + + +def test_cmd_has_feature(): + r""" + Methods tested: + - L{gbp.git.GitRepository._cmd_has_feature} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo._cmd_has_feature("commit", "a") + True + >>> repo._cmd_has_feature("commit", "reuse-message") + True + >>> repo._cmd_has_feature("merge", "n") + True + >>> repo._cmd_has_feature("merge", "stat") + True + >>> repo._cmd_has_feature("format-patch", "cc") + True + >>> repo._cmd_has_feature("merge", "foobaroption") + False + >>> repo._cmd_has_feature("foobarcmd", "foobaroption") + Traceback (most recent call last): + ... + GitRepositoryError: Invalid git command 'foobarcmd': No manual entry for gitfoobarcmd + >>> repo._cmd_has_feature("show", "standard-notes") + True + >>> repo._cmd_has_feature("show", "no-standard-notes") + True + """ + + +def test_set_user_name_and_email(): + r""" + Methods tested: + - L{gbp.git.GitRepository.set_user_name} + - L{gbp.git.GitRepository.set_user_email} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(dirs['repo']) + >>> repo.set_user_name("Michael Stapelberg") + >>> repo.set_user_email("stapelberg@test.invalid") + """ + + +def test_git_dir(): + """ + Properties tested: + - L{gbp.git.GitRepository.git_dir} + >>> import os, gbp.git + >>> git_dir = os.path.join(dirs['repo'], '.git') + >>> os.environ['GIT_DIR'] = git_dir + >>> somewhere = gbp.git.GitRepository(os.path.join(dirs['repo'], '..')) + >>> somewhere.git_dir == git_dir + True + >>> del os.environ['GIT_DIR'] + """ + +# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_GitVfs.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_GitVfs.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_GitVfs.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_GitVfs.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,78 @@ +# vim: set fileencoding=utf-8 : + +""" +Test L{gbp.git.GitVfs} +""" + +import os +import gbp.log + +from .. import context # noqa: F401 + +gbp.log.setup(color=False, verbose=True) + + +def setup_repo(): + repo_dir = context.new_tmpdir(__name__) + repo = gbp.git.GitRepository.create(str(repo_dir)) + content = 'al pha\na\nb\nc' + with open(os.path.join(repo.path, 'foo.txt'), 'w') as f: + f.write(content) + repo.add_files(repo.path, force=True) + repo.commit_all(msg="foo") + return (repo, content) + + +def test_read(): + """ + Create a repository + + Methods tested: + - L{gbp.git.GitVfs.open} + - L{gbp.git.GitVfs._File.readline} + - L{gbp.git.GitVfs._File.readlines} + - L{gbp.git.GitVfs._File.read} + - L{gbp.git.GitVfs._File.close} + + >>> import gbp.git.vfs + >>> (repo, content) = setup_repo() + >>> vfs = gbp.git.vfs.GitVfs(repo, 'HEAD') + >>> gf = vfs.open('foo.txt') + >>> gf.readline() + 'al pha\\n' + >>> gf.readline() + 'a\\n' + >>> gf.readlines() + ['b\\n', 'c'] + >>> gf.readlines() + [] + >>> gf.readline() + '' + >>> gf.readline() + '' + >>> gf.close() + >>> gbp.git.vfs.GitVfs(repo, 'HEAD').open('foo.txt').read() == content + True + >>> gf = vfs.open('doesnotexist') + Traceback (most recent call last): + ... + IOError: can't get HEAD:doesnotexist: fatal: Path 'doesnotexist' does not exist in 'HEAD' + >>> context.teardown() + """ + + +def test_content_manager(): + """ + Create a repository + + Methods tested: + - L{gbp.git.GitVfs.open} + + >>> import gbp.git.vfs + >>> (repo, content) = setup_repo() + >>> vfs = gbp.git.vfs.GitVfs(repo, 'HEAD') + >>> with vfs.open('foo.txt') as gf: + ... data = gf.readlines() + >>> data + ['al pha\\n', 'a\\n', 'b\\n', 'c'] + """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_PristineTar.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_PristineTar.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/doctests/test_PristineTar.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/doctests/test_PristineTar.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,173 @@ +# vim: set fileencoding=utf-8 : +""" +Test pristine-tar related methods in + + - L{gbp.deb.DebianPristineTar} + +and + + - L{gbp.deb.git.DebianGitRepository} + +This testcase creates this reposity: + + - A repository at I{dirs['repo']} called I{repo} + +""" + +import os +from .. import context + +test_data = os.path.join(context.projectdir, "tests/test_PristineTar_data") +dirs = {} + + +def setup_module(): + dirs['repo'] = context.new_tmpdir(__name__).join('repo') + + +def teardown_module(): + del dirs['repo'] + context.teardown() + + +def test_create(): + """ + Create a repository + + Methods tested: + - L{gbp.deb.git.DebianGitRepository.create} + + >>> import os, gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository.create(dirs['repo']) + """ + + +def test_empty_repo(): + """ + Empty repos have no branch pristine-tar branch + + Methods tested: + - L{gbp.deb.git.DebianGitRepository.has_pristine_tar_branch} + - L{gbp.deb.pristinetar.DebianPristineTar.has_commit} + + >>> import gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) + >>> repo.has_pristine_tar_branch() + False + >>> repo.pristine_tar.has_commit('upstream', '1.0', 'gzip') + False + """ + + +def test_commit_dir(): + """ + Empty repos have no branch pristine-tar branch + + Methods tested: + - L{gbp.git.repository.GitRepository.commit_dir} + - L{gbp.git.repository.GitRepository.create_branch} + + >>> import gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) + >>> commit = repo.commit_dir(test_data, msg="initial commit", branch=None) + >>> repo.create_branch('upstream') + """ + + +def test_create_tarball(): + """ + Create a tarball from a git tree + + Methods tested: + - L{gbp.deb.git.DebianGitRepository.archive} + + >>> import gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) + >>> repo.archive('tar', 'upstream/', '../upstream_1.0.orig.tar', 'upstream') + >>> gbp.command_wrappers.Command('gzip', [ '-n', '%s/../upstream_1.0.orig.tar' % dirs['repo']])() + """ + + +def test_pristine_tar_commit(): + """ + Commit the delta to the pristine-tar branch + + Methods tested: + - L{gbp.deb.pristinetar.DebianPristineTar.commit} + + >>> import gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) + >>> repo.pristine_tar.commit('../upstream_1.0.orig.tar.gz', 'upstream') + """ + + +def test_pristine_has_commit(): + """ + Find delta on the pristine tar branch + + Methods tested: + - L{gbp.deb.pristinetar.DebianPristineTar.has_commit} + - L{gbp.pkg.pristinetar.PristineTar.get_commit} + + >>> import gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) + >>> repo.pristine_tar.has_commit('upstream', '1.0', 'bzip2') + False + >>> repo.pristine_tar.has_commit('upstream', '1.0', 'gzip') + True + >>> repo.pristine_tar.has_commit('upstream', '1.0') + True + >>> branch = repo.rev_parse('pristine-tar') + >>> commit = repo.pristine_tar.get_commit('upstream_1.0.orig.tar.gz') + >>> branch == commit + True + """ + + +def test_pristine_tar_checkout(): + """ + Checkout a tarball using pristine-tar + + Methods tested: + - L{gbp.deb.pristinetar.DebianPristineTar.checkout} + + >>> import gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) + >>> repo.pristine_tar.checkout('upstream', '1.0', 'gzip', '..') + """ + + +def test_pristine_tar_verify(): + """ + Verify a tarball using pristine-tar + + Methods tested: + - L{gbp.deb.pristinetar.DebianPristineTar.verify} + + >>> import gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) + >>> repo.pristine_tar.verify('../upstream_1.0.orig.tar.gz') + """ + + +def test_pristine_tar_checkout_nonexistent(): + """ + Checkout a tarball that does not exist using pristine-tar + + Methods tested: + - L{gbp.deb.pristinetar.DebianPristineTar.checkout} + + # Silence error output + >>> import gbp.deb.git + >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) + >>> _gbp_log_err_bak = gbp.log.err + >>> gbp.log.err = lambda x: None + >>> repo.pristine_tar.checkout('upstream', '1.1', 'gzip', '..') + Traceback (most recent call last): + ... + CommandExecFailed: Pristine-tar couldn't checkout "upstream_1.1.orig.tar.gz": fatal: Path 'upstream_1.1.orig.tar.gz.delta' does not exist in 'refs/heads/pristine-tar' + pristine-tar: git show refs/heads/pristine-tar:upstream_1.1.orig.tar.gz.delta failed + >>> gbp.log.err = _gbp_log_err_bak + """ + +# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/helpers/run-in-docker git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/helpers/run-in-docker --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/helpers/run-in-docker 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/helpers/run-in-docker 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,31 @@ +#!/bin/sh + +set -eu + +echo $(pwd) +cat >Dockerfile < /etc/apt/sources.list +RUN apt-get update && apt-get dist-upgrade --yes +RUN apt-get install -y --no-install-recommends build-essential adduser +RUN adduser gbp --disabled-password --gecos='gbp docker test user' --shell=/bin/bash --home /git-buildpackage + +WORKDIR /git-buildpackage +COPY . . +RUN chown -R gbp: . + +RUN apt-get -y build-dep . +# Run as non root so permision tests pass +CMD su -c "make all+net" gbp +EOF + +CIDFILE="$(mktemp --dry-run)" +TAG="git-buildpackage/sid" +echo "Building Docker image ${TAG}" +docker build . --tag=${TAG} +docker run --cidfile=${CIDFILE} ${TAG} + +docker rm "$(cat ${CIDFILE})" >/dev/null +rm -f "${CIDFILE}" + diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_Changelog.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_Changelog.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_Changelog.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_Changelog.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,311 +0,0 @@ -# vim: set fileencoding=utf-8 : - -""" -Test L{gbp.deb.changelog.ChangeLog} -""" -from . import context -import os -import nose - -cl_debian = """git-buildpackage (0.5.32) unstable; urgency=low - - * [efe9220] Use known_compressions in guess_upstream_version too - (Closes: #645477) - * [e984baf] git-import-orig: fix --filter - - -- Guido Günther Mon, 17 Oct 2011 10:15:22 +0200 - -git-buildpackage (0.5.31) unstable; urgency=low - - [ Guido Günther ] - * [3588d88] Fix pristine-tar error message - * [8da98da] gbp-pq: don't fail on missing series file but create an empty - branch instead - - [ Salvatore Bonaccorso ] - * [b33cf74] Fix URL to cl2vcs service. - Refer to https://honk.sigxcpu.org/cl2vcs instead of - https://honk.sigxcpu.org/cl2vcs for the cl2vcs service. (Closes: #640141) - - -- Guido Günther Wed, 28 Sep 2011 20:21:34 +0200 -""" - -cl_upstream="""python-dateutil (1.0-1) unstable; urgency=low - - * Initial release (Closes: #386256) - - -- Guido Günther Wed, 6 Sep 2006 10:33:06 +0200 -""" - -cl_epoch="""xserver-xorg-video-nv (1:1.2.0-3) unstable; urgency=low - - [ Steve Langasek ] - * Upload to unstable - - -- David Nusinow Mon, 18 Sep 2006 19:57:45 -0400 -""" - -def setup(): - """Setup test module""" - if not os.path.exists('/usr/bin/debchange'): - raise nose.SkipTest('debchange tool not present') - -def test_parse_debian_only(): - """ - Parse a the changelog of debian only package - - Methods tested: - - L{gbp.deb.changelog.ChangeLog.__init__} - - Properties tested: - - L{gbp.deb.changelog.ChangeLog.version} - - L{gbp.deb.changelog.ChangeLog.debian_version} - - L{gbp.deb.changelog.ChangeLog.upstream_version} - - L{gbp.deb.changelog.ChangeLog.epoch} - - L{gbp.deb.changelog.ChangeLog.noepoch} - - >>> import gbp.deb.changelog - >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) - >>> cl.version - '0.5.32' - >>> cl.version == cl['Version'] - True - >>> cl.debian_version - '0.5.32' - >>> cl.debian_version == cl['Debian-Version'] - True - >>> cl.noepoch - '0.5.32' - >>> cl.noepoch == cl['NoEpoch-Version'] - True - >>> cl.epoch - >>> cl.upstream_version - """ - -def test_parse_no_eopch(): - """ - Parse a the changelog of a package without eopch - - Methods tested: - - L{gbp.deb.changelog.ChangeLog.__init__} - - L{gbp.deb.changelog.ChangeLog.has_epoch} - - Properties tested: - - L{gbp.deb.changelog.ChangeLog.version} - - L{gbp.deb.changelog.ChangeLog.debian_version} - - L{gbp.deb.changelog.ChangeLog.upstream_version} - - L{gbp.deb.changelog.ChangeLog.epoch} - - L{gbp.deb.changelog.ChangeLog.noepoch} - - >>> import gbp.deb.changelog - >>> cl = gbp.deb.changelog.ChangeLog(cl_upstream) - >>> cl.version - '1.0-1' - >>> cl.version == cl['Version'] - True - >>> cl.debian_version - '1' - >>> cl.debian_version == cl['Debian-Version'] - True - >>> cl.noepoch - '1.0-1' - >>> cl.noepoch == cl['NoEpoch-Version'] - True - >>> cl.epoch - >>> cl.upstream_version - '1.0' - >>> cl.has_epoch() - False - """ - -def test_parse_eopch(): - """ - Parse a the changelog of a package without epoch - - Methods tested: - - L{gbp.deb.changelog.ChangeLog.__init__} - - L{gbp.deb.changelog.ChangeLog.has_epoch} - - Properties tested: - - L{gbp.deb.changelog.ChangeLog.version} - - L{gbp.deb.changelog.ChangeLog.debian_version} - - L{gbp.deb.changelog.ChangeLog.upstream_version} - - L{gbp.deb.changelog.ChangeLog.epoch} - - L{gbp.deb.changelog.ChangeLog.noepoch} - - >>> import gbp.deb.changelog - >>> cl = gbp.deb.changelog.ChangeLog(cl_epoch) - >>> cl.version - '1:1.2.0-3' - >>> cl.version == cl['Version'] - True - >>> cl.debian_version - '3' - >>> cl.debian_version == cl['Debian-Version'] - True - >>> cl.noepoch - '1.2.0-3' - >>> cl.noepoch == cl['NoEpoch-Version'] - True - >>> cl.epoch - '1' - >>> cl.upstream_version - '1.2.0' - >>> cl.has_epoch() - True - """ - -def test_parse_name(): - """ - Methods tested: - - L{gbp.deb.changelog.ChangeLog.__init__} - - Properties tested: - - L{gbp.deb.changelog.ChangeLog.name} - - >>> import gbp.deb.changelog - >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) - >>> cl.name - 'git-buildpackage' - """ - -def test_parse_last_mod(): - """ - Test author, email and date of last modification - - Methods tested: - - L{gbp.deb.changelog.ChangeLog.__init__} - - Properties tested: - - L{gbp.deb.changelog.ChangeLog.name} - - L{gbp.deb.changelog.ChangeLog.email} - - L{gbp.deb.changelog.ChangeLog.date} - - >>> import gbp.deb.changelog - >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) - >>> cl.author.startswith('Guido') - True - >>> cl.email - 'agx@sigxcpu.org' - >>> cl.date - 'Mon, 17 Oct 2011 10:15:22 +0200' - """ - -def test_parse_sections(): - """ - Test if we can parse sections out of the changelog - - Methods tested: - - L{gbp.deb.changelog.ChangeLog.__init__} - - L{gbp.deb.changelog.ChangeLogSection.__init__} - - L{gbp.deb.changelog.ChangeLogSection.parse} - - Properties tested: - - L{gbp.deb.changelog.ChangeLog.sections} - - >>> import gbp.deb.changelog - >>> cl = gbp.deb.changelog.ChangeLog(cl_debian) - >>> cl.sections[0].package - 'git-buildpackage' - >>> cl.sections[0].version - '0.5.32' - >>> cl.sections[1].package - 'git-buildpackage' - >>> cl.sections[1].version - '0.5.31' - """ - -def test_add_section(): - """ - Test if we can add a section to an existant changelog - - Methods tested: - - L{gbp.deb.changelog.ChangeLog.__init__} - - L{gbp.deb.changelog.ChangeLog._parse} - - L{gbp.deb.changelog.ChangeLog.add_section} - - L{gbp.deb.changelog.ChangeLog.spawn_dch} - - >>> import os - >>> import tempfile - >>> import shutil - >>> import gbp.deb.changelog - >>> from .testutils import OsReleaseFile - >>> os_release = OsReleaseFile('/etc/lsb-release') - >>> olddir = os.path.abspath(os.path.curdir) - >>> testdir = tempfile.mkdtemp(prefix='gbp-test-changelog-') - >>> testdebdir = os.path.join(testdir, 'debian') - >>> testclname = os.path.join(testdebdir, "changelog") - >>> os.mkdir(testdebdir) - >>> clh = open(os.path.join(testdebdir, "changelog"), "w") - >>> ret = clh.write(cl_debian) - >>> clh.close() - >>> os.chdir(testdir) - >>> os.path.abspath(os.path.curdir) == testdir - True - >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) - >>> cl.add_section(msg=["Test add section"], distribution=None, author="Debian Maintainer", email="maint@debian.org") - >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) - >>> version = '0.5.32ubuntu1' if os_release['DISTRIB_ID'] == 'Ubuntu' else '0.5.33' - >>> cl.version == version - True - >>> cl.debian_version == version - True - >>> distributions = ['UNRELEASED', os_release['DISTRIB_CODENAME'] or 'unstable'] - >>> cl['Distribution'] in distributions - True - >>> 'Test add section' in cl['Changes'] - True - >>> os.chdir(olddir) - >>> os.path.abspath(os.path.curdir) == olddir - True - >>> shutil.rmtree(testdir, ignore_errors=True) - """ - -def test_add_entry(): - """ - Test if we can add an entry to an existant changelog - - Methods tested: - - L{gbp.deb.changelog.ChangeLog.__init__} - - L{gbp.deb.changelog.ChangeLog._parse} - - L{gbp.deb.changelog.ChangeLog.add_entry} - - L{gbp.deb.changelog.ChangeLog.spawn_dch} - - >>> import os - >>> import tempfile - >>> import shutil - >>> import gbp.deb.changelog - >>> from .testutils import OsReleaseFile - >>> os_release = OsReleaseFile('/etc/lsb-release') - >>> olddir = os.path.abspath(os.path.curdir) - >>> testdir = tempfile.mkdtemp(prefix='gbp-test-changelog-') - >>> testdebdir = os.path.join(testdir, 'debian') - >>> testclname = os.path.join(testdebdir, "changelog") - >>> os.mkdir(testdebdir) - >>> clh = open(os.path.join(testdebdir, "changelog"), "w") - >>> ret = clh.write(cl_debian) - >>> clh.close() - >>> os.chdir(testdir) - >>> os.path.abspath(os.path.curdir) == testdir - True - >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) - >>> cl.add_section(msg=["Test add section"], distribution=None, author="Debian Maintainer", email="maint@debian.org") - >>> cl.add_entry(msg=["Test add entry"], author="Debian Maintainer", email="maint@debian.org") - >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) - >>> version = '0.5.32ubuntu1' if os_release['DISTRIB_ID'] == 'Ubuntu' else '0.5.33' - >>> cl.version == version - True - >>> cl.debian_version == version - True - >>> distributions = ['UNRELEASED', os_release['DISTRIB_CODENAME'] or 'unstable'] - >>> cl['Distribution'] in distributions - True - >>> 'Test add entry' in cl['Changes'] - True - >>> cl['Changes'].split('*',1)[1] - ' Test add section\\n * Test add entry' - >>> os.chdir(olddir) - >>> os.path.abspath(os.path.curdir) == olddir - True - >>> shutil.rmtree(testdir, ignore_errors=True) - """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_Config.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_Config.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_Config.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_Config.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -# vim: set fileencoding=utf-8 : - -""" -Test L{gbp.config.GbpOptionParser} -Test L{gbp.config.GbpOptionParserDebian} -""" - -from . import context - -def test_option_parser(): - """ - Methods tested: - - L{gbp.config.GbpOptionParser.add_config_file_option} - - L{gbp.config.GbpOptionParser.add_boolean_config_file_option} - - >>> import gbp.config - >>> c = gbp.config.GbpOptionParser('common', prefix='test') - >>> c.add_config_file_option(option_name='upstream-branch', dest='upstream') - >>> c.add_boolean_config_file_option(option_name='overlay', dest='overlay') - >>> c.add_boolean_config_file_option(option_name='track', dest='track') - """ - -def test_option_parser_debian(): - """ - Methods tested: - - L{gbp.config.GbpOptionParserDebian.add_config_file_option} - - >>> import gbp.config - >>> c = gbp.config.GbpOptionParserDebian('debian') - >>> c.add_config_file_option(option_name='builder', dest='builder') - Traceback (most recent call last): - ... - KeyError: 'builder' - >>> c.add_config_file_option(option_name='builder', dest='builder', help='foo') - """ - -def test_option_group(): - """ - Methods tested: - - L{gbp.config.GbpOptionGroup.add_config_file_option} - - L{gbp.config.GbpOptionGroup.add_boolean_config_file_option} - - >>> import gbp.config - >>> c = gbp.config.GbpOptionParser('debian') - >>> g = gbp.config.GbpOptionGroup(c, 'wheezy') - >>> g.add_config_file_option(option_name='debian-branch', dest='branch') - >>> g.add_boolean_config_file_option(option_name='track', dest='track') - """ - -def test_tristate(): - """ - Methods tested: - - L{gbp.config.GbpOptionParser.add_config_file_option} - - >>> import gbp.config - >>> c = gbp.config.GbpOptionParser('tristate') - >>> c.add_config_file_option(option_name="color", dest="color", type='tristate') - >>> options, args= c.parse_args(['--color=auto']) - >>> options.color - auto - """ - -def test_filter(): - """ - The filter option should always parse as a list - >>> import os - >>> from gbp.config import GbpOptionParser - >>> tmpdir = str(context.new_tmpdir('bar')) - >>> confname = os.path.join(tmpdir, 'gbp.conf') - >>> GbpOptionParser._set_config_file_value('bar', 'filter', 'asdf', filename=confname) - >>> os.environ['GBP_CONF_FILES'] = confname - >>> parser = GbpOptionParser('bar') - >>> parser.config['filter'] - ['asdf'] - >>> f = open(confname, 'w') - >>> ret = f.write("[bar]\\nfilter = ['this', 'is', 'a', 'list']\\n") - >>> f.close() - >>> parser = GbpOptionParser('bar') - >>> parser.config['filter'] - ['this', 'is', 'a', 'list'] - >>> del os.environ['GBP_CONF_FILES'] - """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_Control.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_Control.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_Control.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_Control.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -# vim: set fileencoding=utf-8 : - -""" -Test L{gbp.deb.control.Control} -""" - -from . import context - -cl_debian = """Source: git-buildpackage -Section: vcs -Priority: optional -Maintainer: Guido Günther -Build-Depends: debhelper (>= 7.0.50~), python (>> 2.6.6-3~), - pychecker, gtk-doc-tools, sgml2x, docbook-utils, jade, python-dateutil, python-nose, - bash-completion, perl, python-epydoc, python-coverage, python-setuptools, - # For the testsuite - git (>= 1:1.7.9.1-1~), bzip2, unzip, pristine-tar -Standards-Version: 3.9.3 -Vcs-Git: git://honk.sigxcpu.org/git/git-buildpackage.git -Vcs-Browser: http://git.debian.org/?p=users/agx/git-buildpackage.git -Homepage: https://honk.sigxcpu.org/piki/projects/git-buildpackage/ -X-Python-Version: >= 2.6 - -Package: git-buildpackage -Architecture: all -Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, devscripts (>= 2.10.66~), - git (>= 1:1.7.9.1-1~), python-dateutil -Recommends: pristine-tar (>= 0.5), cowbuilder -Suggests: python-notify, unzip -Description: Suite to help with Debian packages in Git repositories - This package contains the following tools: - * git-import-{dsc,dscs}: import existing Debian source packages into a git - repository - * git-import-orig: import a new upstream version into the git repository - * git-buildpackage: build a package out of a git repository, check for local - modifications and tag appropriately - * git-dch: generate Debian changelog entries from Git commit messages - * gbp-{pull,clone}: clone and pull from remote repos - * gbp-pq: manage debian/patches easily - * gbp-create-remote-repo: create remote repositories -""" - -def test_parse_control(): - """ - Parse a the control of debian package - - Methods tested: - - L{gbp.deb.control.Control.__init__} - - Properties tested: - - L{gbp.deb.control.Control.name} - - L{gbp.deb.control.Control.section} - - L{gbp.deb.control.Control.priority} - - >>> import gbp.deb.control - >>> cl = gbp.deb.control.Control(cl_debian) - >>> cl.name - 'git-buildpackage' - >>> cl.name == cl['Source'] - True - >>> cl.section - 'vcs' - >>> cl.section == cl['Section'] - True - >>> cl.priority - 'optional' - >>> cl.priority == cl['Priority'] - True - >>> cl['Standards-Version'] - '3.9.3' - >>> cl['Package'] - - """ - -def test_no_control_error(): - """ - Raise an error if no control file exist or is empty - - Methods tested: - - L{gbp.deb.control.Control.__init__} - - >>> import gbp.deb.control - >>> cl = gbp.deb.control.Control(filename="doesnotexist") - Traceback (most recent call last): - ... - NoControlError: Control file doesnotexist does not exist - >>> cl = gbp.deb.control.Control("notparsable") - Traceback (most recent call last): - ... - ParseControlError: Empty or invalid control file or contents - """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_GitModifier.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_GitModifier.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_GitModifier.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_GitModifier.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -# vim: set fileencoding=utf-8 : - -""" -Test L{gbp.git.GitModifier} -""" - -from . import context - -def test_author(): - """ - Methods tested: - - L{gbp.git.GitModifier.get_author_env} - - L{gbp.git.GitModifier.get_committer_env} - - L{gbp.git.GitModifier.keys} - - >>> import gbp.git - >>> modifier = gbp.git.GitModifier('foo', 'bar') - >>> modifier.name - 'foo' - >>> modifier.email - 'bar' - >>> modifier.get_author_env()['GIT_AUTHOR_EMAIL'] - 'bar' - >>> modifier.get_author_env()['GIT_AUTHOR_NAME'] - 'foo' - >>> modifier.get_committer_env()['GIT_COMMITTER_NAME'] - 'foo' - >>> modifier.get_committer_env()['GIT_COMMITTER_EMAIL'] - 'bar' - >>> modifier._get_env('foo') - Traceback (most recent call last): - ... - GitModifierError: Neither committer nor author - >>> modifier['name'] - 'foo' - >>> modifier['email'] - 'bar' - >>> modifier['date'] - """ - -def test_date(): - """ - Methods tested: - - L{gbp.git.GitModifier.__init__} - - Properties tested: - - L{gbp.git.GitModifier.date} - - L{gbp.git.GitModifier.datetime} - - L{gbp.git.GitModifier.tz_offset} - - >>> import gbp.git - >>> import datetime - >>> modifier = gbp.git.GitModifier('foo', 'bar', 1) - >>> modifier.date - '1 +0000' - >>> modifier.date = '1 +0400' - >>> modifier.date - '1 +0400' - >>> modifier['date'] - '1 +0400' - >>> modifier.datetime # doctest: +ELLIPSIS - datetime.datetime(1970, 1, 1, 4, 0, 1, tzinfo=) - >>> modifier.date = datetime.datetime(1970, 1, 1, 0, 0, 1) - >>> modifier.date - '1 +0000' - >>> modifier.datetime # doctest: +ELLIPSIS - datetime.datetime(1970, 1, 1, 0, 0, 1, tzinfo=) - >>> modifier.tz_offset - '+0000' - """ - -def test_dict(): - """ - Test C{dict} interface - >>> import gbp.git - >>> modifier = gbp.git.GitModifier('foo', 'bar', 1) - >>> sorted(modifier.keys()) - ['date', 'email', 'name'] - >>> sorted(modifier.items()) - [('date', '1 +0000'), ('email', 'bar'), ('name', 'foo')] - """ - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_GitRepository.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_GitRepository.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_GitRepository.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_GitRepository.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,961 +0,0 @@ -# vim: set fileencoding=utf-8 : - -""" -Test L{gbp.git.GitRepository} - -This testcase creates several repositores: - - - A repository at L{repo_dir} called I{repo} - - A bare repository at L{bare_dir} called I{bare} - - A clone of I{repo} below L{clone_dir} called I{clone} - - A mirror of I{repo} below L{mirror_clone_dir} called I{mirror} -""" - -from . import context - -import gbp.log - -gbp.log.setup(color=False, verbose=True) - -repo_dir, bare_dir, clone_dir, mirror_clone_dir = list(map( - lambda x, tmpdir=context.new_tmpdir(__name__): tmpdir.join(x), - ['repo', 'bare', 'clone', 'mirror_clone'])) - -def test_create(): - """ - Create a repository - - Methods tested: - - L{gbp.git.GitRepository.create} - - Properties tested: - - L{gbp.git.GitRepository.path} - - L{gbp.git.GitRepository.git_dir} - - >>> import os, gbp.git - >>> repo = gbp.git.GitRepository.create(repo_dir) - >>> repo.path == repo_dir - True - >>> repo.git_dir == os.path.join(repo_dir, '.git') - True - >>> type(repo) == gbp.git.GitRepository - True - """ - - -def test_empty(): - """ - Empty repos have no branch - - Methods tested: - - L{gbp.git.GitRepository.get_branch} - - L{gbp.git.GitRepository.is_empty} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.get_branch() - >>> repo.branch - >>> repo.is_empty() - True - """ - - -def test_add_files(): - """ - Add some dummy data - - Methods tested: - - L{gbp.git.GitRepository.add_files} - - L{gbp.git.GitRepository.commit_all} - - L{gbp.git.GitRepository.is_clean} - - Properties tested: - - L{gbp.git.GitRepository.head} - - >>> import gbp.git, shutil, os - >>> repo = gbp.git.GitRepository(repo_dir) - >>> ret = shutil.copy(os.path.join(repo.path, ".git/HEAD"), - ... os.path.join(repo.path, "testfile")) - >>> repo.is_clean()[0] - False - >>> repo.is_clean(ignore_untracked=True)[0] - True - >>> repo.add_files(repo.path, force=True) - >>> repo.commit_all(msg="foo") - >>> repo.is_clean()[0] - True - >>> h = repo.head - >>> len(h) - 40 - """ - - -def test_branch_master(): - """ - First branch is called I{master} - - Methods tested: - - L{gbp.git.GitRepository.get_branch} - >>> import gbp.git, shutil - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.get_branch() - 'master' - >>> repo.branch - 'master' - """ - -def test_clean(): - """ - Remove untracked files from the working tree - - Methods tested: - - L{gbp.git.GitRepository.clean} - - >>> import gbp.git, shutil, os - >>> repo = gbp.git.GitRepository(repo_dir) - >>> ret = shutil.copy(os.path.join(repo.path, ".git/HEAD"), - ... os.path.join(repo.path, "testclean")) - >>> repo.clean(dry_run=True) - >>> repo.is_clean()[0] - False - >>> repo.clean(directories=True, force=True) - >>> repo.is_clean()[0] - True - """ - -def test_create_branch(): - """ - Create a branch name I{foo} - - Methods tested: - - L{gbp.git.GitRepository.create_branch} - - L{gbp.git.GitRepository.branch_contains} - - >>> import gbp.git, shutil - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.create_branch("foo") - >>> repo.branch_contains("foo", 'HEAD') - True - >>> repo.branch_contains("doesnotexist", 'HEAD', remote=True) - False - """ - -def test_delete_branch(): - """ - Create a branch named I{foo2} and delete it - - Methods tested: - - L{gbp.git.GitRepository.create_branch} - - L{gbp.git.GitRepository.delete_branch} - - >>> import gbp.git, shutil - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.create_branch("bar") - >>> repo.delete_branch("bar") - >>> repo.delete_branch("master") - Traceback (most recent call last): - ... - GitRepositoryError: Can't delete the branch you're on - """ - -def test_set_branch(): - """ - Switch to branch named I{foo} - - Methods tested: - - L{gbp.git.GitRepository.set_branch} - - L{gbp.git.GitRepository.get_branch} - - L{gbp.git.GitRepository.branch} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.set_branch("foo") - >>> repo.get_branch() == "foo" - True - >>> repo.branch == "foo" - True - """ - - -def test_rename_branch(): - """ - Create branch named I{baz}, rename it to I{bax} and finally delete it - - Methods tested: - - L{gbp.git.GitRepository.create_branch} - - L{gbp.git.GitRepository.rename_branch} - - L{gbp.git.GitRepository.delete_branch} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.create_branch("baz") - >>> repo.rename_branch("baz", "bax") - >>> repo.delete_branch("bax") - """ - - -def test_set_upstream_branch(): - """ - Set upstream branch master -> origin/master - - >>> import os, shutil - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> os.makedirs(os.path.join(repo.git_dir, 'refs/remotes/origin')) - >>> ret = shutil.copy(os.path.join(repo.git_dir, 'refs/heads/master'), \ - os.path.join(repo.git_dir, 'refs/remotes/origin/')) - >>> repo.add_remote_repo('origin', 'git://git.example.com/git/origin') - >>> repo.set_upstream_branch('master', 'origin/master') - >>> repo.get_upstream_branch('master') - 'origin/master' - >>> repo.set_upstream_branch('bla', 'origin/master') - Traceback (most recent call last): - GitRepositoryError: Branch bla doesn't exist! - >>> repo.set_upstream_branch('foo', 'origin/bla') - Traceback (most recent call last): - GitRepositoryError: Branch origin/bla doesn't exist! - """ - -def test_get_upstream_branch(): - """ - Get info about upstream branches set in test_set_upstream_branch - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.get_upstream_branch('master') - 'origin/master' - >>> repo.get_upstream_branch('foo') - '' - >>> repo.get_upstream_branch('bla') - Traceback (most recent call last): - GitRepositoryError: Branch bla doesn't exist! - """ - -def test_tag(): - """ - Create a tag named I{tag} and check its existance - - Methods tested: - - L{gbp.git.GitRepository.create_tag} - - L{gbp.git.GitRepository.verify_tag} - - L{gbp.git.GitRepository.has_tag} - - L{gbp.git.GitRepository.get_tags} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.create_tag("tag") - >>> repo.has_tag("tag") - True - >>> repo.has_tag("unknown") - False - >>> repo.create_tag("tag2", msg="foo") - >>> repo.has_tag("tag2") - True - >>> repo.verify_tag("tag2") - False - >>> repo.get_tags() - ['tag', 'tag2'] - >>> repo.tags - ['tag', 'tag2'] - """ - -def test_describe(): - """ - Describe commit-ish - - Methods tested: - - L{gbp.git.GitRepository.describe} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> sha = repo.rev_parse('HEAD') - >>> repo.describe('HEAD') - 'tag2' - >>> repo.describe('HEAD', longfmt=True) == 'tag2-0-g%s' % sha[:7] - True - >>> repo.describe('HEAD', pattern='foo*') - Traceback (most recent call last): - ... - GitRepositoryError: Can't describe HEAD. Git error: fatal: No names found, cannot describe anything. - >>> repo.describe('HEAD', pattern='foo*', always=True) == sha[:7] - True - >>> repo.describe('HEAD', always=True, abbrev=16) - 'tag2' - >>> repo.describe('HEAD', pattern='foo*', always=True, abbrev=16) == sha[:16] - True - >>> tag = repo.describe('HEAD', longfmt=True, abbrev=16) == 'tag2-0-g%s' % sha[:16] - >>> repo.delete_tag('tag2') - >>> repo.describe('HEAD', tags=True) - 'tag' - >>> repo.describe('HEAD', tags=True, exact_match=True) - 'tag' - >>> repo.create_tag('tag2', msg='foo') - """ - -def test_find_tag(): - """ - Find tags - - Methods tested: - - L{gbp.git.GitRepository.find_tag} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.find_tag('HEAD') - 'tag2' - >>> repo.find_tag('HEAD', pattern='foo*') - Traceback (most recent call last): - ... - GitRepositoryError: Can't describe HEAD. Git error: fatal: No names found, cannot describe anything. - """ - -def test_find_branch_tag(): - """ - Find the closest tags on a certain branch to a given commit - - Methods tested: - - L{gbp.git.GitRepository.find_branch_tag} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.find_branch_tag('HEAD', 'master', 'tag*') - 'tag2' - >>> repo.find_branch_tag('HEAD', 'master', 'v*') # doctest:+ELLIPSIS - Traceback (most recent call last): - ... - GitRepositoryError: Can't describe .... Git error: fatal: No names found, cannot describe anything. - """ - -def test_move_tag(): - """ - Move a tag - - Methods tested: - - L{gbp.git.GitRepository.move_tag} - - L{gbp.git.GitRepository.has_tag} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.move_tag("tag", "moved") - >>> repo.has_tag("tag") - False - >>> repo.has_tag("moved") - True - """ - -def test_delete_tag(): - """ - Delete tags - - Methods tested: - - L{gbp.git.GitRepository.delete_tag} - - L{gbp.git.GitRepository.has_tag} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.has_tag("moved") - True - >>> repo.delete_tag("moved") - >>> repo.has_tag("moved") - False - """ - -def test_get_obj_type(): - """ - Find commit SHA1 related to tags - - Methods tested: - - L{gbp.git.GitRepository.create_tag} - - L{gbp.git.GitRepository.get_obj_type} - - L{gbp.git.GitRepository.delete_tag} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.create_tag("tag3", "tag msg") - >>> repo.get_obj_type("tag3") - 'tag' - >>> repo.get_obj_type("HEAD") - 'commit' - >>> repo.get_obj_type("HEAD:testfile") - 'blob' - >>> repo.delete_tag("tag3") - """ - -def test_list_files(): - """ - List files in the index - - Methods tested: - - L{gbp.git.GitRepository.list_files} - - L{gbp.git.GitRepository.add_files} - - L{gbp.git.GitRepository.commit_staged} - - L{gbp.git.GitRepository.commit_files} - - L{gbp.git.GitRepository.force_head} - - >>> import gbp.git, os, shutil - >>> repo = gbp.git.GitRepository(repo_dir) - >>> src = os.path.join(repo.path, ".git/HEAD") - >>> dst = os.path.join(repo.path, "testfile") - >>> repo.list_files() - ['testfile'] - >>> repo.list_files(['modified']) - [] - >>> repo.list_files(['modified', 'deleted']) - [] - >>> repo.list_files(['modified', 'deleted', 'cached']) - ['testfile'] - >>> ret = shutil.copy(src, dst) - >>> repo.list_files(['modified']) - ['testfile'] - >>> repo.add_files(dst) - >>> repo.commit_staged(msg="foo") - >>> repo.list_files(['modified']) - [] - >>> repo.list_files(['foo']) - Traceback (most recent call last): - ... - GitRepositoryError: Unknown type 'foo' - >>> repo.force_head('HEAD^', hard=True) - >>> repo.list_files(['modified']) - [] - >>> ret = shutil.copy(src, dst) - >>> repo.list_files(['modified']) - ['testfile'] - >>> repo.commit_files(dst, msg="foo") - >>> repo.list_files(['modified']) - [] - """ - -def test_get_commits(): - """ - Test listing commits - - Methods tested: - - L{gbp.git.GitRepository.get_commits} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> commits = repo.get_commits() - >>> type(commits) == list and len(commits) == 2 - True - >>> len(repo.get_commits(num=1)) == 1 - True - >>> commits2 = repo.get_commits(since='HEAD~1') - >>> len(commits2) == 1 - True - >>> commits2[0] == commits[0] - True - >>> commits2 = repo.get_commits(until='HEAD~1') - >>> len(commits2) == 1 - True - >>> commits2[0] == commits[-1] - True - >>> repo.get_commits(paths=['foo', 'bar']) - [] - >>> repo.get_commits(paths=['testfile']) == commits - True - """ - - -def test_get_commit_info(): - """ - Test inspecting commits - - Methods tested: - - L{gbp.git.GitRepository.get_commit_info} - - >>> import gbp.git - >>> from datetime import datetime - >>> repo = gbp.git.GitRepository(repo_dir) - >>> info = repo.get_commit_info('HEAD') - >>> info['id'] - 'HEAD' - >>> info['body'] - '' - >>> info['subject'] - 'foo' - >>> '@' in info['author'].email - True - >>> '@' in info['committer'].email - True - >>> now = datetime.now() - >>> (now - datetime.fromtimestamp(int(info['author'].date.split()[0]))).seconds < 10 - True - >>> (now - datetime.fromtimestamp(int(info['committer'].date.split()[0]))).seconds < 10 - True - >>> info['patchname'] - 'foo' - >>> info['files'] # doctest:+ELLIPSIS - defaultdict(<... 'list'>, {'M': ['testfile']}) - >>> repo.get_subject('HEAD') - 'foo' - """ - -def test_diff(): - """ - Test git-diff - - Methods tested: - - L{gbp.git.GitRepository.diff} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> len(repo.diff('HEAD~1', 'HEAD')) > 3 - True - >>> len(repo.diff('HEAD~1', 'HEAD', 'testfile')) > 3 - True - >>> len(repo.diff('HEAD~1', 'HEAD', 'testfile', text=True)) > 3 - True - >>> len(repo.diff('HEAD~1', 'HEAD', 'filenotexist')) == 0 - True - >>> repo.diff('HEAD~1', 'HEAD') == repo.diff('HEAD~1') - True - """ - -def test_diff_status(): - """ - Methods tested: - - L{gbp.git.GitRepository.diff_status} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.diff_status("HEAD", "HEAD") # doctest:+ELLIPSIS - defaultdict(<... 'list'>, {}) - >>> repo.diff_status("HEAD~1", "HEAD") # doctest:+ELLIPSIS - defaultdict(<... 'list'>, {'M': ['testfile']}) - """ - -def test_mirror_clone(): - """ - Mirror a repository - - Methods tested: - - L{gbp.git.GitRepository.clone} - - L{gbp.git.GitRepository.is_empty} - - L{gbp.git.GitRepository.set_branch} - - L{gbp.git.GitRepository.has_branch} - - L{gbp.git.GitRepository.branch} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.set_branch('master') - >>> mirror = gbp.git.GitRepository.clone(mirror_clone_dir, repo.path, mirror=True) - >>> mirror.is_empty() - False - >>> mirror.branch - 'master' - >>> mirror.has_branch('foo') - True - >>> mirror.has_branch('bar') - False - >>> mirror.set_branch('foo') - >>> mirror.branch - 'foo' - >>> mirror.force_head('foo^') - """ - -def test_clone(): - """ - Clone a repository - - Methods tested: - - L{gbp.git.GitRepository.clone} - - L{gbp.git.GitRepository.is_empty} - - L{gbp.git.GitRepository.set_branch} - - L{gbp.git.GitRepository.branch} - - L{gbp.git.GitRepository.get_merge_branch} - - L{gbp.git.GitRepository.get_remote_branches} - - L{gbp.git.GitRepository.get_local_branches} - - L{gbp.git.GitRepository.get_remote_repos} - - L{gbp.git.GitRepository.has_remote_repo} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.set_branch('master') - >>> clone = gbp.git.GitRepository.clone(clone_dir, repo.path) - >>> clone.is_empty() - False - >>> clone.branch - 'master' - >>> clone.get_remote_branches() - ['origin/HEAD', 'origin/foo', 'origin/master'] - >>> clone.get_local_branches() - ['master'] - >>> clone.get_merge_branch('master') - 'origin/master' - >>> clone.create_branch('foo', 'origin/foo') - >>> clone.get_merge_branch('foo') - 'origin/foo' - >>> clone.create_branch('bar') - >>> clone.get_merge_branch('bar') # None if no merge branch exists - >>> clone.get_local_branches() - ['bar', 'foo', 'master'] - >>> clone.get_remote_repos() - ['origin'] - >>> clone.has_remote_repo('origin') - True - >>> clone.has_branch('origin/master', remote=True) - True - >>> clone.has_remote_repo('godiug') - False - """ - -def test_get_remotes(): - """ - Merge a branch - - Methods tested: - - L{gbp.git.GitRepository.get_remotes} - - >>> import os - >>> import gbp.git.repository - >>> repo = gbp.git.repository.GitRepository(os.path.join(clone_dir, 'repo')) - >>> remotes = repo.get_remotes() - >>> len(remotes) - 1 - >>> origin = remotes['origin'] - >>> origin.name - 'origin' - >>> origin.fetch_url == repo_dir - True - >>> origin.push_urls == [repo_dir] - True - """ - -def test_merge(): - """ - Merge a branch - - Methods tested: - - L{gbp.git.GitRepository.merge} - - L{gbp.git.GitRepository.set_branch} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.set_branch('master') - >>> repo.merge('foo') - """ - -def test_pull(): - """ - Pull from a remote repository - - Methods tested: - - L{gbp.git.GitRepository.set_branch} - - L{gbp.git.GitRepository.pull} - - >>> import gbp.git, os - >>> d = os.path.join(clone_dir, 'repo') - >>> clone = gbp.git.GitRepository(d) - >>> clone.set_branch('master') - >>> clone.pull() - >>> clone.pull(all_remotes=True) - >>> clone.pull('origin', all_remotes=True) - """ - -def test_fetch(): - """ - Fetch from a remote repository - - Methods tested: - - L{gbp.git.GitRepository.fetch} - - L{gbp.git.GitRepository.push} - - L{gbp.git.GitRepository.push_tag} - - L{gbp.git.GitRepository.add_remote_repo} - - L{gbp.git.GitRepository.remove_remote_repo} - - >>> import gbp.git, os - >>> d = os.path.join(clone_dir, 'repo') - >>> clone = gbp.git.GitRepository(d) - >>> clone.fetch() - >>> clone.push() - >>> clone.push('origin') - >>> clone.push('origin', 'master') - >>> clone.push('origin', 'master', force=True) - >>> clone.create_tag('tag3') - >>> clone.push_tag('origin', 'tag3') - >>> clone.create_tag('tag4') - >>> clone.push('origin', 'master', tags=True) - >>> clone.add_remote_repo('foo', repo_dir) - >>> clone.fetch('foo') - >>> clone.fetch('foo', tags=True) - >>> clone.fetch('foo', refspec='refs/heads/master') - >>> clone.fetch(all_remotes=True) - >>> clone.remove_remote_repo('foo') - """ - -def test_create_bare(): - """ - Create a bare repository - - Methods tested: - - L{gbp.git.GitRepository.create} - - L{gbp.git.GitRepository.is_empty} - - >>> import gbp.git - >>> bare = gbp.git.GitRepository.create(bare_dir, bare=True, description="msg") - >>> bare.path == bare_dir - True - >>> bare.git_dir[:-1] == bare_dir - True - >>> type(bare) == gbp.git.GitRepository - True - >>> bare.is_empty() - True - >>> bare.is_clean() - (True, '') - """ - -def test_nonexistant(): - """ - Check that accessing a non existant repository fails. - - Methods tested: - - L{gbp.git.GitRepository.__init__} - - >>> import gbp.git - >>> bare = gbp.git.GitRepository("/does/not/exist") - Traceback (most recent call last): - ... - GitRepositoryError: No Git repository at '/does/not/exist' - """ - -def test_create_noperm(): - """ - Check that creating a repository at a path that isn't writeable fails - - Methods tested: - - L{gbp.git.GitRepository.create} - - >>> import gbp.git - >>> gbp.git.GitRepository.create("/does/not/exist") - Traceback (most recent call last): - ... - GitRepositoryError: Cannot create Git repository at '/does/not/exist': Permission denied - """ - -def test_checkout(): - """ - Checkout treeishs - - Methods tested: - - L{gbp.git.GitRepository.checkout} - - L{gbp.git.GitRepository.get_branch} - - L{gbp.git.GitRepository.set_branch} - - L{gbp.git.GitRepository.rev_parse} - - Properties tested: - - L{gbp.git.GitRepository.branch} - - L{gbp.git.GitRepository.tags} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.checkout('master') - >>> repo.branch - 'master' - >>> repo.rev_parse('doesnotexist') - Traceback (most recent call last): - ... - GitRepositoryError: revision 'doesnotexist' not found - >>> sha1 = repo.rev_parse('master', short=10) - >>> len(sha1) - 10 - >>> sha1 = repo.rev_parse('master') - >>> len(sha1) - 40 - >>> repo.checkout(sha1) - >>> repo.branch - >>> repo.get_branch() - Traceback (most recent call last): - ... - GitRepositoryError: Currently not on a branch - >>> tag = repo.tags[0] - >>> repo.checkout(tag) - >>> repo.branch - """ - -def test_gc(): - """ - Test garbace collection - - Methods tested: - - L{gbp.git.GitRepository.collect_garbage} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.collect_garbage() - """ - -def test_grep_log(): - """ - Test grepping through commit messages - - Methods tested: - - L{gbp.git.GitRepository.grep_log} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.set_branch('master') - >>> len(repo.grep_log('foo')) == 2 - True - >>> len(repo.grep_log('foo', 'master')) == 2 - True - >>> repo.grep_log('blafasel') - [] - >>> repo.grep_log('foo', 'doesnotexist') - Traceback (most recent call last): - ... - GitRepositoryError: Error grepping log for foo: fatal: bad revision 'doesnotexist' - """ - -def test_is_ff(): - """ - Test if branch is fast forwardable - - Methods tested: - - L{gbp.git.GitRepository.is_fast_forward} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.is_fast_forward('master', 'foo') - (True, True) - >>> repo.create_branch('ff', 'HEAD^') - >>> repo.is_fast_forward('ff', 'master') - (True, False) - >>> repo.is_fast_forward('master', 'ff') - (False, True) - """ - -def test_update_ref(): - """ - Test updating a reference - - Methods tested: - - L{gbp.git.GitRepository.update_ref} - - >>> import gbp.git, os - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.update_ref('new_ref', 'master', msg='update') - >>> os.path.exists(os.path.join(repo.git_dir, 'new_ref')) - True - """ - - -def test_make_tree(): - """ - Test git-mk-tree - - Methods tested: - - L{gbp.git.GitRepository.write_file} - - L{gbp.git.GitRepository.list_tree} - - L{gbp.git.GitRepository.make_tree} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> sha1 = repo.write_file('testfile') - >>> sha1 - '19af7398c894bc5e86e17259317e4db519e9241f' - >>> head = repo.list_tree('HEAD') - >>> head - [['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile']] - >>> head.append(['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile2']) - >>> newtree = repo.make_tree(head) - >>> newtree - '745951810c9e22fcc6de9b23f05efd6ab5512123' - >>> repo.list_tree(newtree, recurse=False, paths='testfile') - [['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile']] - """ - - -def test_update_submodules(): - """ - Updating submodules if we don't have any is a noop - - Methods tested: - - L{gbp.git.GitRepository.has_submodules} - - L{gbp.git.GitRepository.update_submodules} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo.has_submodules() - False - >>> repo.update_submodules() - """ - -def test_get_merge_base(): - """ - Find the common ancestor of two objects - - Methods tested: - - L{gbp.git.GitRepository.get_merge_base} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> sha1 = repo.get_merge_base('master', 'foo') - >>> len(sha1) - 40 - >>> repo.get_merge_base('master', 'doesnotexist') - Traceback (most recent call last): - ... - GitRepositoryError: Failed to get common ancestor: fatal: Not a valid object name doesnotexist - """ - -def test_status(): - r""" - Methods tested: - - L{gbp.git.GitRepository.status} - - >>> import gbp.git, os, shutil - >>> repo = gbp.git.GitRepository(repo_dir) - >>> fname = os.path.join(repo.path, "test_status") - >>> ret = shutil.copy(os.path.join(repo.path, ".git/HEAD"), fname) - >>> list(repo.status().items()) - [('??', ['test_status'])] - >>> list(repo.status(['bla*']).items()) - [] - >>> list(repo.status(['te*']).items()) - [('??', ['test_status'])] - >>> repo.add_files(repo.path, force=True) - >>> repo.commit_all(msg='added %s' % fname) - >>> _ = repo._git_inout('mv', [fname, fname + 'new']) - >>> list(repo.status().items()) - [('R ', ['test_status\x00test_statusnew'])] - """ - -def test_cmd_has_feature(): - r""" - Methods tested: - - L{gbp.git.GitRepository._cmd_has_feature} - - >>> import gbp.git - >>> repo = gbp.git.GitRepository(repo_dir) - >>> repo._cmd_has_feature("commit", "a") - True - >>> repo._cmd_has_feature("commit", "reuse-message") - True - >>> repo._cmd_has_feature("merge", "n") - True - >>> repo._cmd_has_feature("merge", "stat") - True - >>> repo._cmd_has_feature("format-patch", "cc") - True - >>> repo._cmd_has_feature("merge", "foobaroption") - False - >>> repo._cmd_has_feature("foobarcmd", "foobaroption") - Traceback (most recent call last): - ... - GitRepositoryError: Invalid git command 'foobarcmd': No manual entry for gitfoobarcmd - >>> repo._cmd_has_feature("show", "standard-notes") - True - >>> repo._cmd_has_feature("show", "no-standard-notes") - True - """ - -def test_teardown(): - """ - Perform the teardown - - >>> context.teardown() - """ - -# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_GitVfs.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_GitVfs.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_GitVfs.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_GitVfs.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -# vim: set fileencoding=utf-8 : - -""" -Test L{gbp.git.GitVfs} -""" - -import gbp.log - -from . import context - -gbp.log.setup(color=False, verbose=True) - -def test_read(): - """ - Create a repository - - Methods tested: - - L{gbp.git.GitVfs.open} - - L{gbp.git.GitVfs._File.readline} - - L{gbp.git.GitVfs._File.readlines} - - L{gbp.git.GitVfs._File.read} - - L{gbp.git.GitVfs._File.close} - - >>> import os, gbp.git.vfs - >>> repo_dir = context.new_tmpdir(__name__) - >>> repo = gbp.git.GitRepository.create(str(repo_dir)) - >>> f = open(os.path.join(repo.path, 'foo.txt'), 'w') - >>> content = 'al pha\\na\\nb\\nc' - >>> ret = f.write('al pha\\na\\nb\\nc') - >>> f.close() - >>> repo.add_files(repo.path, force=True) - >>> repo.commit_all(msg="foo") - >>> vfs = gbp.git.vfs.GitVfs(repo, 'HEAD') - >>> gf = vfs.open('foo.txt') - >>> gf.readline() - 'al pha\\n' - >>> gf.readline() - 'a\\n' - >>> gf.readlines() - ['b\\n', 'c'] - >>> gf.readlines() - [] - >>> gf.readline() - '' - >>> gf.readline() - '' - >>> gf.close() - >>> gbp.git.vfs.GitVfs(repo, 'HEAD').open('foo.txt').read() == content - True - >>> gf = vfs.open('doesnotexist') - Traceback (most recent call last): - ... - IOError: can't get HEAD:doesnotexist: fatal: Path 'doesnotexist' does not exist in 'HEAD' - >>> context.teardown() - """ diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_PristineTar.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_PristineTar.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_PristineTar.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_PristineTar.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ -# vim: set fileencoding=utf-8 : - -""" -Test pristine-tar related methods in - - - L{gbp.deb.DebianPristineTar} - -and - - - L{gbp.deb.git.DebianGitRepository} - -This testcase creates this reposity: - - - A repository at L{repo_dir} called I{repo} - -""" - -from . import context - -import os - -repo_dir = context.new_tmpdir(__name__).join('repo') -test_data = os.path.join(context.projectdir, "tests/test_PristineTar_data") - -def test_create(): - """ - Create a repository - - Methods tested: - - L{gbp.deb.git.DebianGitRepository.create} - - >>> import os, gbp.deb.git - >>> repo = gbp.deb.git.DebianGitRepository.create(repo_dir) - """ - -def test_empty_repo(): - """ - Empty repos have no branch pristine-tar branch - - Methods tested: - - L{gbp.deb.git.DebianGitRepository.has_pristine_tar_branch} - - L{gbp.deb.pristinetar.DebianPristineTar.has_commit} - - >>> import gbp.deb.git - >>> repo = gbp.deb.git.DebianGitRepository(repo_dir) - >>> repo.has_pristine_tar_branch() - False - >>> repo.pristine_tar.has_commit('upstream', '1.0', 'gzip') - False - """ - -def test_commit_dir(): - """ - Empty repos have no branch pristine-tar branch - - Methods tested: - - L{gbp.git.repository.GitRepository.commit_dir} - - L{gbp.git.repository.GitRepository.create_branch} - - >>> import gbp.deb.git - >>> repo = gbp.deb.git.DebianGitRepository(repo_dir) - >>> commit = repo.commit_dir(test_data, msg="initial commit", branch=None) - >>> repo.create_branch('upstream') - """ - -def test_create_tarball(): - """ - Create a tarball from a git tree - - Methods tested: - - L{gbp.deb.git.DebianGitRepository.archive} - - >>> import gbp.deb.git - >>> repo = gbp.deb.git.DebianGitRepository(repo_dir) - >>> repo.archive('tar', 'upstream/', '../upstream_1.0.orig.tar', 'upstream') - >>> gbp.command_wrappers.Command('gzip', [ '-n', '%s/../upstream_1.0.orig.tar' % repo_dir])() - """ - -def test_pristine_tar_commit(): - """ - Commit the delta to the pristine-tar branch - - Methods tested: - - L{gbp.deb.pristinetar.DebianPristineTar.commit} - - >>> import gbp.deb.git - >>> repo = gbp.deb.git.DebianGitRepository(repo_dir) - >>> repo.pristine_tar.commit('../upstream_1.0.orig.tar.gz', 'upstream') - """ - -def test_pristine_has_commit(): - """ - Find delta on the pristine tar branch - - Methods tested: - - L{gbp.deb.pristinetar.DebianPristineTar.has_commit} - - L{gbp.pkg.pristinetar.PristineTar.get_commit} - - >>> import gbp.deb.git - >>> repo = gbp.deb.git.DebianGitRepository(repo_dir) - >>> repo.pristine_tar.has_commit('upstream', '1.0', 'bzip2') - False - >>> repo.pristine_tar.has_commit('upstream', '1.0', 'gzip') - True - >>> repo.pristine_tar.has_commit('upstream', '1.0') - True - >>> branch = repo.rev_parse('pristine-tar') - >>> commit = repo.pristine_tar.get_commit('upstream_1.0.orig.tar.gz') - >>> branch == commit - True - """ - -def test_pristine_tar_checkout(): - """ - Checkout a tarball using pristine-tar - - Methods tested: - - L{gbp.deb.pristinetar.DebianPristineTar.checkout} - - >>> import gbp.deb.git - >>> repo = gbp.deb.git.DebianGitRepository(repo_dir) - >>> repo.pristine_tar.checkout('upstream', '1.0', 'gzip', '..') - """ - -def test_pristine_tar_checkout_nonexistent(): - """ - Checkout a tarball that does not exist using pristine-tar - - Methods tested: - - L{gbp.deb.pristinetar.DebianPristineTar.checkout} - - >>> import gbp.deb.git - >>> repo = gbp.deb.git.DebianGitRepository(repo_dir) - >>> repo.pristine_tar.checkout('upstream', '1.1', 'gzip', '..') - Traceback (most recent call last): - ... - CommandExecFailed: Pristine-tar couldn't checkout "upstream_1.1.orig.tar.gz": fatal: Path 'upstream_1.1.orig.tar.gz.delta' does not exist in 'refs/heads/pristine-tar' - pristine-tar: git show refs/heads/pristine-tar:upstream_1.1.orig.tar.gz.delta failed - """ - -def test_teardown(): - """ - Perform the teardown - - >>> context.teardown() - """ - -# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_rpm_changelog.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_rpm_changelog.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/test_rpm_changelog.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/test_rpm_changelog.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,226 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2014-2015 Intel Corporation +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# +"""Test RPM changelog classes and parsing""" + +from datetime import datetime +from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 +from tempfile import NamedTemporaryFile + +from gbp.rpm.changelog import _ChangelogHeader, _ChangelogEntry +from gbp.rpm.changelog import _ChangelogSection, Changelog +from gbp.rpm.changelog import ChangelogParser, ChangelogError +from gbp.rpm.policy import RpmPkgPolicy + + +class TestChangelogHeader(object): + """Test the _ChangelogHeader class""" + + def test_str_format(self): + """Basic test for header""" + time = datetime(2014, 1, 29, 12, 13, 14) + header = _ChangelogHeader(RpmPkgPolicy, time, name="John Doe", + email="user@host.com", revision="1") + eq_(str(header), "* Wed Jan 29 2014 John Doe 1\n") + + def test_str_format_err(self): + """Test missing properties""" + time = datetime(2014, 1, 29, 12, 13, 14) + header = _ChangelogHeader(RpmPkgPolicy, time, name="John", revision="1") + with assert_raises(ChangelogError): + str(header) + + def test_container(self): + """Test the container methods of the class""" + header = _ChangelogHeader(RpmPkgPolicy, datetime(2014, 1, 1), name="N", + revision="1") + # Test __getitem__() + eq_(header['name'], "N") + eq_(header['email'], None) + # Test __contains__() + ok_('name' in header) + ok_('foo' not in header) + + +class TestChangelogEntry(object): + """Test the _ChangelogEntry class""" + + def test_str_format(self): + """Basic test""" + entry = _ChangelogEntry(RpmPkgPolicy, author="John Doe", + text="- foo\n bar") + eq_(str(entry), "- foo\n bar\n") + + +class TestChangelogSection(object): + """Test the _ChangelogSection class""" + + def setup(self): + """Initialize test""" + time = datetime(2014, 1, 29, 12, 13, 14) + self.default_sect = _ChangelogSection(RpmPkgPolicy, time, name="J. D.", + email="u@h", revision="1") + entry = _ChangelogEntry(RpmPkgPolicy, "J. D.", "- my change") + self.default_sect.entries = [entry] + + def test_str_format(self): + """Basic test""" + section = self.default_sect + eq_(str(section), "* Wed Jan 29 2014 J. D. 1\n- my change\n\n") + + def test_append_entry(self): + """Test add_entry() method""" + section = self.default_sect + entry = _ChangelogEntry(RpmPkgPolicy, author="", + text="- another\n change") + new_entry = section.append_entry(entry) + eq_(str(section), "* Wed Jan 29 2014 J. D. 1\n- my change\n" + "- another\n change\n\n") + eq_(new_entry, section.entries[-1]) + + def test_set_header(self): + """Test set_header() method""" + section = self.default_sect + time = datetime(2014, 1, 30) + section.set_header(time=time, name="Jane", email="u@h", revision="1.1") + eq_(str(section), "* Thu Jan 30 2014 Jane 1.1\n- my change\n\n") + + +class TestChangelogParser(object): + """Test the default changelog parser""" + + cl_default_style = """\ +* Wed Jan 29 2014 Markus Lehtonen 0.3-1 +- Version bump +- Drop foo.patch + +* Tue Jan 28 2014 Markus Lehtonen 0.2 +- Update to 0.2 + +* Mon Jan 27 2014 Markus Lehtonen 0.1 +- Initial version +""" + cl_with_authors = """\ +* Wed Jan 29 2014 Markus Lehtonen 0.3-1 +[Markus Lehtonen] +- Version bump +[John Doe] +- Bug fix +""" + # Invalid timestamp / name + cl_broken_header_1 = """\ +* Wed Jan 29 2014Markus Lehtonen 0.3-1 +- Version bump +""" + # Whitespace before the asterisk in the header + cl_broken_header_2 = """\ + * Wed Jan 29 2014 Markus Lehtonen 0.3-1 +- Version bump +""" + # Invalid timestamp + cl_broken_header_3 = """\ +* Wed Jan 32 2014 Markus Lehtonen 0.3-1 +- Version bump +""" + # Missing email + cl_broken_header_4 = """\ +* Wed Jan 29 2014 Markus Lehtonen 0.3-1 +- Version bump +""" + # Garbage before section header + cl_broken_header_5 = """\ +---garbage--- +* Wed Jan 29 2014 Markus Lehtonen 0.3-1 +- Version bump +""" + + parser = ChangelogParser(RpmPkgPolicy) + + def test_parse_changelog(self): + """Basic tests for successful parsing""" + # Raw parsing of changelog + changelog = self.parser.raw_parse_string(self.cl_default_style) + eq_(len(changelog.sections), 3) + + # Check that re-creating the changelog doesn't mangle it + eq_(str(changelog), self.cl_default_style) + + # Parse and check section + section = self.parser.parse_section(changelog.sections[0]) + + eq_(section.header['time'], datetime(2014, 1, 29)) + eq_(section.header['name'], "Markus Lehtonen") + eq_(section.header['email'], "markus.lehtonen@linux.intel.com") + eq_(section.header['revision'], "0.3-1") + + # Check that re-creating section doesn't mangle it + eq_(str(section), changelog.sections[0]) + + def test_parse_authors(self): + """Test parsing of authors from changelog entries""" + section = self.parser.parse_section(self.cl_with_authors) + eq_(section.entries[0].author, "Markus Lehtonen") + eq_(section.entries[1].author, "John Doe") + + def test_parse_changelog_file(self): + """Basic tests for parsing a file""" + # Create file and parse it + tmpfile = NamedTemporaryFile() + tmpfile.write(self.cl_default_style) + tmpfile.file.flush() + changelog = self.parser.raw_parse_file(tmpfile.name) + # Check parsing results + eq_(len(changelog.sections), 3) + eq_(str(changelog), self.cl_default_style) + # Cleanup + tmpfile.close() + + def test_parse_section_fail(self): + """Basic tests for failures of changelog section parsing""" + with assert_raises(ChangelogError): + self.parser.parse_section(self.cl_broken_header_1) + + with assert_raises(ChangelogError): + self.parser.parse_section(self.cl_broken_header_2) + + with assert_raises(ChangelogError): + self.parser.parse_section(self.cl_broken_header_3) + + with assert_raises(ChangelogError): + self.parser.parse_section(self.cl_broken_header_4) + + def test_parse_changelog_fail(self): + """Basic tests for changelog parsing failures""" + with assert_raises(ChangelogError): + self.parser.raw_parse_string(self.cl_broken_header_5) + + +class TestChangelog(object): + """Unit tests for the Changelog class""" + + def basic_test(self): + """Test basic initialization""" + changelog = Changelog(RpmPkgPolicy) + eq_(str(changelog), "") + + def test_add_section(self): + """Test the add_section() method""" + changelog = Changelog(RpmPkgPolicy) + time = datetime(2014, 1, 30) + new_section = changelog.add_section(time=time, name="Jane Doe", + email="j@doe.com", revision="1.2") + eq_(str(changelog), "* Thu Jan 30 2014 Jane Doe 1.2\n\n") + eq_(new_section, changelog.sections[0]) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/capture.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/capture.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/capture.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/capture.py 2017-02-11 19:33:12.000000000 +0000 @@ -5,9 +5,9 @@ from six import StringIO -class StderrCapture(StringIO): +class _StderrCapture(StringIO): def save(self): - self.safed = sys.stderr + self.safed = sys.stdout sys.stderr = self def restore(self): @@ -20,10 +20,34 @@ return self.read() +class _StdoutCapture(StringIO): + def save(self): + self.safed = sys.stdout + sys.stdout = self + + def restore(self): + if self.safed is not None: + sys.stdout = self.safed + self.safed = None + + def output(self): + self.seek(0) + return self.read() + + @contextmanager def capture_stderr(): """Capture an output and return its content""" - c = StderrCapture() + c = _StderrCapture() + c.save() + yield c + c.restore() + + +@contextmanager +def capture_stdout(): + """Capture an output and return its content""" + c = _StdoutCapture() c.save() yield c c.restore() diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/data.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/data.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/data.py 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/data.py 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,35 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2016 Guido Guenther +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# + +from functools import wraps + +import unittest + + +class TestCaseWithData(unittest.TestCase): + @staticmethod + def feed(data): + def wrapper(fn): + @wraps(fn) + def feed_item(self, *args): + for d in data: + try: + fn(self, *((d,) + args)) + except self.failureException as e: + raise self.failureException(e.message + " with data %s" % repr(d)) + return feed_item + return wrapper diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/debiangittestrepo.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/debiangittestrepo.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/debiangittestrepo.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/debiangittestrepo.py 2017-02-11 19:33:12.000000000 +0000 @@ -7,14 +7,20 @@ import gbp.deb.git + class DebianGitTestRepo(unittest.TestCase): """Scratch repo for a single unit test""" - def setUp(self): + def setUp(self, repo_cls=None): + name = 'test_repo' self.tmpdir = context.new_tmpdir(__name__) - repodir = self.tmpdir.join('test_repo') - self.repo = gbp.deb.git.DebianGitRepository.create(repodir) + if repo_cls is None: + repo_cls = gbp.deb.git.DebianGitRepository + + repodir = self.tmpdir.join(name) + self.repodir = os.path.join(str(self.tmpdir), name) + self.repo = repo_cls.create(repodir) def tearDown(self): context.teardown() @@ -36,6 +42,6 @@ os.makedirs(d) with open(path, 'w+') as f: - content == None or f.write(content) + content is None or f.write(content) self.repo.add_files(name, force=True) self.repo.commit_files(path, msg or "added %s" % name) diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/gbplogtester.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/gbplogtester.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/gbplogtester.py 2016-08-07 18:14:39.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/gbplogtester.py 2017-02-11 19:33:12.000000000 +0000 @@ -6,6 +6,7 @@ import gbp.log + class GbpLogTester(object): """ Helper class for tests that need to capture logging output @@ -56,6 +57,18 @@ ok_(re.match(regex, output), "Log entry '%s' doesn't match '%s'" % (output, regex)) + def _check_in_log(self, regex): + """Check that the at least one line on log matches expectations""" + found = False + if self._log is None: + raise Exception("BUG in unittests: no log captured!") + log = self._get_log() + for line in log: + if re.match(regex, line): + found = True + break + ok_(found, "No line of %s matched '%s'" % (log, regex)) + def _clear_log(self): """Clear the mock strerr""" if self._log is not None: diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/__init__.py git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/__init__.py --- git-buildpackage-0.7.5ubuntu0~ppa1/tests/testutils/__init__.py 2016-08-07 18:14:38.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/tests/testutils/__init__.py 2017-02-11 19:33:12.000000000 +0000 @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : -from .. import context +from .. import context # noqa: F401 import os import shutil @@ -15,12 +15,14 @@ from . gbplogtester import GbpLogTester from . debiangittestrepo import DebianGitTestRepo -from . capture import capture_stderr +from . capture import capture_stdout, capture_stderr __all__ = ['GbpLogTester', 'DebianGitTestRepo', 'OsReleaseFile', - 'MockedChangeLog', 'get_dch_default_urgency', 'capture_stderr', + 'MockedChangeLog', 'get_dch_default_urgency', + 'capture_stderr', 'capture_stdout', 'ls_dir', 'ls_tar', 'ls_zip'] + class OsReleaseFile(object): """Repesents a simple file with key-value pairs""" @@ -38,7 +40,7 @@ self._values[key] = value.strip() except IOError as err: gbp.log.info('Failed to read OS release file %s: %s' % - (filename, err)) + (filename, err)) def __getitem__(self, key): if key in self._values: @@ -54,6 +56,7 @@ def __repr__(self): return repr(self._values) + class MockedChangeLog(ChangeLog): contents = """foo (%s) experimental; urgency=low @@ -61,7 +64,7 @@ -- Debian Maintainer Sat, 01 Jan 2012 00:00:00 +0100""" - def __init__(self, version, changes = "a important change"): + def __init__(self, version, changes="a important change"): ChangeLog.__init__(self, contents=self.contents % (version, changes)) @@ -101,6 +104,7 @@ contents.update(['%s%s' % (prefix, dname) for dname in dirs]) return contents + def ls_tar(tarball, directories=True): """List the contents of tar archive""" tmpdir = tempfile.mkdtemp() @@ -111,6 +115,7 @@ finally: shutil.rmtree(tmpdir) + def ls_zip(archive, directories=True): """List the contents of zip file""" tmpdir = tempfile.mkdtemp() @@ -120,4 +125,3 @@ return ls_dir(tmpdir, directories) finally: shutil.rmtree(tmpdir) - diff -Nru git-buildpackage-0.7.5ubuntu0~ppa1/.travis.yml git-buildpackage-0.8.12.2ubuntu0~ppa1/.travis.yml --- git-buildpackage-0.7.5ubuntu0~ppa1/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ git-buildpackage-0.8.12.2ubuntu0~ppa1/.travis.yml 2017-02-11 19:33:12.000000000 +0000 @@ -0,0 +1,13 @@ +--- +sudo: required +language: python + +services: + - docker + +python: + - "2.7" +install: "pip install -r requirements.txt" +script: + - flake8 + - tests/helpers/run-in-docker