-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfold
executable file
·39 lines (31 loc) · 1.25 KB
/
fold
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/7/6 11:31
# @Author : jiakang
# @File : fold
# @Software: IntelliJ IDEA
# sman_notes: Fold several commits to one on the current branch.
import sys, os, time
sys.path.append(os.path.dirname(sys.path[0]))
import utils, __egits
def fold(args=None):
__egits.exit_at_master('fold')
current_branch_name = __egits.get_current_branch_name()
if __egits.has_uncommitted_codes():
utils.print_err('Please deal with uncommitted changes first!')
exit(0)
utils.try_exec('git checkout master')
utils.try_exec('git pull')
new_branch_name = 'tmp_new_branch_%s' % time.time()
utils.try_exec('git checkout -b %s' % new_branch_name)
utils.try_exec('git merge --squash %s' % current_branch_name)
utils.try_exec('git push origin --delete %s' % current_branch_name)
utils.try_exec('git branch -D %s' % current_branch_name)
utils.try_exec('git branch -m %s' % current_branch_name)
utils.try_exec('git push --set-upstream origin %s' % current_branch_name)
commit_msg = __egits.get_commit_msg(args)
if __egits.has_uncommitted_codes():
utils.try_exec('sman fpush %s' % commit_msg)
if __name__ == '__main__':
args = sys.argv
fold(args[1:])