- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestgit.py
More file actions
Latest commit
45 lines (40 loc) · 1.26 KB
/
Copy pathtestgit.py
File metadata and controls
45 lines (40 loc) · 1.26 KB
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
importos
importyaml
importgit
fromgitimportRepo
importlogging
defmain():
logging.basicConfig(filename='gittest.log',level=logging.DEBUG)
ifos.path.isdir("flux-demo"):
g=git.cmd.Git("flux-demo")
g.pull()
logging.info('repo is pulled times')
else:
git.Git("").clone("git@github.com:itsmesinghavneet/flux-demo.git")
logging.info('repo is cloned')
if__name__=="__main__":main()
defset_state(state):
withopen('flux-demo/hello-deploy.yaml') asf:
doc=yaml.load(f)
logging.debug('yaml file is loaded')
doc['metadata']['annotations']['flux.weave.works/locked'] =state
logging.debug('Selected the part to edit')
withopen('flux-demo/hello-deploy.yaml', 'w') asf:
yaml.safe_dump(doc, f, default_flow_style=False)
logging.debug('File is opened in write mode')
set_state("true")
logging.debug('The value is changed ')
repo_dir='flux-demo/'
repo=Repo(repo_dir)
logging.debug('choosed the repo')
file_list= [
'hello-deploy.yaml'
]
commit_message='deautomate'
logging.debug('The commit initialed')
repo.index.add(file_list)
logging.debug('File added')
repo.index.commit(commit_message)
origin=repo.remote('origin')
repo.git.push('git@github.com:itsmesinghavneet/flux-demo.git')
logging.debug('File is being pushed')