Skip to content

Commit 490b3e7

Browse files
author
Mohamed ElKalioby
committed
List number of commits to return by a config
1 parent 8c6220a commit 490b3e7

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

server/Config.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[Server]
22
port: 4567
3-
publicKey: /home/mohamed/AutoDeploy/server/client.pub
3+
publicKey: /home/shgpuser/dev/AutoDeploy/server/client.pub
44

5+
[MISC]
6+
log_limit: 30

server/autodeploy-server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def validReq(req):
4242

4343

4444
def HandleClient(clientsock):
45+
import config
4546
name = threading.currentThread().getName()
4647
print name, ' Started.............'
4748
global EOM
@@ -112,7 +113,6 @@ def HandleClient(clientsock):
112113
cmd = gclient.get_list_branches()
113114
result = []
114115
res = Common.run(cmd)
115-
print res
116116
if "ERR:" in res:
117117
Response.sendData(clientsock, res)
118118
else:
@@ -122,15 +122,15 @@ def HandleClient(clientsock):
122122
result.append(line.replace("*","").strip())
123123
except:
124124
pass
125-
print result
125+
#print result
126126
Response.sendData(clientsock, "\n".join(result))
127127
return
128128
elif req["requestType"]=="LIST-COMMITS":
129129
job = Request.parseGetCommitsJob(msg)
130130
if job["scm"]=="git":
131131
gclient=git.GIT(workdir=job["workdir"])
132132
gclient.setKey(job["key"])
133-
cmd=gclient.get_history_cmd(job["options"])
133+
cmd=gclient.get_history_cmd(job["options"],limit=config.log_limit)
134134
elif req["requestType"]=="SWITCH-TAG":
135135
job = Request.parseSwitchTagJob(msg)
136136
if job["scm"]=="git":
@@ -178,7 +178,7 @@ def HandleClient(clientsock):
178178
if cmd!="":
179179
print cmd
180180
res=Common.run(cmd)
181-
print res
181+
182182
Response.sendData(clientsock,res)
183183
if debug:
184184
print "Ended,",res

server/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111

1212
publicKey=config.get('Server', 'publicKey')
1313
port=config.get('Server', 'port')
14+
try:
15+
log_limit=config.get('MISC', 'log_limit')
16+
except:
17+
log_limit=100

server/scm/Git.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ def get_list_branches(self):
2828

2929
def get_switch_to_tag_cmd(self,tag):
3030
return "cd %s; git checkout tags/%s"%(self.workdir,tag)
31-
def get_history_cmd(self,options={}):
31+
def get_history_cmd(self,options={},limit=0):
3232
branch=options.get("branch","")
3333
cmd = 'cd ' + self.workdir +'; git log '
34-
if branch!="":
35-
cmd += branch
36-
else:
37-
cmd+= ' --all '
34+
if limit!=0: cmd+= "-n %s "%limit
35+
if branch!="": cmd += branch
36+
else: cmd+= ' --all '
3837
cmd += ' --pretty=format:"%H,,%h,,%an,,%ar,,%s,,%cd" | cat -'
3938
return cmd
4039
def switch_to_histroy_cmd(self,commit):

0 commit comments

Comments
 (0)