:
, . :
git unidiff.
import git
from unidiff import PatchSet
from cStringIO import StringIO
commit_sha1 = 'commit_sha'
repo_directory_address = "your/repo/address"
repository = git.Repo(repo_directory_address)
commit = repository.commit(commit_sha1)
uni_diff_text = repository.git.diff(commit_sha1+ '~1', commit_sha1,
ignore_blank_lines=True,
ignore_space_at_eol=True)
patch_set = PatchSet(StringIO(uni_diff_text), encoding='utf-8')
change_list = []
for patched_file in patch_set:
file_path = patched_file.path
print('file name :' + file_path)
del_line_no = [line.target_line_no
for hunk in patched_file for line in hunk
if line.is_added and
line.value.strip() != '']
print('deleted lines : ' + str(del_line_no))
ad_line_no = [line.source_line_no for hunk in patched_file
for line in hunk if line.is_removed and
line.value.strip() != '']
print('added lines : ' + str(ad_line_no))
change_list.append((file_path, del_line_no, ad_line_no))
( )
- . gitpython git diff. git diff ---, gitpython ------, python ( asticsearch):
import git
repo_directory_address = '/your/elasticsearch/repository/address'
revision = "ace83d9d2a97cfe8a8aa9bdd7b46ce71713fb494"
repository = git.Repo(repo_directory_address)
commit = repository.commit(rev=revision)
diff_index = commit.diff(revision+'~1', create_patch=True, ignore_blank_lines=True,
ignore_space_at_eol=True, diff_filter='cr')
print reduce(lambda x, y: str(x)+str(y), diff_index)
:
core/src/main/java/org/elasticsearch/action/index/IndexRequest.java
lhs: 100644 | f8b0ce6c13fd819a02b1df612adc929674749220
rhs: 100644 | b792241b56ce548e7dd12ac46068b0bcf4649195
@@ -20,16 +20,18 @@
package org.elasticsearch.action.index;
import org.elasticsearch.ElasticsearchGenerationException;
+import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.DocumentRequest;
import org.elasticsearch.action.RoutingMissingException;
import org.elasticsearch.action.TimestampParsingException;
import org.elasticsearch.action.support.replication.ReplicationRequest;
import org.elasticsearch.client.Requests;
+import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.UUIDs;
+import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
, 4 ------. , unidiff 0.5.2, /unidiff/constants.py :
RE_SOURCE_FILENAME = re.compile(
r'^--- (?P<filename>[^\t\n]+)(?:\t(?P<timestamp>[^\n]+))?')
:
RE_SOURCE_FILENAME = re.compile(
r'^------ (?P<filename>[^\t\n]+)(?:\t(?P<timestamp>[^\n]+))?')
PS: , gitpython diff, ---. , git diff (diff_filter = 'cr').