Skip to content

Commit

Permalink
List number of commits to return by a config
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed ElKalioby committed Nov 23, 2017
1 parent 8c6220a commit 490b3e7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 3 additions & 1 deletion server/Config.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[Server]
port: 4567
publicKey: /home/mohamed/AutoDeploy/server/client.pub
publicKey: /home/shgpuser/dev/AutoDeploy/server/client.pub

[MISC]
log_limit: 30
8 changes: 4 additions & 4 deletions server/autodeploy-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def validReq(req):


def HandleClient(clientsock):
import config
name = threading.currentThread().getName()
print name, ' Started.............'
global EOM
Expand Down Expand Up @@ -112,7 +113,6 @@ def HandleClient(clientsock):
cmd = gclient.get_list_branches()
result = []
res = Common.run(cmd)
print res
if "ERR:" in res:
Response.sendData(clientsock, res)
else:
Expand All @@ -122,15 +122,15 @@ def HandleClient(clientsock):
result.append(line.replace("*","").strip())
except:
pass
print result
#print result
Response.sendData(clientsock, "\n".join(result))
return
elif req["requestType"]=="LIST-COMMITS":
job = Request.parseGetCommitsJob(msg)
if job["scm"]=="git":
gclient=git.GIT(workdir=job["workdir"])
gclient.setKey(job["key"])
cmd=gclient.get_history_cmd(job["options"])
cmd=gclient.get_history_cmd(job["options"],limit=config.log_limit)
elif req["requestType"]=="SWITCH-TAG":
job = Request.parseSwitchTagJob(msg)
if job["scm"]=="git":
Expand Down Expand Up @@ -178,7 +178,7 @@ def HandleClient(clientsock):
if cmd!="":
print cmd
res=Common.run(cmd)
print res

Response.sendData(clientsock,res)
if debug:
print "Ended,",res
Expand Down
4 changes: 4 additions & 0 deletions server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@

publicKey=config.get('Server', 'publicKey')
port=config.get('Server', 'port')
try:
log_limit=config.get('MISC', 'log_limit')
except:
log_limit=100
9 changes: 4 additions & 5 deletions server/scm/Git.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ def get_list_branches(self):

def get_switch_to_tag_cmd(self,tag):
return "cd %s; git checkout tags/%s"%(self.workdir,tag)
def get_history_cmd(self,options={}):
def get_history_cmd(self,options={},limit=0):
branch=options.get("branch","")
cmd = 'cd ' + self.workdir +'; git log '
if branch!="":
cmd += branch
else:
cmd+= ' --all '
if limit!=0: cmd+= "-n %s "%limit
if branch!="": cmd += branch
else: cmd+= ' --all '
cmd += ' --pretty=format:"%H,,%h,,%an,,%ar,,%s,,%cd" | cat -'
return cmd
def switch_to_histroy_cmd(self,commit):
Expand Down

0 comments on commit 490b3e7

Please sign in to comment.