generate_patches
Generate patches from repo in the form suitable for later analysis by
the annotate.py
script, and then further for gathering statistics with
the gather_data.py
script.
Example (after installing the 'patchscope' package): diff-generate PatchScope --output-dataset=patchscope/user-jnareb --author=jnareb
main ¶
main(
ctx: Context,
repo_path: Annotated[
Path,
Argument(
exists=True,
file_okay=False,
dir_okay=True,
readable=True,
help="Path to git repository.",
),
],
output_dir: Annotated[
Optional[Path],
Option(
file_okay=False,
dir_okay=True,
help="Where to save generated patches.",
),
] = None,
use_fanout: Annotated[
bool,
Option(
help="Use fan-out when saving patches, saved as `*.diff`"
),
] = False,
) -> None
Create patches from local Git repository with provided REPO_PATH
You can add additional options and parameters, which will be passed to
the git format-patch
command. With those options and arguments, you
can specify which commits to operate on.
-
A single commit,
<since>
, specifies that commits leading to the tip of the current branch that are not in the history that leads to the<since>
to be output. Example: 'HEAD~2
'. Not supported with '--use-fanout
'. -
Generic
<revision-range>
expression means the commits in the specified range. Example: 'origin/main..main
', or '--root HEAD
', or '--user=joe --root HEAD
'.
If not provided <since>
or <revision-range>
, a single patch for
the current commit on the current branch will be created ('HEAD
').
To create patches for everything since the beginning of history
up until <commit>
, use '--root <commit>
' as extra options.
Source code in src/diffannotator/generate_patches.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|