Skip to content

Can't pass environment variables to Git.execute #644

@AJMansfield

Description

@AJMansfield

This is needed for commands like git-commit and git-commit-tree in order to be able to specify author and committer information. While git-commit does provide the --author and --date to specify author information, there are no options for specifying committer information, and git-commit-tree is wholly dependent on environment variables.

For instance, the following code fails with TypeError: type object got multiple values for keyword argument 'env'.

def pipe_of(string):
	import os
	if type(string) is str:
		string = bytes(string, 'utf-8')
	r,w = os.pipe()
	os.write(w, string)
	os.close(w)
	return r
git = Repo('/path/ro/repo').git
blob = git.execute(['git', 'hash-object', '-w', '--stdin'], istream=pipe_of("my data"))
tree = git.execute(['git', 'mktree'], istream=pipe_of("100644 blob {}\tmy-file\n".format(blob)))
commit = git.execute(['git', 'commit-tree', tree], istream=None, env={
	'GIT_AUTHOR_NAME':'Author Name',
	'GIT_AUTHOR_EMAIL':'author@example.com',
	'GIT_AUTHOR_DATE':'1400000000+0000',
	'GIT_COMMITTER_NAME':'Comitter Name',
	'GIT_COMMITTER_EMAIL':'committer@example.com',
	'GIT_COMMITTER_DATE':'1500000000+0000',
	})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy