我尝试使用GitPython
,但我只是得到了 actual 提交git哈希。
import git
repo = git.Repo(search_parent_directories=True)
repo.head.commit.hexsha
但是,出于可疑性,我想存储特定文件的git commit哈希,即等效于此命令(使用git
)
git log -n 1 --pretty=format:%h -- experiments/test.yaml
是否可以通过GitPython
来达到目标?
答案 0 :(得分:0)
how do I get sha key for any repository' file.之类的问题指向the Tree object,因为它提供了对git树的递归遍历的访问,并可以访问所有元数据,包括SHA1哈希。
class MyComponent extends React.Component {
state = {
image: null
}
fileSelectHandler = event => {
this.setState = {
image: event.target.files[0]
}
}
fileUploadHandler = event => {
const { image } = this.state
S3.upload({
files: image,
path: "subfolder"
}, function (e, r) {
console.log(r);
});
}
render() {
return (
// Stuff
);
}
}
self.assertEqual(tree['smmap'], tree / 'smmap') # access by index and by sub-path
for entry in tree: # intuitive iteration of tree members
print(entry)
blob = tree.trees[0].blobs[0] # let's get a blob in a sub-tree
assert blob.name
将是团块的SHA1。