1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
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 | diff --git a/usd-clone b/usd-clone
index d3a409f..47a556f 100755
--- a/usd-clone
+++ b/usd-clone
@@ -94,7 +94,7 @@ find_lp_user() {
}
prompt_for_lpuser() {
- local user="" add="" cmd="" url="" none="$LP_USER_NONE"
+ local user="" proto="$proto" add="" cmd="" url="" none="$LP_USER_NONE"
if [ ! -t 0 -o ! -t 1 ]; then
error "Input not a terminal, assuming user=$none"
_RET="$none"
@@ -108,8 +108,8 @@ prompt_for_lpuser() {
fi
url="git+ssh://$user@git.launchpad.net/"
cmd=( git config --global "url.$url.insteadof" lp: )
- error "I can store this answer for next time by adding a git config"
- error "alias of 'lp:' to 'git+ssh://$user@git.launchpad.net/'"
+ error "I can store that answer for next time by adding a git config"
+ error "alias of 'lp:' to '$proto://$user@git.launchpad.net/'"
error "Command to do that is:"
error " " "${cmd[@]}"
read -p "Shall I do that now? [Y/n] " add
@@ -172,7 +172,7 @@ main() {
ret=$?
if [ $ret -ne 0 ]; then
if [ $ret -eq 2 ]; then
- prompt_for_lpuser || return
+ prompt_for_lpuser "$proto" || return
lpuser="$_RET"
else
error "Determining your launchpad user id failed."
diff --git a/usd/importer.py b/usd/importer.py
index 596c1c1..01ae905 100755
--- a/usd/importer.py
+++ b/usd/importer.py
@@ -107,10 +107,8 @@ class USDGitRepository:
self._target_remote = self._local_repo.remotes[remote_name]
try:
- subprocess.run('git fetch -q %s' % remote_name,
- shell=True,
- env=self._env
- )
+ subprocess.run(['git', 'fetch', '--quiet', remote_name],
+ env=self._env)
for branch in self._local_repo.listall_branches(pygit2.GIT_BRANCH_REMOTE):
orig_prefix = '%s/' % remote_name
_, prefix, local_head_name = branch.partition(orig_prefix)
@@ -134,17 +132,13 @@ class USDGitRepository:
return self._target_remote
def garbage_collect(self):
- subprocess.run('git gc', shell=True, env=self._env)
+ subprocess.run(['git', 'gc'], env=self._env)
def push(self):
- subprocess.run('git push --all %s' % self._target_remote.name,
- shell=True,
- env=self._env
- )
- subprocess.run('git push --tags %s' % self._target_remote.name,
- shell=True,
- env=self._env
- )
+ subprocess.run(['git', 'push', '--all', self._target_remote.name],
+ env=self._env)
+ subprocess.run(['git', 'push', '--tags=%s' % self._target_remote.name],
+ env=self._env)
def get_changelog_versions_from_treeish(self, ref, patch_overrides):
current_version = None
@@ -307,19 +301,15 @@ class USDGitRepository:
# working tree
if len(self._local_repo.status()) > 0:
subprocess.run(
- 'git checkout --orphan master',
- check=True,
- shell=True,
- env=self._env)
+ ['git', 'checkout', '--orphan', 'master'],
+ check=True, env=self._env)
subprocess.run(
- 'git reset --hard',
+ ['git', 'reset', '--hard'],
check=True,
- shell=True,
env=self._env)
subprocess.run(
- 'git clean -f -d',
+ ['git', 'clean' '--force', '-d'],
check=True,
- shell=True,
env=self._env)
def commit_import(self, publish_parent_commit, changelog_parent_commit, tree_hash, head_name, spi):
@@ -331,11 +321,12 @@ class USDGitRepository:
tag = self.orphan_tag(spi.version)
elif self.get_import_tag(spi.version) is None:
tag = self.import_tag(spi.version)
- commit_tree = 'git commit-tree %s -m \'Import version %s to %s\n\nImported using usd-importer.\'' % (tree_hash, spi.version, head_name)
+ commit_tree = ['git', 'commit-tree', tree_hash,
+ '-m', 'Import version %s to %s\n\nImported using usd-importer.' % (spi.version, head_name)]
if publish_parent_commit is not None:
- commit_tree += ' -p %s' % publish_parent_commit
+ commit_tree += ['-p', publish_parent_commit]
if changelog_parent_commit is not None:
- commit_tree += ' -p %s' % changelog_parent_commit
+ commit_tree += ['-p', changelog_parent_commit]
commit_env = self._env
commit_env.update(self.get_commit_environment(tree_hash, spi))
cp = subprocess.run(
@@ -344,7 +335,6 @@ class USDGitRepository:
stderr=subprocess.DEVNULL,
universal_newlines=True,
check=True,
- shell=True,
env=commit_env
)
commit_hash = cp.stdout.strip()
@@ -357,11 +347,8 @@ class USDGitRepository:
if tag is not None:
# should be annotated to use create_tag API
logging.info('Creating tag %s pointing to %s', tag, commit_hash)
- subprocess.run(
- 'git tag %s %s' % (tag, commit_hash),
- check=True,
- shell=True,
- env=self._env)
+ subprocess.run(['git', 'tag', tag, commit_hash],
+ check=True, env=self._env)
@staticmethod
def version_compare(a, b):
@@ -503,12 +490,11 @@ class USDGitRepository:
# relies on this API being present, handle error if not?
cp = subprocess.run(
- 'git dsc-commit --tree-only %s' % srcpkg.dsc_pathname,
+ ['git', 'dsc-commit', '--tree-only', srcpkg.dsc_pathname],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
universal_newlines=True,
check=True,
- shell=True,
env=self._env)
import_tree_hash = cp.stdout.strip()
logging.info('Imported version %s as tree %s',
|