@@ -117,7 +117,8 @@ def repo(
117
117
118
118
# Store git commands for directory prefix
119
119
git_commands = []
120
- is_repo = host .get_fact (Directory , path = unix_path_join (dest , '.git' ))
120
+ git_dir = unix_path_join (dest , '.git' )
121
+ is_repo = host .get_fact (Directory , path = git_dir )
121
122
122
123
# Cloning new repo?
123
124
if not is_repo :
@@ -126,12 +127,20 @@ def repo(
126
127
else :
127
128
git_commands .append ('clone {0} .' .format (src ))
128
129
130
+ host .create_fact (GitBranch , kwargs = {'repo' : dest }, data = branch )
131
+ host .create_fact (
132
+ Directory ,
133
+ kwargs = {'path' : git_dir },
134
+ data = {'user' : user , 'group' : group },
135
+ )
136
+
129
137
# Ensuring existing repo
130
138
else :
131
139
current_branch = host .get_fact (GitBranch , repo = dest )
132
140
if current_branch != branch :
133
141
git_commands .append ('fetch' ) # fetch to ensure we have the branch locally
134
142
git_commands .append ('checkout {0}' .format (branch ))
143
+ host .create_fact (GitBranch , kwargs = {'repo' : dest }, data = branch )
135
144
136
145
if pull :
137
146
if rebase :
@@ -155,8 +164,8 @@ def repo(
155
164
for cmd in git_commands :
156
165
yield cmd
157
166
158
- # Apply any user or group
159
- if user or group :
167
+ # Apply any user or group if we did anything
168
+ if git_commands and ( user or group ) :
160
169
yield chown (dest , user , group , recursive = True )
161
170
162
171
0 commit comments